Correctly return NULL from messaging_ctdbd_connection if messaging_init failed
[Samba.git] / source / torture / t_push_ucs2.c
blobb9bf87ba5460f9a0e832b5e98ffeaea42581d014
1 /*
2 * Copyright (C) 2003 by Martin Pool
3 * Copyright (C) 2003 by Andrew Bartlett
5 * Test harness for push_ucs2
6 */
8 #include "includes.h"
10 static int check_push_ucs2(const char *orig)
12 smb_ucs2_t *dest = NULL;
13 char *orig2 = NULL;
14 int ret;
15 size_t converted_size;
17 push_ucs2_allocate(&dest, orig, &converted_size);
18 pull_ucs2_allocate(&orig2, dest, &converted_size);
19 ret = strcmp(orig, orig2);
20 if (ret) {
21 fprintf(stderr, "orig: %s\n", orig);
22 fprintf(stderr, "orig (UNIX -> UCS2 -> UNIX): %s\n", orig2);
25 SAFE_FREE(dest);
26 SAFE_FREE(orig2);
28 return ret;
31 int main(int argc, char *argv[])
33 int i, ret = 0;
34 int count = 1;
36 /* Needed to initialize character set */
37 lp_load("/dev/null", True, False, False, True);
39 if (argc < 2) {
40 fprintf(stderr, "usage: %s STRING1 [COUNT]\n"
41 "Checks that a string translated UNIX->UCS2->UNIX is unchanged\n"
42 "Should be always 0\n",
43 argv[0]);
44 return 2;
46 if (argc >= 3)
47 count = atoi(argv[2]);
49 for (i = 0; ((i < count) && (!ret)); i++)
50 ret = check_push_ucs2(argv[1]);
52 printf("%d\n", ret);
54 return 0;