Skip to content

Commit aaa3ef7

Browse files
committed
adds more valid and invalid URI testcases
1 parent 728066f commit aaa3ef7

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

tests/draft4/optional/format.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,76 @@
2929
"data": "http://foo.bar/?baz=qux#quux",
3030
"valid": true
3131
},
32+
{
33+
"description": "a valid URI",
34+
"data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
35+
"valid": true
36+
},
37+
{
38+
"description": "a valid URI",
39+
"data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
40+
"valid": true
41+
},
42+
{
43+
"description": "a valid URI",
44+
"data": "http://xn--nw2a.xn--j6w193g/",
45+
"valid": true
46+
},
47+
{
48+
"description": "a valid URI",
49+
"data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
50+
"valid": true
51+
},
52+
{
53+
"description": "a valid URI",
54+
"data": "http://223.255.255.254",
55+
"valid": true
56+
},
57+
{
58+
"description": "a valid URI",
59+
"data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
60+
"valid": true
61+
},
62+
{
63+
"description": "a valid URI",
64+
"data": "http://www.ietf.org/rfc/rfc2396.txt",
65+
"valid": true
66+
},
67+
{
68+
"description": "a valid URI",
69+
"data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
70+
"valid": true
71+
},
72+
{
73+
"description": "a valid URI",
74+
"data": "mailto:John.Doe@example.com",
75+
"valid": true
76+
},
77+
{
78+
"description": "a valid URI",
79+
"data": "news:comp.infosystems.www.servers.unix",
80+
"valid": true
81+
},
82+
{
83+
"description": "a valid URI",
84+
"data": "tel:+1-816-555-1212",
85+
"valid": true
86+
},
87+
{
88+
"description": "a valid URI",
89+
"data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
90+
"valid": true
91+
},
3292
{
3393
"description": "an invalid protocol-relative URI Reference",
3494
"data": "//foo.bar/?baz=qux#quux",
3595
"valid": false
3696
},
97+
{
98+
"description": "an invalid relative URI Reference",
99+
"data": "/abc",
100+
"valid": false
101+
},
37102
{
38103
"description": "an invalid URI",
39104
"data": "\\\\WINDOWS\\fileshare",
@@ -43,6 +108,16 @@
43108
"description": "an invalid URI though valid URI reference",
44109
"data": "abc",
45110
"valid": false
111+
},
112+
{
113+
"description": "an invalid URI",
114+
"data": "http:// shouldfail.com",
115+
"valid": false
116+
},
117+
{
118+
"description": "an invalid URI",
119+
"data": ":// should fail",
120+
"valid": false
46121
}
47122
]
48123
},

tests/draft6/optional/format.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,66 @@
2929
"data": "http://foo.bar/?baz=qux#quux",
3030
"valid": true
3131
},
32+
{
33+
"description": "a valid URI",
34+
"data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
35+
"valid": true
36+
},
37+
{
38+
"description": "a valid URI",
39+
"data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
40+
"valid": true
41+
},
42+
{
43+
"description": "a valid URI",
44+
"data": "http://xn--nw2a.xn--j6w193g/",
45+
"valid": true
46+
},
47+
{
48+
"description": "a valid URI",
49+
"data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
50+
"valid": true
51+
},
52+
{
53+
"description": "a valid URI",
54+
"data": "http://223.255.255.254",
55+
"valid": true
56+
},
57+
{
58+
"description": "a valid URI",
59+
"data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
60+
"valid": true
61+
},
62+
{
63+
"description": "a valid URI",
64+
"data": "http://www.ietf.org/rfc/rfc2396.txt",
65+
"valid": true
66+
},
67+
{
68+
"description": "a valid URI",
69+
"data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
70+
"valid": true
71+
},
72+
{
73+
"description": "a valid URI",
74+
"data": "mailto:John.Doe@example.com",
75+
"valid": true
76+
},
77+
{
78+
"description": "a valid URI",
79+
"data": "news:comp.infosystems.www.servers.unix",
80+
"valid": true
81+
},
82+
{
83+
"description": "a valid URI",
84+
"data": "tel:+1-816-555-1212",
85+
"valid": true
86+
},
87+
{
88+
"description": "a valid URI",
89+
"data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
90+
"valid": true
91+
},
3292
{
3393
"description": "an invalid protocol-relative URI Reference",
3494
"data": "//foo.bar/?baz=qux#quux",
@@ -48,6 +108,16 @@
48108
"description": "an invalid URI though valid URI reference",
49109
"data": "abc",
50110
"valid": false
111+
},
112+
{
113+
"description": "an invalid URI",
114+
"data": "http:// shouldfail.com",
115+
"valid": false
116+
},
117+
{
118+
"description": "an invalid URI",
119+
"data": ":// should fail",
120+
"valid": false
51121
}
52122
]
53123
},

0 commit comments

Comments
 (0)