summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-02-18 12:54:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:48:32 -0500
commitae76a5a92819bfd2d31bc5d23a540c6c71b47354 (patch)
treefbbf1ad737aeebe576034aaa008bc8d1052af42f /source4/pidl/tests
parentab975d9d7fc2cf92f1e254d5ee9078cc00d08636 (diff)
downloadsamba-ae76a5a92819bfd2d31bc5d23a540c6c71b47354.tar.gz
samba-ae76a5a92819bfd2d31bc5d23a540c6c71b47354.tar.bz2
samba-ae76a5a92819bfd2d31bc5d23a540c6c71b47354.zip
r21427: Add tests for Needed*(), in preparation of refactoring.
(This used to be commit a21e7b22ac99c66e2b23d0fa694a8a2ea6e7994e)
Diffstat (limited to 'source4/pidl/tests')
-rwxr-xr-xsource4/pidl/tests/samba-ndr.pl60
1 files changed, 58 insertions, 2 deletions
diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl
index db261d4492..f64a8c4093 100755
--- a/source4/pidl/tests/samba-ndr.pl
+++ b/source4/pidl/tests/samba-ndr.pl
@@ -4,12 +4,14 @@
use strict;
use warnings;
-use Test::More tests => 20;
+use Test::More tests => 29;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv EnvSubstituteValue);
+use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
+ GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
+ EnvSubstituteValue NeededFunction NeededElement NeededTypedef);
my $output;
sub print_fn($) { my $x = shift; $output.=$x; }
@@ -172,3 +174,57 @@ $fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] };
$env = GenerateStructEnv($fn);
EnvSubstituteValue($env, $fn);
is_deeply($env, { foo => 0, this => "r" });
+
+my $needed = {};
+NeededElement({ TYPE => "foo" }, "pull", $needed);
+is_deeply($needed, { pull_foo => 1 });
+
+# old settings should be kept
+$needed = { pull_foo => 0 };
+NeededElement({ TYPE => "foo" }, "pull", $needed);
+is_deeply($needed, { pull_foo => 0 });
+
+# print/pull/push are independent of each other
+$needed = { pull_foo => 0 };
+NeededElement({ TYPE => "foo" }, "print", $needed);
+is_deeply($needed, { pull_foo => 0, print_foo => 1 });
+
+$needed = { };
+NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed);
+is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
+ pull_bar => 1, print_bar => 1, push_bar => 1});
+
+# push/pull/print are always set for functions
+$needed = { pull_foo => 0 };
+NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed);
+is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
+ pull_bar => 1, push_bar => 1, print_bar => 1});
+
+# public structs are always needed
+$needed = {};
+NeededTypedef({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
+ $needed);
+is_deeply($needed, { });
+
+$needed = {};
+NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla",
+ DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
+ $needed);
+is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 });
+
+# make sure types for elements are set too
+$needed = {};
+NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla",
+ DATA => { TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "bar" } ] } },
+ $needed);
+is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1,
+ pull_bar => 1, print_bar => 1, push_bar => 1});
+
+$needed = {};
+NeededTypedef({ PROPERTIES => { gensize => 1}, NAME => "bla",
+ DATA => { TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "bar" } ] } },
+ $needed);
+is_deeply($needed, { ndr_size_bla => 1 });
+