| 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 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | BEGIN { $| = 1; print "1..27\n"; } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | END {print "not ok 1\n" unless $loaded;} | ||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use NetAddr::IP::Util qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | ipv6_aton | ||||||||||||||||||||||||||||
| 13 | ipv6_n2x | ||||||||||||||||||||||||||||
| 14 | ipv6_n2d | ||||||||||||||||||||||||||||
| 15 | 1 | ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | $loaded = 1; | |||||||||||||||||||||||||||
| 18 | 1 | print "ok 1\n"; | |||||||||||||||||||||||||||
| 19 | ######################### End of black magic. | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Insert your test code below (better if it prints "ok 13" | ||||||||||||||||||||||||||||
| 22 | # (correspondingly "not ok 13") depending on the success of chunk 13 | ||||||||||||||||||||||||||||
| 23 | # of the test code): | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | $test = 2; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 26 | ▶ | sub ok { | ||||||||||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 26 | print "ok $test\n"; | |||||||||||||||||||||||||||
| 29 | 26 | ++$test; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | my @num = # in exphex expd | |||||||||||||||||||||||||||
| 33 | qw( | ||||||||||||||||||||||||||||
| 34 | :: 0:0:0:0:0:0:0:0 0:0:0:0:0:0:0.0.0.0 | ||||||||||||||||||||||||||||
| 35 | 43:: 43:0:0:0:0:0:0:0 43:0:0:0:0:0:0.0.0.0 | ||||||||||||||||||||||||||||
| 36 | ::21 0:0:0:0:0:0:0:21 0:0:0:0:0:0:0.0.0.33 | ||||||||||||||||||||||||||||
| 37 | ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 0:1:2:3:4:5:0.6.0.7 | ||||||||||||||||||||||||||||
| 38 | 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 1:2:3:4:5:6:0.7.0.0 | ||||||||||||||||||||||||||||
| 39 | 1::8 1:0:0:0:0:0:0:8 1:0:0:0:0:0:0.0.0.8 | ||||||||||||||||||||||||||||
| 40 | FF00::FFFF FF00:0:0:0:0:0:0:FFFF FF00:0:0:0:0:0:0.0.255.255 | ||||||||||||||||||||||||||||
| 41 | FFFF::FFFF:FFFF FFFF:0:0:0:0:0:FFFF:FFFF FFFF:0:0:0:0:0:255.255.255.255 | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | for (my $i=0;$i<@num;$i+=3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 8 | my $bits = ipv6_aton($num[$i]); | |||||||||||||||||||||||||||
| 46 | 8 | my $len = length($bits); | |||||||||||||||||||||||||||
| 47 | 8 | ▶ | print "bad len = $len, exp: 16\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | unless $len == 16; # 16 bytes x 8 bits | ||||||||||||||||||||||||||||
| 49 | 8 | &ok; | |||||||||||||||||||||||||||
| 50 | 8 | my $ipv6x = ipv6_n2x($bits); | |||||||||||||||||||||||||||
| 51 | 8 | ▶ | print "got: $ipv6x\nexp: $num[$i +1]\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | unless $ipv6x eq $num[$i +1]; | ||||||||||||||||||||||||||||
| 53 | 8 | &ok; | |||||||||||||||||||||||||||
| 54 | 8 | my $ipv6d = ipv6_n2d($bits); | |||||||||||||||||||||||||||
| 55 | 8 | ▶ | print "got: $ipv6d\nexp: $num[$i +2]\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | unless $ipv6d eq $num[$i +2]; | ||||||||||||||||||||||||||||
| 57 | 8 | &ok; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | ## test 26 check bad length n2x | ||||||||||||||||||||||||||||
| 61 | 1 | my $try = '1234'; | |||||||||||||||||||||||||||
| 62 | 1 | my $notempty = eval { | |||||||||||||||||||||||||||
| 63 | 1 | ipv6_n2x($try); | |||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||
| 65 | 1 | ▶ | print "failed bad argument length test for ipv6_n2x\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $@ =~ /Bad arg/
MC/DC0%0/2
$@ and $@ =~ /Bad arg/
$@
$@ =~ /Bad arg/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg/
| |||||||||||||||||||||||||||||
| 66 | unless $@ && $@ =~ /Bad arg/; | ||||||||||||||||||||||||||||
| 67 | 1 | &ok; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | ## test 27 check bad length n2d | ||||||||||||||||||||||||||||
| 70 | 1 | $notempty = eval { | |||||||||||||||||||||||||||
| 71 | 1 | ipv6_n2d($try); | |||||||||||||||||||||||||||
| 72 | }; | ||||||||||||||||||||||||||||
| 73 | 1 | ▶ | print "failed bad argument length test for ipv6_n2d\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $@ =~ /Bad arg/
MC/DC0%0/2
$@ and $@ =~ /Bad arg/
$@
$@ =~ /Bad arg/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg/
| |||||||||||||||||||||||||||||
| 74 | unless $@ && $@ =~ /Bad arg/; | ||||||||||||||||||||||||||||
| 75 | 1 | &ok; | |||||||||||||||||||||||||||