diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-02-18 23:48:16 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:48:34 -0500 |
commit | 127ccc27d45f4da84a6687562f50d733a011adfe (patch) | |
tree | cab613d29b29b1c9a6f1180d594c55beb3176b93 /source4 | |
parent | 5cd79db03e143eaaa9b63a28d3f0824edb1295d2 (diff) | |
download | samba-127ccc27d45f4da84a6687562f50d733a011adfe.tar.gz samba-127ccc27d45f4da84a6687562f50d733a011adfe.tar.bz2 samba-127ccc27d45f4da84a6687562f50d733a011adfe.zip |
r21437: Cherrypick typelib tests.
(This used to be commit 9ba814d033412150d383d3687f02775d4efc618e)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Typelist.pm | 5 | ||||
-rwxr-xr-x | source4/pidl/tests/typelist.pl | 59 |
2 files changed, 63 insertions, 1 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm index a098f1ab05..55f8390f65 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/source4/pidl/lib/Parse/Pidl/Typelist.pm @@ -7,7 +7,10 @@ package Parse::Pidl::Typelist; require Exporter; @ISA = qw(Exporter); -@EXPORT_OK = qw(hasType getType mapTypeName scalar_is_reference expandAlias); +@EXPORT_OK = qw(hasType getType mapTypeName scalar_is_reference expandAlias + mapScalarType addType typeIs is_scalar enum_type_fn + bitmap_type_fn mapType +); use vars qw($VERSION); $VERSION = '0.01'; diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl new file mode 100755 index 0000000000..5c1a7ddd21 --- /dev/null +++ b/source4/pidl/tests/typelist.pl @@ -0,0 +1,59 @@ +#!/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 => 33; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Typelist qw(hasType getType mapTypeName expandAlias + mapScalarType addType typeIs is_scalar scalar_is_reference + enum_type_fn bitmap_type_fn mapType); + +is("foo", expandAlias("foo")); +is("uint32", expandAlias("DWORD")); +is("int32", expandAlias("int")); +is("", expandAlias("")); +is("int32", expandAlias("int32")); + +is("uint32_t", mapScalarType("uint32")); +is("void", mapScalarType("void")); +is("uint64_t", mapScalarType("hyper")); + +my $x = { TYPE => "ENUM", NAME => "foo" }; +addType($x); +is($x, getType("foo")); +is(undef, getType("bloebla")); + +is(0, typeIs("someUnknownType", "ENUM")); + +is(1, hasType("foo")); +is(0, hasType("nonexistant")); + +is(1, is_scalar("uint32")); +is(0, is_scalar("nonexistant")); + +is(1, scalar_is_reference("string")); +is(0, scalar_is_reference("uint32")); + +is("uint8", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {enum8bit => 1}}})); +is("uint32", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {v1_enum => 1}}})); +is("uint16", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {}}})); + +is("uint8", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}})); +is("uint16", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap16bit => 1}})); +is("hyper", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap64bit => 1}})); +is("uint32", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {}})); + +is("enum foo", mapType({TYPE => "ENUM"}, "foo")); +is("union foo", mapType({TYPE => "UNION"}, "foo")); +is("struct foo", mapType({TYPE => "STRUCT"}, "foo")); +is("uint8_t", mapType({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}}, "foo")); +is("uint8_t", mapType({TYPE => "SCALAR"}, "uint8")); +is("uint32_t", mapType({TYPE => "TYPEDEF", DATA => {TYPE => "SCALAR"}}, "uint32")); + +is("void", mapTypeName(undef)); +is("uint32_t", mapTypeName("uint32")); +is("int32_t", mapTypeName("int")); |