1use strict; 2use warnings; 3 4print "1..17\n"; 5 6use URI::Split qw(uri_join uri_split); 7 8sub j { join("-", map { defined($_) ? $_ : "<undef>" } @_) } 9 10print "not " unless j(uri_split("p")) eq "<undef>-<undef>-p-<undef>-<undef>"; 11print "ok 1\n"; 12 13print "not " unless j(uri_split("p?q")) eq "<undef>-<undef>-p-q-<undef>"; 14print "ok 2\n"; 15 16print "not " unless j(uri_split("p#f")) eq "<undef>-<undef>-p-<undef>-f"; 17print "ok 3\n"; 18 19print "not " unless j(uri_split("p?q/#f/?")) eq "<undef>-<undef>-p-q/-f/?"; 20print "ok 4\n"; 21 22print "not " unless j(uri_split("s://a/p?q#f")) eq "s-a-/p-q-f"; 23print "ok 5\n"; 24 25print "not " unless uri_join("s", "a", "/p", "q", "f") eq "s://a/p?q#f"; 26print "ok 6\n"; 27 28print "not " unless uri_join("s", "a", "p", "q", "f") eq "s://a/p?q#f"; 29print "ok 7\n"; 30 31print "not " unless uri_join(undef, undef, "", undef, undef) eq ""; 32print "ok 8\n"; 33 34print "not " unless uri_join(undef, undef, "p", undef, undef) eq "p"; 35print "ok 9\n"; 36 37print "not " unless uri_join("s", undef, "p") eq "s:p"; 38print "ok 10\n"; 39 40print "not " unless uri_join("s") eq "s:"; 41print "ok 11\n"; 42 43print "not " unless uri_join() eq ""; 44print "ok 12\n"; 45 46print "not " unless uri_join("s", "a") eq "s://a"; 47print "ok 13\n"; 48 49print "not " unless uri_join("s", "a/b") eq "s://a%2Fb"; 50print "ok 14\n"; 51 52print "not " unless uri_join("s", ":/?#", ":/?#", ":/?#", ":/?#") eq "s://:%2F%3F%23/:/%3F%23?:/?%23#:/?#"; 53print "ok 15\n"; 54 55print "not " unless uri_join(undef, undef, "a:b") eq "a%3Ab"; 56print "ok 16\n"; 57 58print "not " unless uri_join("s", undef, "//foo//bar") eq "s:////foo//bar"; 59print "ok 17\n"; 60