| 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..13\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 | #use diagnostics; | ||||||||||
| 12 | 1 | ▶ | use NetAddr::IP::InetBase qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | inet_ntoa | ||||||||||
| 14 | inet_aton | ||||||||||
| 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 | 12 | ▶ | sub ok { | ||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 12 | print "ok $test\n"; | |||||||||
| 29 | 12 | ++$test; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | ## test 2 add stuff to buffer | ||||||||||
| 33 | 1 | my @num = # addr | |||||||||
| 34 | qw( | ||||||||||
| 35 | 0.0.0.0 | ||||||||||
| 36 | 255.255.255.255 | ||||||||||
| 37 | 1.2.3.4 | ||||||||||
| 38 | 10.253.230.9 | ||||||||||
| 39 | ); | ||||||||||
| 40 | |||||||||||
| 41 | 1 | foreach (@num) { | |||||||||
| 42 | 4 | my @digs = split(/\./,$_); | |||||||||
| 43 | 4 | my $pkd = pack('C4',@digs); | |||||||||
| 44 | 4 | my $naddr = inet_aton($_); | |||||||||
| 45 | 4 | my $addr = join('.',unpack('C4',$naddr)); | |||||||||
| 46 | 4 | my $num = inet_ntoa($pkd); | |||||||||
| 47 | |||||||||||
| 48 | 4 | ▶ | print "bits do not match\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | unless $naddr eq $pkd; | ||||||||||
| 50 | 4 | &ok; | |||||||||
| 51 | |||||||||||
| 52 | 4 | ▶ | print "inet_aton: $addr, exp: $_\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | unless $addr eq $_; | ||||||||||
| 54 | 4 | &ok; | |||||||||
| 55 | |||||||||||
| 56 | 4 | ▶ | print "inet_ntoa: $num, exp: $_\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | unless $num eq $_; | ||||||||||
| 58 | 4 | &ok; | |||||||||
| 59 | } | ||||||||||