ldb:attrib_handlers: make ldb_comparison_Boolean more consistent
[samba.git] / pidl / tests / ndr_align.pl
blob80d61158e3700eee0e5350f550ec8516a5049f02
1 #!/usr/bin/perl
2 # NDR alignment tests
3 # (C) 2005 Jelmer Vernooij. Published under the GNU GPL
4 use strict;
5 use warnings;
7 use Test::More tests => 5 * 8;
8 use FindBin qw($RealBin);
9 use lib "$RealBin";
10 use Util qw(test_samba4_ndr);
12 test_samba4_ndr('align-uint8-uint16',
14 typedef [public] struct {
15 uint8 x;
16 uint16 y;
17 } bla;
20 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
21 struct bla r;
22 uint8_t expected[] = { 0x0D, 0x00, 0xef, 0xbe };
23 DATA_BLOB expected_blob = { expected, 4 };
24 DATA_BLOB result_blob;
25 r.x = 13;
26 r.y = 0xbeef;
28 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
29 return 1;
31 result_blob = ndr_push_blob(ndr);
33 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
34 return 2;
35 ');
37 test_samba4_ndr('align-uint8-uint32',
39 typedef [public] struct {
40 uint8 x;
41 uint32 y;
42 } bla;
45 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
46 struct bla r;
47 uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe };
48 DATA_BLOB expected_blob = { expected, 8 };
49 DATA_BLOB result_blob;
50 r.x = 13;
51 r.y = 0xbeefbeef;
53 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
54 return 1;
56 result_blob = ndr_push_blob(ndr);
58 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
59 return 2;
60 ');
63 test_samba4_ndr('align-uint8-hyper',
65 typedef [public] struct {
66 uint8 x;
67 hyper y;
68 } bla;
71 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
72 struct bla r;
73 uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe };
75 DATA_BLOB expected_blob = { expected, 16 };
76 DATA_BLOB result_blob;
77 r.x = 13;
78 r.y = 0xbeefbeefbeefbeefLLU;
80 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
81 return 1;
83 result_blob = ndr_push_blob(ndr);
85 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
86 return 2;
87 ');
89 test_samba4_ndr('noalignflag-uint8-uint16',
91 typedef [public] struct {
92 uint8 x;
93 uint16 y;
94 } bla;
97 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
98 struct bla r;
99 uint8_t expected[] = { 0x0D, 0xef, 0xbe };
100 DATA_BLOB expected_blob = { expected, 3 };
101 DATA_BLOB result_blob;
102 ndr->flags |= LIBNDR_FLAG_NOALIGN;
104 r.x = 13;
105 r.y = 0xbeef;
107 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
108 return 1;
110 result_blob = ndr_push_blob(ndr);
112 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
113 return 2;
116 test_samba4_ndr('align-blob-align2',
118 typedef [public] struct {
119 uint8 x;
120 [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data;
121 uint8 y;
122 } blie;
125 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
126 struct blie r;
127 uint8_t data[] = { 0x01, 0x02 };
128 uint8_t expected[] = { 0x0D, 0x00, 0x0E };
129 DATA_BLOB expected_blob = { expected, 3 };
130 DATA_BLOB result_blob;
132 r.x = 13;
133 r.y = 14;
134 r.data.data = data;
135 r.data.length = 2;
137 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
138 return 1;
140 result_blob = ndr_push_blob(ndr);
142 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
143 return 2;