s3-loadparm: Fix resume command typo for "printing = vlp".
[Samba.git] / source / pidl / tests / ndr_string.pl
blobb6e64066d67f1eb1c0217773396c364ffd3805c5
1 #!/usr/bin/perl
2 # String tests for pidl
3 # (C) 2005 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU General Public License
5 use strict;
7 use Test::More tests => 3 * 8;
8 use FindBin qw($RealBin);
9 use lib "$RealBin";
10 use Util qw(test_samba4_ndr);
12 test_samba4_ndr("string-pull-empty",
13 ' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);',
15 uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
16 DATA_BLOB b = { data, 4 };
17 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
18 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
19 struct TestString r;
20 r.in.data = NULL;
22 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
23 return 1;
25 if (r.in.data == NULL)
26 return 2;
28 if (r.in.data[0] != 0)
29 return 3;
30 ');
32 test_samba4_ndr("string-ascii-pull",
34 [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);
37 uint8_t data[] = { 0x03, 0x00, 0x00, 0x00,
38 \'f\', \'o\', \'o\', 0 };
39 DATA_BLOB b = { data, 8 };
40 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
41 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
42 struct TestString r;
43 r.in.data = NULL;
45 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
46 return 1;
48 if (r.in.data == NULL)
49 return 2;
51 if (strncmp(r.in.data, "foo", 3) != 0)
52 return 3;
54 if (r.in.data[4] != 0)
55 return 4;
56 ');
58 SKIP: {
59 skip "doesn't seem to work yet", 8;
61 test_samba4_ndr("string-out",
63 [public] void TestString([out,string,charset(UNIX)] uint8 **data);
66 uint8_t data[] = { 0x03, 0x00, 0x00, 0x00,
67 \'f\', \'o\', \'o\', 0 };
68 DATA_BLOB b = { data, 8 };
69 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
70 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
71 struct TestString r;
72 char *str = NULL;
73 r.out.data = &str;
75 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
76 return 1;
78 if (r.out.data == NULL)
79 return 2;
81 if (*r.out.data == NULL)
82 return 3;
84 if (strncmp(r.out.data, "foo", 3) != 0)
85 return 4;
87 if (r.out.data[4] != 0)
88 return 5;
89 ');