summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-03-02 14:05:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:49:05 -0500
commitf653871d770006620533b7dc50f350991d567712 (patch)
treebfb0825ba7033fbf7a30bb8e134b9afb14b7a65b /source4
parent04fed31e1a61366debd217510cb1a9d767fbaaec (diff)
downloadsamba-f653871d770006620533b7dc50f350991d567712.tar.gz
samba-f653871d770006620533b7dc50f350991d567712.tar.bz2
samba-f653871d770006620533b7dc50f350991d567712.zip
r21654: Add simple test for print functions.
(This used to be commit 3c9df011a85aa8178a26d66faaaed5c88757800e)
Diffstat (limited to 'source4')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm2
-rwxr-xr-xsource4/pidl/tests/samba-ndr.pl24
2 files changed, 23 insertions, 3 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 16d60ace53..ac4b390e76 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -12,7 +12,7 @@ require Exporter;
@EXPORT = qw(is_charset_array);
@EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv
GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv NeededFunction
- NeededElement NeededType $res NeededInterface TypeFunctionName);
+ NeededElement NeededType $res NeededInterface TypeFunctionName ParseElementPrint);
use strict;
use Parse::Pidl::Typelist qw(hasType getType mapTypeName);
diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl
index a806d33417..cf79cd006f 100755
--- a/source4/pidl/tests/samba-ndr.pl
+++ b/source4/pidl/tests/samba-ndr.pl
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 38;
+use Test::More tests => 41;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -12,7 +12,7 @@ use Parse::Pidl::Util qw(MyDumper);
use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
EnvSubstituteValue NeededFunction NeededElement NeededType $res
- NeededInterface TypeFunctionName);
+ NeededInterface TypeFunctionName ParseElementPrint);
my $output;
sub print_fn($) { my $x = shift; $output.=$x; }
@@ -303,3 +303,23 @@ is(TypeFunctionName("ndr_pull", "uint32"), "ndr_pull_uint32");
is(TypeFunctionName("ndr_pull", {TYPE => "ENUM", NAME => "bar"}), "ndr_pull_ENUM_bar");
is(TypeFunctionName("ndr_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef}), "ndr_pull_bar");
is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_STRUCT_bar");
+
+# check noprint works
+$res = "";
+ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
+ PROPERTIES => { noprint => 1},
+ LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, "var", { "x" => "r->foobar" } );
+is($res, "");
+
+$res = "";
+ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
+ PROPERTIES => {},
+ LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, "var", { "x" => "r->foobar" } );
+is($res, "ndr_print_rt(ndr, \"x\", &var);\n");
+
+# make sure that a print function for an element with value() set works
+$res = "";
+ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32",
+ PROPERTIES => { value => "23" },
+ LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } );
+is($res, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n");