File Coverage

tests/ndr_string.pl
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             # String tests for pidl
3             # (C) 2005 Jelmer Vernooij
4             # Published under the GNU General Public License
5 1     1   7 use strict;
  1         1  
  1         139  
6              
7 1     1   1213 use Test::More tests => 2 * 8;
  1         30552  
  1         11  
8 1     1   2823 use FindBin qw($RealBin);
  1         1445  
  1         122  
9 1     1   942 use lib "$RealBin/../lib";
  1         964  
  1         7  
10 1     1   177 use lib "$RealBin";
  1         2  
  1         5  
11 1     1   832 use Util qw(test_samba4_ndr);
  0            
  0            
12              
13             test_samba4_ndr("string-pull-empty",
14             ' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);',
15             '
16             uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
17             DATA_BLOB b = { data, 4 };
18             struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
19             struct TestString r;
20             r.in.data = NULL;
21              
22             if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r)))
23             return 1;
24            
25             if (r.in.data == NULL)
26             return 2;
27              
28             if (r.in.data[0] != 0)
29             return 3;
30             ');
31              
32             test_samba4_ndr("string-ascii-pull",
33             '
34             [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);
35             ',
36             '
37             uint8_t data[] = { 0x03, 0x00, 0x00, 0x00,
38             \'f\', \'o\', \'o\', 0 };
39             DATA_BLOB b = { data, 8 };
40             struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
41             struct TestString r;
42             r.in.data = NULL;
43              
44             if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r)))
45             return 1;
46            
47             if (r.in.data == NULL)
48             return 2;
49              
50             if (strncmp(r.in.data, "foo", 3) != 0)
51             return 3;
52              
53             if (r.in.data[4] != 0)
54             return 4;
55             ');