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
|
#!/usr/bin/perl
# -------------------------------------------------------------------------------
# test harness for Data::Validate::URI::is_https_uri
#
# Author: Richard Sonnen (http://www.richardsonnen.com/)
# -------------------------------------------------------------------------------
use lib './t';
use ExtUtils::TBone;
use lib './blib';
use Data::Validate::URI qw(is_https_uri);
my $t = ExtUtils::TBone->typical();
$t->begin(17);
$t->msg("testing is_https_uri...");
# invalid
$t->ok(!defined(is_https_uri('')), "bad: ''");
$t->ok(!defined(is_https_uri('http://www.richardsonnen.com/')), 'http://www.richardsonnen.com/');
$t->ok(!defined(is_https_uri('ftp://ftp.richardsonnen.com')), "bad: 'ftp://ftp.richardsonnen.com'");
$t->ok(!defined(is_https_uri('https:www.richardsonnen.com')), "bad: 'https:www.richardsonnen.com'");
$t->ok(!defined(is_https_uri('https://under_scored.richardsonnen.com/')), "bad: 'https://under_scored.richardsonnen.com/'");
# valid
$t->ok(defined(is_https_uri('https://www.richardsonnen.com/')), 'https://www.richardsonnen.com/');
$t->ok(defined(is_https_uri('https://www.richardsonnen.com')), 'https://www.richardsonnen.com');
$t->ok(defined(is_https_uri('https://www.richardsonnen.com/foo/bar/test.html')), 'https://www.richardsonnen.com/foo/bar/test.html');
$t->ok(defined(is_https_uri('https://www.richardsonnen.com/?foo=bar')), 'https://www.richardsonnen.com/?foo=bar');
$t->ok(defined(is_https_uri('https://www.richardsonnen.com:8080/test.html')), 'https://www.richardsonnen.com:8080/test.html');
$t->ok(defined(is_https_uri('https://example.w3.org/path%20with%20spaces.html')), 'http://example.w3.org/path%20with%20spaces.html');
$t->ok(defined(is_https_uri('https://192.168.0.1/')), 'http://192.168.0.1/');
$t->ok(defined(is_https_uri('https://under_scored.richardsonnen.com/', {domain_allow_underscore=>1})), 'https://under_scored.richardsonnen.com/');
# as an object
my $v = Data::Validate::URI->new();
$t->ok(defined($v->is_https_uri('https://www.richardsonnen.com/')), 'https://www.richardsonnen.com/ (object)');
$t->ok(!defined($v->is_https_uri('foo')), 'bad: foo (object)');
$t->ok(!defined($v->is_https_uri('https://under_scored.richardsonnen.com/')), "bad: 'https://under_scored.richardsonnen.com/' (object)");
$v = Data::Validate::URI->new(domain_allow_underscore=>1);
$t->ok(defined($v->is_https_uri('https://under_scored.richardsonnen.com/')), 'https://under_scored.richardsonnen.com/ (object)');
# we're done
$t->end();
|