s3:torture/test_smb2: check directory listing during reauth
[Samba.git] / pidl / tests / typelist.pl
blobe99b016487b9ad369f5d2942efbdea1ab511aef8
1 #!/usr/bin/perl
2 # (C) 2007 Jelmer Vernooij <jelmer@samba.org>
3 # Published under the GNU General Public License
4 use strict;
5 use warnings;
7 use Test::More tests => 56;
8 use FindBin qw($RealBin);
9 use lib "$RealBin";
10 use Util;
11 use Parse::Pidl::Typelist qw(hasType typeHasBody getType mapTypeName expandAlias
12 mapScalarType addType typeIs is_scalar scalar_is_reference
13 enum_type_fn bitmap_type_fn mapType);
15 is("foo", expandAlias("foo"));
16 is("uint32", expandAlias("DWORD"));
17 is("int32", expandAlias("int"));
18 is("", expandAlias(""));
19 is("int32", expandAlias("int32"));
21 is("uint32_t", mapScalarType("uint32"));
22 is("void", mapScalarType("void"));
23 is("uint64_t", mapScalarType("hyper"));
24 is("double", mapScalarType("double"));
26 my $x = { TYPE => "ENUM", NAME => "foo", EXTRADATA => 1 };
27 addType($x);
28 is_deeply($x, getType("foo"));
29 is(undef, getType("bloebla"));
30 is_deeply(getType({ TYPE => "STRUCT" }), { TYPE => "STRUCT" });
31 is_deeply(getType({ TYPE => "ENUM", NAME => "foo" }), $x);
32 is_deeply(getType("uint16"), {
33 NAME => "uint16",
34 BASEFILE => "<builtin>",
35 TYPE => "TYPEDEF",
36 DATA => { NAME => "uint16", TYPE => "SCALAR" }});
38 is_deeply(getType("double"), {
39 NAME => "double",
40 BASEFILE => "<builtin>",
41 TYPE => "TYPEDEF",
42 DATA => { NAME => "double", TYPE => "SCALAR" }});
44 is(0, typeIs("someUnknownType", "ENUM"));
45 is(0, typeIs("foo", "ENUM"));
46 addType({NAME => "mytypedef", TYPE => "TYPEDEF", DATA => { TYPE => "ENUM" }});
47 is(1, typeIs("mytypedef", "ENUM"));
48 is(0, typeIs("mytypedef", "BITMAP"));
49 is(1, typeIs({ TYPE => "ENUM"}, "ENUM"));
50 is(0, typeIs({ TYPE => "BITMAP"}, "ENUM"));
51 is(1, typeIs("uint32", "SCALAR"));
52 is(0, typeIs("uint32", "ENUM"));
54 is(1, hasType("foo"));
55 is(0, hasType("nonexistant"));
56 is(0, hasType({TYPE => "ENUM", NAME => "someUnknownType"}));
57 is(1, hasType({TYPE => "ENUM", NAME => "foo"}));
58 is(1, hasType({TYPE => "ENUM"}));
59 is(1, hasType({TYPE => "STRUCT"}));
61 is(1, is_scalar("uint32"));
62 is(0, is_scalar("nonexistant"));
63 is(1, is_scalar({TYPE => "ENUM"}));
64 is(0, is_scalar({TYPE => "STRUCT"}));
65 is(1, is_scalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM" }}));
66 is(1, is_scalar("mytypedef"));
68 is(1, scalar_is_reference("string"));
69 is(0, scalar_is_reference("uint32"));
70 is(0, scalar_is_reference({TYPE => "STRUCT", NAME => "echo_foobar"}));
72 is("uint8", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {enum8bit => 1}}}));
73 is("uint32", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {v1_enum => 1}}}));
74 is("uint1632", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {}}}));
76 is("uint8", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}}));
77 is("uint16", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap16bit => 1}}));
78 is("hyper", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap64bit => 1}}));
79 is("uint32", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {}}));
81 is("enum foo", mapType({TYPE => "ENUM"}, "foo"));
82 is("union foo", mapType({TYPE => "UNION"}, "foo"));
83 is("struct foo", mapType({TYPE => "STRUCT"}, "foo"));
84 is("uint8_t", mapType({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}}, "foo"));
85 is("uint8_t", mapType({TYPE => "SCALAR"}, "uint8"));
86 is("uint32_t", mapType({TYPE => "TYPEDEF", DATA => {TYPE => "SCALAR"}}, "uint32"));
88 is("void", mapTypeName(undef));
89 is("uint32_t", mapTypeName("uint32"));
90 is("int32_t", mapTypeName("int"));
92 ok(not typeHasBody({TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT" }}));
93 ok(typeHasBody({TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [] }}));