summaryrefslogtreecommitdiff
path: root/source4/pidl/tests/header.pl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-02-08 23:54:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:44:54 -0500
commit45db1030651e69896fdb9e78aa2e2495a7ce7ff5 (patch)
tree86734e4199b036ac8ade8c39cd7b10cd112c4b73 /source4/pidl/tests/header.pl
parent57a68c93178ee9e0159366a8b02af01a86e601f5 (diff)
downloadsamba-45db1030651e69896fdb9e78aa2e2495a7ce7ff5.tar.gz
samba-45db1030651e69896fdb9e78aa2e2495a7ce7ff5.tar.bz2
samba-45db1030651e69896fdb9e78aa2e2495a7ce7ff5.zip
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)
Diffstat (limited to 'source4/pidl/tests/header.pl')
-rwxr-xr-xsource4/pidl/tests/header.pl36
1 files changed, 36 insertions, 0 deletions
diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl
new file mode 100755
index 0000000000..e7cd913916
--- /dev/null
+++ b/source4/pidl/tests/header.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+use strict;
+use warnings;
+
+use Test::More tests => 9;
+use FindBin qw($RealBin);
+use lib "$RealBin";
+use Util;
+use Parse::Pidl::Util qw(MyDumper);
+use Parse::Pidl::Samba4::Header;
+use Parse::Pidl::IDL qw(parse_string);
+
+sub parse_idl($)
+{
+ my $text = shift;
+ my $idl = Parse::Pidl::IDL::parse_string($text, "nofile");
+ return Parse::Pidl::Samba4::Header::Parse($idl);
+}
+
+is("/* header auto-generated by pidl */\n\n#include <core.h>\n\n", parse_idl(""), "includes work");
+is("/* header auto-generated by pidl */\n\n#include <core.h>\n\n", parse_idl("interface x {}"), "simple empty interface doesn't cause overhead");
+like(parse_idl("interface p { typedef struct { int y; } x; };"),
+ qr/.*#ifndef _HEADER_p\n#define _HEADER_p\n.+\n#endif \/\* _HEADER_p \*\/.*/ms, "ifdefs are created");
+like(parse_idl("interface p { typedef struct { int y; } x; };"),
+ qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly");
+like(parse_idl("interface x { void foo (void); };"),
+ qr/struct foo.*{\s+int _dummy_element;\s+};/sm, "void fn contains dummy element");
+like(parse_idl("interface x { void foo ([in] uint32 x); };"),
+ qr/struct foo.*{\s+struct\s+{\s+uint32_t x;\s+} in;\s+};/sm, "fn in arg works");
+like(parse_idl("interface x { void foo ([out] uint32 x); };"),
+ qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn out arg works");
+like(parse_idl("interface x { void foo ([in,out] uint32 x); };"),
+ qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works");
+like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out");