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 8BEGIN { $| = 1; print "1..29\n"; } 9END {print "not ok 1\n" unless $loaded;} 10 11use Net::DNS::Codes qw(:constants); 12 13$loaded = 1; 14print "ok 1\n"; 15######################### End of black magic. 16 17# Insert your test code below (better if it prints "ok 13" 18# (correspondingly "not ok 13") depending on the success of chunk 13 19# of the test code): 20 21$test = 2; 22 23sub ok { 24 print "ok $test\n"; 25 ++$test; 26} 27 28## test 2-29 check class codes 29my %constants = (qw( 30 NS_PACKETSZ 512 31 NS_MAXDNAME 1025 32 NS_MAXCDNAME 255 33 NS_MAXLABEL 63 34 NS_HFIXEDSZ 12 35 NS_QFIXEDSZ 4 36 NS_RRFIXEDSZ 10 37 NS_INT32SZ 4 38 NS_INT16SZ 2 39 NS_INT8SZ 1 40 NS_INADDRSZ 4 41 NS_IN6ADDRSZ 16 42 NS_DEFAULTPORT 53 43 PACKETSZ 512 44 MAXDNAME 1025 45 MAXCDNAME 255 46 MAXLABEL 63 47 HFIXEDSZ 12 48 QFIXEDSZ 4 49 RRFIXEDSZ 10 50 INT32SZ 4 51 INT16SZ 2 52 INT8SZ 1 53 INADDRSZ 4 54 IN6ADDRSZ 16 55 NAMESERVER_PORT 53 56 ), 57 ( NS_CMPRSFLGS => 0xc0, 58 INDIR_MASK => 0xc0, 59 ) 60); 61 62foreach(sort keys %constants) { 63 my $value = eval($_); 64 printf("constant %s\ngot: %d\nexp: %d\nnot ",$_,$value,$constants{$_}) 65 unless $value == $constants{$_}; 66 &ok; 67} 68 69