File Coverage

test/dummy
Criterion Covered Total %
statement 59 59 100.0
branch 18 36 50.0
condition 1 2 50.0
subroutine 6 6 100.0
pod n/a
total 84 103 81.5


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   1300 use Test;
  1         4172  
  1         146  
3 1     1   4 BEGIN { plan tests => 35 };
4 1     1   911 use strict;
  1         2  
  1         52  
5 1     1   965 use lib '../lib';
  1         1616  
  1         8  
6 1     1   123 use lib 'lib';
  1         3  
  1         3  
7 1     1   503 use Device::ParallelPort;
  1         2  
  1         2280  
8              
9 1   50     10 my $DEBUG = $ARGV[0] || 0;
10              
11             # 1. We loaded up ok.
12 1         9 ok(1);
13              
14             # Tests = 17 * 2
15 1         1238 foreach my $drv_name (qw/dummy_byte dummy_bit/) {
16              
17             # 2. Create a byte device.
18 2 50       44 print STDERR "CREATE Device - $drv_name\n" if ($DEBUG);
19 2         21 my $pp = Device::ParallelPort->new($drv_name);
20 2         234 ok(defined($pp));
21              
22             # 3. Set some bits
23 2 50       1019 print STDERR "SET_BIT: 2,1\n" if ($DEBUG);
24 2         16 $pp->set_bit(2, 1); # Set the first bit of the 2nd byte on.
25 2         7 ok(1);
26              
27             # 4,5,6 - BIT Tests
28 2 50       381 print STDERR "GET_BIT: 2\n" if ($DEBUG);
29 2         14 ok ($pp->get_bit(2) == 1);
30 2 50       604 print STDERR "GET_BYTE 0\n" if ($DEBUG);
31 2         17 ok (ord($pp->get_byte(0)) == 4);
32 2 50       546 print STDERR "GET_BYTE 1\n" if ($DEBUG);
33 2         8 ok (ord($pp->get_byte(1)) == 0);
34            
35             # 7. Set some bits
36 2 50       712 print STDERR "SET_BIT: 8,1\n" if ($DEBUG);
37 2         9 $pp->set_bit(8, 1); # Set the first bit of the 2nd byte on.
38 2         8 ok(1);
39              
40             # 8,9,10 - BIT Tests
41 2 50       352 print STDERR "GET_BIT: 8\n" if ($DEBUG);
42 2         10 ok ($pp->get_bit(8) == 1);
43 2 50       988 print STDERR "GET_BYTE 0\n" if ($DEBUG);
44 2         8 ok (ord($pp->get_byte(0)) == 4);
45 2 50       654 print STDERR "GET_BYTE 1\n" if ($DEBUG);
46 2         10 ok (ord($pp->get_byte(1)) == 1);
47              
48             # 11 - Set another bit in same byte
49 2 50       396 print STDERR "SET_BIT: 9,1\n" if ($DEBUG);
50 2         11 $pp->set_bit(9, 1); # Set the first bit of the 2nd byte on.
51 2         6 ok(1);
52            
53             # 12, 13 - check ok
54 2 50       601 print STDERR "GET_BIT: 9\n" if ($DEBUG);
55 2         64 ok ($pp->get_bit(9) == 1);
56 2 50       385 print STDERR "GET_BYTE 1\n" if ($DEBUG);
57 2         9 ok (ord($pp->get_byte(1)) == 3);
58              
59             # 14 - Simple byte set and check bits
60 2 50       774 print STDERR "SET_BYTE 2,5\n" if ($DEBUG);
61 2         19 $pp->set_byte(2, chr(5));
62 2         6 ok(1);
63            
64             # 15, 16, 17, 18 - check ok
65 2 50       312 print STDERR "GET_BYTE 2\n" if ($DEBUG);
66 2 50       5 print STDERR "\t = " . ord($pp->get_byte(2)) . "\n" if ($DEBUG);
67 2         8 ok (ord($pp->get_byte(2)) == 5);
68 2 50       431 print STDERR "GET_BIT 16\n" if ($DEBUG);
69 2         9 ok ($pp->get_bit(16) == 1);
70 2 50       3783 print STDERR "GET_BIT 17\n" if ($DEBUG);
71 2         16 ok ($pp->get_bit(17) == 0);
72 2 50       200 print STDERR "GET_BIT 18\n" if ($DEBUG);
73 2         9 ok ($pp->get_bit(18) == 1);
74             }
75