diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-03-02 14:05:52 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:49:05 -0500 |
commit | f653871d770006620533b7dc50f350991d567712 (patch) | |
tree | bfb0825ba7033fbf7a30bb8e134b9afb14b7a65b /source4/pidl/tests | |
parent | 04fed31e1a61366debd217510cb1a9d767fbaaec (diff) | |
download | samba-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/pidl/tests')
-rwxr-xr-x | source4/pidl/tests/samba-ndr.pl | 24 |
1 files changed, 22 insertions, 2 deletions
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"); |