| 1 | # Before `make install' is performed this script should be runnable with | ||||||||||||||||||||||||||||||||
| 2 | # `make test'. After `make install' it should work as `perl test.pl' | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | ######################### We start with some black magic to print on failure. | ||||||||||||||||||||||||||||||||
| 5 | # Change 1..1 below to 1..last_test_to_print . | ||||||||||||||||||||||||||||||||
| 6 | # (It may become useful if the test is moved to ./t subdirectory.) | ||||||||||||||||||||||||||||||||
| 7 | 1 | $| = 1; | |||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | END {print "1..1\nnot ok 1\n" unless $test;} | ||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use NetAddr::IP::Util qw( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | ipv6_aton | ||||||||||||||||||||||||||||||||
| 12 | ipv6_n2x | ||||||||||||||||||||||||||||||||
| 13 | 1 | ); | |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 1 | $test = 1; | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 18 | ▶ | sub ok { | ||||||||||||||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 18 | print "ok $test\n"; | |||||||||||||||||||||||||||||||
| 19 | 18 | ++$test; | |||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 1 | my @addr = | |||||||||||||||||||||||||||||||
| 23 | qw( :: 0:0:0:0:0:0:0:0 | ||||||||||||||||||||||||||||||||
| 24 | ::: undef | ||||||||||||||||||||||||||||||||
| 25 | foo undef | ||||||||||||||||||||||||||||||||
| 26 | ::foo undef | ||||||||||||||||||||||||||||||||
| 27 | foo:: undef | ||||||||||||||||||||||||||||||||
| 28 | abc::def::9 undef | ||||||||||||||||||||||||||||||||
| 29 | abcd1:: undef | ||||||||||||||||||||||||||||||||
| 30 | abcd:: abcd:0:0:0:0:0:0:0 | ||||||||||||||||||||||||||||||||
| 31 | ::abcde undef | ||||||||||||||||||||||||||||||||
| 32 | :a:b:c:d:1:2:3:4 undef | ||||||||||||||||||||||||||||||||
| 33 | :a:b:c:d undef | ||||||||||||||||||||||||||||||||
| 34 | a:b:c:d:1:2:3:4: undef | ||||||||||||||||||||||||||||||||
| 35 | a:b:c:d:1:2:3:4:: undef | ||||||||||||||||||||||||||||||||
| 36 | ::a:b:c:d:1:2:3:4 undef | ||||||||||||||||||||||||||||||||
| 37 | ::a:b:c:d:1:2:3 0:a:b:c:d:1:2:3 | ||||||||||||||||||||||||||||||||
| 38 | ::a:b:c:d:1:2:3: undef | ||||||||||||||||||||||||||||||||
| 39 | :a:b:c:d:1:2:3:: undef | ||||||||||||||||||||||||||||||||
| 40 | a:b:c:d:1:2:3:: a:b:c:d:1:2:3:0 | ||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 1 | my $x = @addr/2; | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | # notify TEST about number of tests | ||||||||||||||||||||||||||||||||
| 46 | # Insert your test code below (better if it prints "ok 13" | ||||||||||||||||||||||||||||||||
| 47 | # (correspondingly "not ok 13") depending on the success of chunk 13 | ||||||||||||||||||||||||||||||||
| 48 | # of the test code): | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 1 | print '1..',$x,"\n"; | |||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | for ($x = 0;$x <= $#addr; $x+=2) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 53 | 18 | my $bstr = ipv6_aton($addr[$x]); | |||||||||||||||||||||||||||||||
| 54 | 18 | ▶ | if ($addr[$x +1] =~ /undef/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 55 | 14 | ▶ | print "unexpected return value for $addr[$x]: $_\nnot " | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
ipv6_aton() && (ipv6_n2x($_) || 'not defined')
ipv6_n2x($_) or "not defined"
MC/DC0%0/2
ipv6_aton() && (ipv6_n2x($_) || 'not defined')
ipv6_aton()
ipv6_n2x($_)
Truth table33%1/3
A && B
A= ipv6_aton()B= ipv6_n2x($_)
| |||||||||||||||||||||||||||||||||
| 56 | if ($_ = ipv6_aton && (ipv6_n2x($_) || 'not defined')); | ||||||||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||||||||
| 58 | 4 | my $rv = ipv6_aton($addr[$x]); | |||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | unless ($rv) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 60 | 0 | print "got undefined value for $addr[$x]\nnot "; | |||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | else { | ||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | $rv = ipv6_n2x($rv) || 'not defined'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
ipv6_n2x($rv) || 'not defined'
MC/DC0%0/1
ipv6_n2x($rv) || 'not defined'
ipv6_n2x($rv)
Truth table50%1/2
A
A= ipv6_n2x($rv)
| |||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | print "got: $rv, exp: $addr[$x +1]\nnot " | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 65 | unless $rv eq uc $addr[$x +1]; | ||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | 18 | &ok; | |||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||