diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-01-09 15:50:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:37:18 -0500 |
commit | bf39b5e5929449b7ef8685b6c7737efd3a31843b (patch) | |
tree | e94bbccf584e68d61122effbc385ca602b6e42ee /source4/pidl/tests | |
parent | eccb2d16dfb584ce4c38cd08235b9ab5eca6072c (diff) | |
download | samba-bf39b5e5929449b7ef8685b6c7737efd3a31843b.tar.gz samba-bf39b5e5929449b7ef8685b6c7737efd3a31843b.tar.bz2 samba-bf39b5e5929449b7ef8685b6c7737efd3a31843b.zip |
r20631: Add some tests for the ndr parser.
(This used to be commit ded25eca701b8e3e0e13e7ef64d5511d8953eb0d)
Diffstat (limited to 'source4/pidl/tests')
-rwxr-xr-x | source4/pidl/tests/ndr.pl | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl new file mode 100755 index 0000000000..97199a4120 --- /dev/null +++ b/source4/pidl/tests/ndr.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij <jelmer@samba.org> +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 9; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement); + +# Case 1 + +my $e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {}, + 'POINTERS' => 0, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 0, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +my $ne = ParseElement($e); +is($ne->{ORIGINAL}, $e); +is($ne->{NAME}, "v"); +is($ne->{ALIGN}, 1); +is($ne->{TYPE}, "uint8"); +is_deeply($ne->{LEVELS}, [ + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 0, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +# Case 2 : pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {}, + 'POINTERS' => 1, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => undef, + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 1, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +# Case 3 : double pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {}, + 'POINTERS' => 2, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => undef, + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => undef, + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 2, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +# Case 2 : ref pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 1, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 1, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); |