File: 02_main.t

package info (click to toggle)
libvalidate-net-perl 0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: perl: 1,163; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

# Formal testing for Validate::Net

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More tests => 33;
use Validate::Net;





# Create a bunch of basic "good" and "bad" ips
my @good = qw{
	1.2.3.4
	0.0.0.0
	};
my @bad = qw{1.2.3};

# Check the good and bad ips
foreach ( @good ) {
	ok( Validate::Net->ip( $_ ), "'$_' passes ->ip correctly" );
	ok( Validate::Net->host( $_ ), "'$_' passes ->host correctly" );
}
foreach ( @bad ) {
	ok( ! Validate::Net->ip( $_ ), "'$_' fails ->ip correctly" );
}




# Create a bunch of basic "good" and "bad" domain and host names
@good = qw{
	foo
	bar
	foo-bar
	32146
	black.342.hole
	dot.at.end.
	};
@bad = qw{
	1st
	-blah
	blah-
	blah--blah
	reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylong
	.dot.at.start
	this.is.1st.also.bad
	blah.blah-.blah
	};

# Check the good and bad domains
foreach ( @good ) {
	ok( Validate::Net->domain( $_ ), "'$_' passes ->domain correctly" );
	ok( Validate::Net->host( $_ ), "'$_' passes ->host correctly" );
}
foreach ( @bad ) {
	ok( ! Validate::Net->domain( $_ ), "'$_' fails ->domain correctly" );
	ok( ! Validate::Net->host( $_ ), "'$_' fails ->host correctly" );
}