test/dummy

filter: Statementstmt 100% 62 / 62 Branchbran 50.0% 18 / 36 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 81.4% 88 / 108 CC 1 SCAR 0.0
CC
1
Cov
81%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Device/ParallelPort/drv/dummy_byte.pm ↑ Summary
1 #!/usr/bin/perl -w
2 1 ▶use Test;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶BEGIN { plan tests => 35 };
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use lib '../lib';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use lib 'lib';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Device::ParallelPort;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶my $DEBUG = $ARGV[0] || 0;
Condition50%1/2
$ARGV[0] || 0
l!l
01
MC/DC0%0/1
$ARGV[0] || 0
$ARGV[0]
Truth table50%1/2
A
A= $ARGV[0]
Aresult
11
00
10  
11 # 1. We loaded up ok.
12 1 ok(1);
13  
14 # Tests = 17 * 2
15 1 foreach my $drv_name (qw/dummy_byte dummy_bit/) {
16  
17 # 2. Create a byte device.
18 2 ▶ print STDERR "CREATE Device - $drv_name\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
19 2 my $pp = Device::ParallelPort->new($drv_name);
20 2 ok(defined($pp));
21  
22 # 3. Set some bits
23 2 ▶ print STDERR "SET_BIT: 2,1\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
24 2 $pp->set_bit(2, 1); # Set the first bit of the 2nd byte on.
25 2 ok(1);
26  
27 # 4,5,6 - BIT Tests
28 2 ▶ print STDERR "GET_BIT: 2\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
29 2 ok ($pp->get_bit(2) == 1);
30 2 ▶ print STDERR "GET_BYTE 0\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
31 2 ok (ord($pp->get_byte(0)) == 4);
32 2 ▶ print STDERR "GET_BYTE 1\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
33 2 ok (ord($pp->get_byte(1)) == 0);
34
35 # 7. Set some bits
36 2 ▶ print STDERR "SET_BIT: 8,1\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
37 2 $pp->set_bit(8, 1); # Set the first bit of the 2nd byte on.
38 2 ok(1);
39  
40 # 8,9,10 - BIT Tests
41 2 ▶ print STDERR "GET_BIT: 8\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
42 2 ok ($pp->get_bit(8) == 1);
43 2 ▶ print STDERR "GET_BYTE 0\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
44 2 ok (ord($pp->get_byte(0)) == 4);
45 2 ▶ print STDERR "GET_BYTE 1\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
46 2 ok (ord($pp->get_byte(1)) == 1);
47  
48 # 11 - Set another bit in same byte
49 2 ▶ print STDERR "SET_BIT: 9,1\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
50 2 $pp->set_bit(9, 1); # Set the first bit of the 2nd byte on.
51 2 ok(1);
52
53 # 12, 13 - check ok
54 2 ▶ print STDERR "GET_BIT: 9\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
55 2 ok ($pp->get_bit(9) == 1);
56 2 ▶ print STDERR "GET_BYTE 1\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
57 2 ok (ord($pp->get_byte(1)) == 3);
58  
59 # 14 - Simple byte set and check bits
60 2 ▶ print STDERR "SET_BYTE 2,5\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
61 2 $pp->set_byte(2, chr(5));
62 2 ok(1);
63
64 # 15, 16, 17, 18 - check ok
65 2 ▶ print STDERR "GET_BYTE 2\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
66 2 ▶ print STDERR "\t = " . ord($pp->get_byte(2)) . "\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
67 2 ok (ord($pp->get_byte(2)) == 5);
68 2 ▶ print STDERR "GET_BIT 16\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
69 2 ok ($pp->get_bit(16) == 1);
70 2 ▶ print STDERR "GET_BIT 17\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
71 2 ok ($pp->get_bit(17) == 0);
72 2 ▶ print STDERR "GET_BIT 18\n" if ($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 2 2
73 2 ok ($pp->get_bit(18) == 1);
74 }
75  
« lib/Device/ParallelPort/drv/dummy_byte.pm ↑ Summary