summaryrefslogtreecommitdiff
path: root/source4/pidl/tests/ndr.pl
diff options
context:
space:
mode:
Diffstat (limited to 'source4/pidl/tests/ndr.pl')
-rwxr-xr-xsource4/pidl/tests/ndr.pl289
1 files changed, 282 insertions, 7 deletions
diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl
index 7fcc7ef40e..504b7ec8de 100755
--- a/source4/pidl/tests/ndr.pl
+++ b/source4/pidl/tests/ndr.pl
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 40;
+use Test::More tests => 46;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -22,7 +22,7 @@ my $e = {
'PARENT' => { TYPE => 'STRUCT' },
'LINE' => 42 };
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
{
'IS_DEFERRED' => 0,
'LEVEL_INDEX' => 0,
@@ -33,7 +33,7 @@ is_deeply(GetElementLevelTable($e), [
}
]);
-my $ne = ParseElement($e, undef);
+my $ne = ParseElement($e, "unique");
is($ne->{ORIGINAL}, $e);
is($ne->{NAME}, "v");
is($ne->{ALIGN}, 1);
@@ -60,7 +60,7 @@ $e = {
'TYPE' => 'uint8',
'LINE' => 42 };
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
{
LEVEL_INDEX => 0,
IS_DEFERRED => 0,
@@ -90,7 +90,7 @@ $e = {
'PARENT' => { TYPE => 'STRUCT' },
'LINE' => 42 };
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
{
LEVEL_INDEX => 0,
IS_DEFERRED => 0,
@@ -128,7 +128,7 @@ $e = {
'PARENT' => { TYPE => 'STRUCT' },
'LINE' => 42 };
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
{
LEVEL_INDEX => 0,
IS_DEFERRED => 0,
@@ -147,6 +147,97 @@ is_deeply(GetElementLevelTable($e), [
}
]);
+# Case 3 : ref pointers
+#
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => {"ref" => 1},
+ 'POINTERS' => 3,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'STRUCT' },
+ 'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "unique"), [
+ {
+ LEVEL_INDEX => 0,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 0,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 1,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 1,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 2,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 2,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ 'IS_DEFERRED' => 1,
+ 'LEVEL_INDEX' => 3,
+ 'DATA_TYPE' => 'uint8',
+ 'CONTAINS_DEFERRED' => 0,
+ 'TYPE' => 'DATA',
+ 'IS_SURROUNDING' => 0,
+ }
+]);
+
+# Case 3 : ref pointers
+#
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => {"ref" => 1},
+ 'POINTERS' => 3,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'STRUCT' },
+ 'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "ref"), [
+ {
+ LEVEL_INDEX => 0,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 0,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 1,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 1,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 2,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 2,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ 'IS_DEFERRED' => 1,
+ 'LEVEL_INDEX' => 3,
+ 'DATA_TYPE' => 'uint8',
+ 'CONTAINS_DEFERRED' => 0,
+ 'TYPE' => 'DATA',
+ 'IS_SURROUNDING' => 0,
+ }
+]);
# Case 4 : top-level ref pointers
#
@@ -159,7 +250,7 @@ $e = {
'PARENT' => { TYPE => 'FUNCTION' },
'LINE' => 42 };
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
{
LEVEL_INDEX => 0,
IS_DEFERRED => 0,
@@ -178,6 +269,190 @@ is_deeply(GetElementLevelTable($e), [
}
]);
+# Case 4 : top-level ref pointers, triple with pointer_default("unique")
+#
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => {"ref" => 1},
+ 'POINTERS' => 3,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'FUNCTION' },
+ 'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "unique"), [
+ {
+ LEVEL_INDEX => 0,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 0,
+ LEVEL => 'TOP'
+ },
+ {
+ LEVEL_INDEX => 1,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 1,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 2,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 2,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ 'IS_DEFERRED' => 1,
+ 'LEVEL_INDEX' => 3,
+ 'DATA_TYPE' => 'uint8',
+ 'CONTAINS_DEFERRED' => 0,
+ 'TYPE' => 'DATA',
+ 'IS_SURROUNDING' => 0,
+ }
+]);
+
+# Case 4 : top-level unique pointers, triple with pointer_default("unique")
+#
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => {"unique" => 1, "in" => 1},
+ 'POINTERS' => 3,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'FUNCTION' },
+ 'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "unique"), [
+ {
+ LEVEL_INDEX => 0,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 0,
+ LEVEL => 'TOP'
+ },
+ {
+ LEVEL_INDEX => 1,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 1,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 2,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 2,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ 'IS_DEFERRED' => 1,
+ 'LEVEL_INDEX' => 3,
+ 'DATA_TYPE' => 'uint8',
+ 'CONTAINS_DEFERRED' => 0,
+ 'TYPE' => 'DATA',
+ 'IS_SURROUNDING' => 0,
+ }
+]);
+
+# Case 4 : top-level unique pointers, triple with pointer_default("ref")
+#
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => {"unique" => 1, "in" => 1},
+ 'POINTERS' => 3,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'FUNCTION' },
+ 'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "ref"), [
+ {
+ LEVEL_INDEX => 0,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "unique",
+ POINTER_INDEX => 0,
+ LEVEL => 'TOP'
+ },
+ {
+ LEVEL_INDEX => 1,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 1,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 2,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 2,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ 'IS_DEFERRED' => 1,
+ 'LEVEL_INDEX' => 3,
+ 'DATA_TYPE' => 'uint8',
+ 'CONTAINS_DEFERRED' => 0,
+ 'TYPE' => 'DATA',
+ 'IS_SURROUNDING' => 0,
+ }
+]);
+
+# Case 4 : top-level ref pointers, triple with pointer_default("ref")
+#
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => {"ref" => 1},
+ 'POINTERS' => 3,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'FUNCTION' },
+ 'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "ref"), [
+ {
+ LEVEL_INDEX => 0,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 0,
+ LEVEL => 'TOP'
+ },
+ {
+ LEVEL_INDEX => 1,
+ IS_DEFERRED => 0,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 1,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ LEVEL_INDEX => 2,
+ IS_DEFERRED => 1,
+ TYPE => 'POINTER',
+ POINTER_TYPE => "ref",
+ POINTER_INDEX => 2,
+ LEVEL => 'EMBEDDED'
+ },
+ {
+ 'IS_DEFERRED' => 1,
+ 'LEVEL_INDEX' => 3,
+ 'DATA_TYPE' => 'uint8',
+ 'CONTAINS_DEFERRED' => 0,
+ 'TYPE' => 'DATA',
+ 'IS_SURROUNDING' => 0,
+ }
+]);
+
# representation_type
$e = {
'FILE' => 'foo.idl',