summaryrefslogtreecommitdiff
path: root/t/gopher.t
blob: 427a5fceb5071f612af19d1acfaa6e188cf32e50 (plain)
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
use strict;
use warnings;

print "1..48\n";

use URI;

my $t = 1;
sub is {
    my ($exp, $got) = @_;
    if (!defined $exp) {
        print "not " if defined $got;
    }
    else {
        print "not " unless $got eq $exp;
    }
    print "ok " . ($t++) . "\n";
}

sub check_gopher_uri {
    my ($u, $exphost, $expport, $exptype, $expselector, $expsearch) = @_;
    is("gopher", $u->scheme);
    is($exphost, $u->host);
    is($expport, $u->port);
    is($exptype, $u->gopher_type);
    is($expselector, $u->selector);
    is($expsearch, $u->search);
}

my $u;
$u = URI->new("gopher://host");
check_gopher_uri($u, "host", 70, 1);
$u = URI->new("gopher://host:70");
check_gopher_uri($u, "host", 70, 1);
$u = URI->new("gopher://host:70/");
check_gopher_uri($u, "host", 70, 1);
$u = URI->new("gopher://host:70/1");
check_gopher_uri($u, "host", 70, 1);
$u = URI->new("gopher://host:70/1");
check_gopher_uri($u, "host", 70, 1);
$u = URI->new("gopher://host:123/7foo");
check_gopher_uri($u, "host", 123, 7, "foo");
$u = URI->new("gopher://host/7foo\tbar%20baz");
check_gopher_uri($u, "host", 70, 7, "foo", "bar baz");
$u = URI->new("gopher://host/7foo%09bar%20baz");
check_gopher_uri($u, "host", 70, 7, "foo", "bar baz");