From 45db1030651e69896fdb9e78aa2e2495a7ce7ff5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 Feb 2007 23:54:31 +0000 Subject: r21253: Merge some pidl fixes: * Add tests for wireshark dissector generator * Add tests for the header code * Some cleanups * Fix handling of elements without [in] or [out] (This used to be commit 1aecba7100685ed291ea13b0ae47fb0cf9e6a6c8) --- source4/pidl/tests/samba-ndr.pl | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests/samba-ndr.pl') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index a3e94bd8b5..a6d74beea9 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 16; 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); +use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -133,3 +133,22 @@ test_warnings("nofile:2: unknown dereferenced expression `r->in.bla'\n", sub { $fn->("r->in.bla"); }); is($output, "if (r->in.bla == NULL) return;"); + +# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work +$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; +is_deeply({ }, GenerateFunctionInEnv($fn)); -- cgit