File Coverage

tests/parse_idl.pl
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             # Some simple tests for pidls parsing routines
3             # (C) 2005 Jelmer Vernooij
4             # Published under the GNU General Public License
5 1     1   8 use strict;
  1         2  
  1         227  
6              
7 1     1   2530 use Test::More tests => 51;
  1         35877  
  1         12  
8 1     1   3350 use FindBin qw($RealBin);
  1         2445  
  1         153  
9 1     1   2648 use lib "$RealBin/../lib";
  1         2027  
  1         11  
10 1     1   3011 use Parse::Pidl::IDL;
  0            
  0            
11             use Parse::Pidl::NDR;
12              
13             sub testok($$)
14             {
15             my ($name, $data) = @_;
16            
17             my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>");
18            
19             ok (defined($pidl), $name);
20             return $pidl
21             }
22              
23             sub testfail($$)
24             {
25             my ($name, $data) = @_;
26            
27             my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>");
28            
29             ok ((not defined $pidl), $name);
30             }
31              
32             testfail "unknowntag", "bla test {};";
33             testok "test1", "interface test { void Test(); }; ";
34             testok "voidtest", "interface test { int Testx(void); }; ";
35             testfail "voidtest", "interface test { Test(); }; ";
36             testok "argtest", "interface test { int Test(int a, long b, uint32 c); }; ";
37             testok "array1", "interface test { int Test(int a[]); };";
38             testok "array2", "interface test { int Test(int a[2]); };";
39             testok "array3", "interface test { int Test(int a[b]); };";
40             testfail "array4", "interface test { int Test(int[] a); };";
41             testok "ptr1", "interface test { int Test(int *a); };";
42             testok "ptr2", "interface test { int Test(int **a); };";
43             testok "ptr3", "interface test { int Test(int ***a); };";
44             testfail "empty1", "interface test { };";
45             testfail "empty2", "";
46             testok "attr1", "[uuid(\"myuuid\"),attr] interface test { int Test(int ***a); };";
47             testok "attr2", "interface test { [public] int Test(); };";
48             testok "attr3", "[attr1] [attr2] interface test { [public] int Test(); };";
49             testok "multfn", "interface test { int test1(); int test2(); };";
50             testok "multif", "interface test { int test1(); }; interface test2 { int test2(); };";
51             testok "tdstruct1", "interface test { typedef struct { } foo; };";
52             testok "tdstruct2", "interface test { typedef struct { int a; } foo; };";
53             testok "tdstruct3", "interface test { typedef struct { int a; int b; } foo; };";
54             testfail "tdstruct4", "interface test { typedef struct { int a, int b; } foo; };";
55             testok "struct1", "interface test { struct x { }; };";
56             testok "struct2", "interface test { struct x { int a; }; };";
57             testok "struct3", "interface test { struct x { int a; int b; }; };";
58             testfail "struct4", "interface test { struct x { int a, int b; }; };";
59             testfail "struct5", "interface test { struct { int a; } x; };";
60             testok "tdunion1", "interface test { typedef union { } a; };";
61             testok "tdunion2", "interface test { typedef union { int a; } a; };";
62             testok "union1", "interface test { union a { }; };";
63             testok "union2", "interface test { union x { int a; }; };";
64             testfail "union3", "interface test { union { int a; } x; };";
65             testok "typedef1", "interface test { typedef int a; };";
66             testfail "typedef2", "interface test { typedef x; };";
67             testok "tdenum1", "interface test { typedef enum { A=1, B=2, C} a; };";
68             testok "enum1", "interface test { enum a { A=1, B=2, C}; };";
69             testfail "enum2", "interface test { enum { A=1, B=2, C} a; };";
70             testok "nested1", "interface test { struct x { struct { int a; } z; }; };";
71             testok "nested2", "interface test { struct x { struct y { int a; } z; }; };";
72             testok "bitmap1", "interface test { bitmap x { a=1 }; };";
73             testok "unsigned", "interface test { struct x { unsigned short y; }; };";
74             testok "signed", "interface test { struct x { signed short y; }; };";
75             testok "declarg", "interface test { void test(struct { int x; } a); };";
76             testok "structqual", "interface test { struct x { struct y z; }; };";
77             testok "unionqual", "interface test { struct x { union y z; }; };";
78             testok "enumqual", "interface test { struct x { enum y z; }; };";
79             testok "bitmapqual", "interface test { struct x { bitmap y z; }; };";
80             testok "emptystructdecl", "interface test { struct x; };";
81             testok "emptyenumdecl", "interface test { enum x; };";
82             testok "emptytdstructdecl", "interface test { typedef struct x y; };";