File: 03-parameters.t

package info (click to toggle)
libnet-dns-perl 1.50-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,644 kB
  • sloc: perl: 18,185; makefile: 9
file content (85 lines) | stat: -rw-r--r-- 2,947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl
# $Id: 03-parameters.t 1921 2023-05-08 18:39:59Z willem $	-*-perl-*-
#

use strict;
use warnings;
use Test::More;
use TestToolkit;

use Net::DNS::Parameters qw(:class :type :opcode :rcode :ednsoption :dsotype);

plan tests => ( 5 + scalar keys %Net::DNS::Parameters::classbyval ) +
		( 4 + scalar keys %Net::DNS::Parameters::typebyval ) +
		( 5 + scalar keys %Net::DNS::Parameters::opcodebyval ) +
		( 3 + scalar keys %Net::DNS::Parameters::rcodebyval ) +
		( 2 + scalar keys %Net::DNS::Parameters::ednsoptionbyval ) +
		( 2 + scalar keys %Net::DNS::Parameters::dsotypebyval );


foreach ( sort { $a <=> $b } 32767, keys %Net::DNS::Parameters::classbyval ) {
	my $name = classbyval($_);	## check class conversion functions
	my $code = eval { classbyname($name) };
	is( $code, $_, "classbyname($name)" );
}


foreach ( sort { $a <=> $b } 65535, keys %Net::DNS::Parameters::typebyval ) {
	my $name = typebyval($_);	## check type conversion functions
	my $code = eval { typebyname($name) };
	is( $code, $_, "typebyname($name)" );
}
is( typebyname('*'), typebyname('ANY'), "typebyname(*)" );


foreach ( sort { $a <=> $b } 255, keys %Net::DNS::Parameters::opcodebyval ) {
	my $name = opcodebyval($_);	## check OPCODE type conversion functions
	my $code = eval { opcodebyname($name) };
	is( $code, $_, "opcodebyname($name)" );
}
is( opcodebyname('NS_NOTIFY_OP'), opcodebyname('NOTIFY'), "opcodebyname(NS_NOTIFY_OP)" );


foreach ( sort { $a <=> $b } 4095, keys %Net::DNS::Parameters::rcodebyval ) {
	my $name = rcodebyval($_);	## check RCODE conversion functions
	my $code = eval { rcodebyname($name) };
	is( $code, $_, "rcodebyname($name)" );
}
is( rcodebyname('BADVERS'), rcodebyname('BADSIG'), "rcodebyname(BADVERS)" );


foreach ( sort { $a <=> $b } 65535, keys %Net::DNS::Parameters::ednsoptionbyval ) {
	my $name = ednsoptionbyval($_);	## check EDNS option conversion functions
	my $code = eval { ednsoptionbyname($name) };
	is( $code, $_, "ednsoptionbyname($name)" );
}


foreach ( sort { $a <=> $b } 65535, keys %Net::DNS::Parameters::dsotypebyval ) {
	my $name = dsotypebyval($_);	## check DSO type conversion functions
	my $code = eval { dsotypebyname($name) };
	is( $code, $_, "dsotypebyname($name)" );
}


exception( 'classbyval',  sub { classbyval(65536) } );
exception( 'classbyname', sub { classbyname(65536) } );
exception( 'classbyname', sub { classbyname('CLASS65536') } );
exception( 'classbyname', sub { classbyname('BOGUS') } );

exception( 'typebyval',	 sub { typebyval(65536) } );
exception( 'typebyname', sub { typebyname(65536) } );
exception( 'typebyname', sub { typebyname('CLASS65536') } );
exception( 'typebyname', sub { typebyname('BOGUS') } );

exception( 'opcodebyname', sub { opcodebyname('BOGUS') } );

exception( 'rcodebyname', sub { rcodebyname('BOGUS') } );

exception( 'ednsoptionbyname', sub { ednsoptionbyname('BOGUS') } );

exception( 'dsotypebyname', sub { dsotypebyname('BOGUS') } );


exit;