summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-02-27 23:47:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:48:58 -0500
commitd7a7b7fb0c423c461c24e8157ad926d0cee07da1 (patch)
treecf1a2804ca44edd950fe46d5e4b49ed419b9e086 /source4/pidl/tests
parent3d61a1bbdda98281d8db46b63aa605c794a6af60 (diff)
downloadsamba-d7a7b7fb0c423c461c24e8157ad926d0cee07da1.tar.gz
samba-d7a7b7fb0c423c461c24e8157ad926d0cee07da1.tar.bz2
samba-d7a7b7fb0c423c461c24e8157ad926d0cee07da1.zip
r21572: More work towards supporting tagged types.
(This used to be commit 4d28396f0928444406334888f4bc345e74a380df)
Diffstat (limited to 'source4/pidl/tests')
-rwxr-xr-xsource4/pidl/tests/ndr.pl12
-rwxr-xr-xsource4/pidl/tests/ndr_tagtype.pl41
-rwxr-xr-xsource4/pidl/tests/typelist.pl14
3 files changed, 61 insertions, 6 deletions
diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl
index 26fb6c290b..9824d1e815 100755
--- a/source4/pidl/tests/ndr.pl
+++ b/source4/pidl/tests/ndr.pl
@@ -4,12 +4,12 @@
use strict;
use warnings;
-use Test::More tests => 12;
+use Test::More tests => 17;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement);
+use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type);
# Case 1
@@ -203,3 +203,11 @@ $e = {
$ne = ParseElement($e, undef);
is($ne->{REPRESENTATION_TYPE}, "uint8");
+
+is(align_type("uint32"), 4);
+is(align_type("uint16"), 2);
+is(align_type("uint8"), 1);
+is(align_type({ TYPE => "STRUCT", "NAME" => "bla",
+ ELEMENTS => [ { TYPE => "uint16" } ] }), 4);
+is(align_type({ TYPE => "STRUCT", "NAME" => "bla",
+ ELEMENTS => [ { TYPE => "uint8" } ] }), 4);
diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl
index 067fa096b4..efc5b67746 100755
--- a/source4/pidl/tests/ndr_tagtype.pl
+++ b/source4/pidl/tests/ndr_tagtype.pl
@@ -3,7 +3,7 @@
# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
use strict;
-use Test::More tests => 1 * 8;
+use Test::More tests => 3 * 8;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util qw(test_samba4_ndr);
@@ -25,3 +25,42 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ',
if (!data_blob_equal(&result_blob, &expected_blob))
return 2;
');
+
+test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; };
+ [public] void myfn([in] struct bla r); ',
+'
+ struct ndr_push *ndr = ndr_push_init_ctx(NULL);
+ struct bla r;
+ uint8_t expected[] = { 0x0D };
+ DATA_BLOB expected_blob = { expected, 1 };
+ DATA_BLOB result_blob;
+ r.x = 13;
+
+ if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &r)))
+ return 1;
+
+ result_blob = ndr_push_blob(ndr);
+
+ if (!data_blob_equal(&result_blob, &expected_blob))
+ return 2;
+');
+
+
+test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; };
+ [public] struct myfn { struct bla r; }; ',
+'
+ struct ndr_push *ndr = ndr_push_init_ctx(NULL);
+ struct bla r;
+ uint8_t expected[] = { 0x0D };
+ DATA_BLOB expected_blob = { expected, 1 };
+ DATA_BLOB result_blob;
+ r.x = 13;
+
+ if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &r)))
+ return 1;
+
+ result_blob = ndr_push_blob(ndr);
+
+ if (!data_blob_equal(&result_blob, &expected_blob))
+ return 2;
+');
diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl
index 5c1a7ddd21..d84fe0592c 100755
--- a/source4/pidl/tests/typelist.pl
+++ b/source4/pidl/tests/typelist.pl
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 33;
+use Test::More tests => 38;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -22,15 +22,23 @@ is("uint32_t", mapScalarType("uint32"));
is("void", mapScalarType("void"));
is("uint64_t", mapScalarType("hyper"));
-my $x = { TYPE => "ENUM", NAME => "foo" };
+my $x = { TYPE => "ENUM", NAME => "foo", EXTRADATA => 1 };
addType($x);
-is($x, getType("foo"));
+is_deeply($x, getType("foo"));
is(undef, getType("bloebla"));
+is_deeply(getType({ TYPE => "STRUCT" }), { TYPE => "STRUCT" });
+is_deeply(getType({ TYPE => "ENUM", NAME => "foo" }), $x);
+is_deeply(getType("uint16"), {
+ NAME => "uint16",
+ TYPE => "TYPEDEF",
+ DATA => { NAME => "uint16", TYPE => "SCALAR" }});
is(0, typeIs("someUnknownType", "ENUM"));
is(1, hasType("foo"));
is(0, hasType("nonexistant"));
+is(0, hasType({TYPE => "ENUM", NAME => "someUnknownType"}));
+is(1, hasType({TYPE => "ENUM", NAME => "foo"}));
is(1, is_scalar("uint32"));
is(0, is_scalar("nonexistant"));