samba-tool dsacl: Add subcommand to delete ACEs
[Samba.git] / pidl / tests / ndr_string.pl
blobaa5fd8b5d1d6287fdd9dbed8cbbab4f54fc41c34
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;
6 use warnings;
8 use Test::More tests => 6 * 8;
9 use FindBin qw($RealBin);
10 use lib "$RealBin";
11 use Util qw(test_samba4_ndr);
13 test_samba4_ndr("string-pull-empty",
14 ' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);',
16 uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
17 DATA_BLOB b = { data, 4 };
18 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
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 struct TestString r;
42 r.in.data = NULL;
44 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
45 return 1;
47 if (r.in.data == NULL)
48 return 2;
50 if (strncmp(r.in.data, "foo", 3) != 0)
51 return 3;
53 if (r.in.data[4] != 0)
54 return 4;
55 ');
57 test_samba4_ndr("string-wchar-fixed-array-01",
59 typedef struct {
60 uint32 l1;
61 [string,charset(UTF16)] uint16 str[6];
62 uint32 l2;
63 } TestStringStruct;
65 [public] void TestString([in,ref] TestStringStruct *str);
68 uint8_t data[] = { 0x01, 0x00, 0x00, 0x00,
69 0x00, 0x00, 0x00, 0x00,
70 0x04, 0x00, 0x00, 0x00,
71 \'f\', 0x00, \'o\', 0x00,
72 \'o\', 0x00, 0x00, 0x00,
73 0x02, 0x00, 0x00, 0x00
75 DATA_BLOB b = { data, sizeof(data) };
76 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
77 struct TestString r;
78 struct TestStringStruct str;
79 r.in.str = &str;
81 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
82 return 1;
84 if (r.in.str == NULL)
85 return 2;
87 if (r.in.str->l1 != 0x00000001)
88 return 3;
90 if (strncmp(str.str, "foo", 3) != 0)
91 return 4;
93 if (r.in.str->str[4] != 0)
94 return 5;
96 if (r.in.str->l2 != 0x00000002)
97 return 6;
98 ');
100 test_samba4_ndr("string-wchar-fixed-array-02",
102 typedef struct {
103 uint32 l1;
104 [string,charset(UTF16)] uint16 str[6];
105 uint32 l2;
106 } TestStringStruct;
108 [public] void TestString([in,ref] TestStringStruct *str);
111 uint8_t data[] = { 0x01, 0x00, 0x00, 0x00,
112 0x00, 0x00, 0x00, 0x00,
113 0x06, 0x00, 0x00, 0x00,
114 \'f\', 0x00, \'o\', 0x00,
115 \'o\', 0x00, \'b\', 0x00,
116 \'a\', 0x00, \'r\', 0x00,
117 0x00, 0x00, 0x00, 0x00,
118 0x02, 0x00, 0x00, 0x00
120 DATA_BLOB b = { data, sizeof(data) };
121 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
122 struct TestString r;
123 struct TestStringStruct str;
124 r.in.str = &str;
126 /* the string terminator is wrong */
127 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
128 return 1;
131 test_samba4_ndr("string-wchar-fixed-array-03",
133 typedef struct {
134 uint32 l1;
135 [string,charset(UTF16)] uint16 str[6];
136 uint32 l2;
137 } TestStringStruct;
139 [public] void TestString([in,ref] TestStringStruct *str);
142 uint8_t data[] = { 0x01, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00,
144 0x07, 0x00, 0x00, 0x00,
145 \'f\', 0x00, \'o\', 0x00,
146 \'o\', 0x00, \'b\', 0x00,
147 \'a\', 0x00, \'r\', 0x00,
148 0x00, 0x00, 0x00, 0x00,
149 0x02, 0x00, 0x00, 0x00
151 DATA_BLOB b = { data, sizeof(data) };
152 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
153 struct TestString r;
154 struct TestStringStruct str;
155 r.in.str = &str;
157 /* the length 0x07 is to large */
158 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
159 return 1;
162 SKIP: {
163 skip "doesn't seem to work yet", 8;
165 test_samba4_ndr("string-out",
167 [public] void TestString([out,string,charset(UNIX)] uint8 **data);
170 uint8_t data[] = { 0x03, 0x00, 0x00, 0x00,
171 \'f\', \'o\', \'o\', 0 };
172 DATA_BLOB b = { data, 8 };
173 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
174 struct TestString r;
175 char *str = NULL;
176 r.out.data = &str;
178 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
179 return 1;
181 if (r.out.data == NULL)
182 return 2;
184 if (*r.out.data == NULL)
185 return 3;
187 if (strncmp(r.out.data, "foo", 3) != 0)
188 return 4;
190 if (r.out.data[4] != 0)
191 return 5;