2 # (C) 2007 Jelmer Vernooij <jelmer@samba.org>
3 # Published under the GNU General Public License
7 use Test
::More tests
=> 12;
8 use FindBin
qw($RealBin);
11 use Parse::Pidl::Util qw(MyDumper);
12 use Parse
::Pidl
::NDR
qw(GetElementLevelTable ParseElement);
22 'PARENT' => { TYPE
=> 'STRUCT' },
25 is_deeply
(GetElementLevelTable
($e), [
29 'DATA_TYPE' => 'uint8',
30 'CONVERT_FROM' => undef,
31 'CONTAINS_DEFERRED' => 0,
33 'IS_SURROUNDING' => 0,
38 my $ne = ParseElement
($e);
39 is
($ne->{ORIGINAL
}, $e);
42 is
($ne->{TYPE
}, "uint8");
43 is_deeply
($ne->{LEVELS
}, [
47 'DATA_TYPE' => 'uint8',
48 'CONVERT_FROM' => undef,
49 'CONTAINS_DEFERRED' => 0,
51 'IS_SURROUNDING' => 0,
61 'PROPERTIES' => {"unique" => 1},
63 'PARENT' => { TYPE
=> 'STRUCT' },
67 is_deeply
(GetElementLevelTable
($e), [
72 POINTER_TYPE
=> "unique",
79 'DATA_TYPE' => 'uint8',
80 'CONVERT_FROM' => undef,
81 'CONTAINS_DEFERRED' => 0,
83 'IS_SURROUNDING' => 0,
88 # Case 3 : double pointers
93 'PROPERTIES' => {"unique" => 1},
96 'PARENT' => { TYPE
=> 'STRUCT' },
99 is_deeply
(GetElementLevelTable
($e), [
104 POINTER_TYPE
=> "unique",
112 POINTER_TYPE
=> "unique",
119 'DATA_TYPE' => 'uint8',
120 'CONVERT_FROM' => undef,
121 'CONTAINS_DEFERRED' => 0,
123 'IS_SURROUNDING' => 0,
124 'CONVERT_TO' => undef
128 # Case 3 : ref pointers
133 'PROPERTIES' => {"ref" => 1},
136 'PARENT' => { TYPE
=> 'STRUCT' },
139 is_deeply
(GetElementLevelTable
($e), [
144 POINTER_TYPE
=> "ref",
151 'DATA_TYPE' => 'uint8',
152 'CONVERT_FROM' => undef,
153 'CONTAINS_DEFERRED' => 0,
155 'IS_SURROUNDING' => 0,
156 'CONVERT_TO' => undef
161 # Case 4 : top-level ref pointers
166 'PROPERTIES' => {"ref" => 1},
169 'PARENT' => { TYPE
=> 'FUNCTION' },
172 is_deeply
(GetElementLevelTable
($e), [
177 POINTER_TYPE
=> "ref",
184 'DATA_TYPE' => 'uint8',
185 'CONVERT_FROM' => undef,
186 'CONTAINS_DEFERRED' => 0,
188 'IS_SURROUNDING' => 0,
189 'CONVERT_TO' => undef
193 # representation_type
197 'PROPERTIES' => { represent_as
=> "bar" },
200 'PARENT' => { TYPE
=> 'STRUCT' },
203 $ne = ParseElement
($e);
204 is
($ne->{REPRESENTATION_TYPE
}, "bar");
206 # representation_type
213 'PARENT' => { TYPE
=> 'STRUCT' },
216 $ne = ParseElement
($e);
217 is
($ne->{REPRESENTATION_TYPE
}, "uint8");