This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-uri.scm
85 lines (77 loc) · 2.88 KB
/
test-uri.scm
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;;; -*- Mode: Scheme; scheme48-package: uri-tests -*-
;;;; Schemantic Web
;;;; URI Tests
;;; This code is written by Taylor R. Campbell and placed in the Public
;;; Domain. All warranties are disclaimed.
(define-test-suite uri-tests
"URI: Uniform Resource Identifiers")
(define-syntax test-uri=
(syntax-rules ()
((TEST-URI= expected-expression actual-expression)
(TEST-COMPARE URI=? expected-expression actual-expression))))
(define-test-case uri-tests parsing.0 ()
(test-uri= (make-uri 'SCHEME
(make-uri-authority "user" "host" 123)
'("" "path" "to" "file")
"query"
"fragment")
(string->uri "scheme://user@host:123/path/to/file?query#fragment")))
;;;; Merging
(define-test-suite (uri-tests.merging uri-tests)
"Relative URI merging rules")
(let-syntax
((define-uri-merging-tests
(syntax-rules ()
((DEFINE-URI-MERGE-TESTS name base-uri
(relative-reference expected-result)
...)
(DEFINE-TEST-CASE URI-TESTS.MERGING name ()
(TEST-EQUAL expected-result
(URI->STRING (MERGE-URIS relative-reference base-uri #T)))
...)))))
(define-uri-merging-tests normal-examples "http://a/b/c/d;p?q"
("g:h" "g:h")
("g" "http://a/b/c/g")
("./g" "http://a/b/c/g")
("g/" "http://a/b/c/g/")
("/g" "http://a/g")
("//g" "http://g")
("?y" "http://a/b/c/d;p?y")
("g?y" "http://a/b/c/g?y")
("#s" "http://a/b/c/d;p?q#s")
("g#s" "http://a/b/c/g#s")
("g?y#s" "http://a/b/c/g?y#s")
(";x" "http://a/b/c/;x")
("g;x" "http://a/b/c/g;x")
("g;x?y#s" "http://a/b/c/g;x?y#s")
("" "http://a/b/c/d;p?q")
("." "http://a/b/c/")
("./" "http://a/b/c/")
(".." "http://a/b/")
("../" "http://a/b/")
("../g" "http://a/b/g")
("../.." "http://a/")
("../../" "http://a/")
("../../g" "http://a/g")
)
(define-uri-merging-tests abnormal-examples "http://a/b/c/d;p?q"
("../../../g" "http://a/g")
("../../../../g" "http://a/g")
("/./g" "http://a/g")
("/../g" "http://a/g")
("g." "http://a/b/c/g.")
(".g" "http://a/b/c/.g")
("g.." "http://a/b/c/g..")
("..g" "http://a/b/c/..g")
("./../g" "http://a/b/g")
("./g/." "http://a/b/c/g/")
("g/./h" "http://a/b/c/g/h")
("g/../h" "http://a/b/c/h")
("g;x=1/./y" "http://a/b/c/g;x=1/y")
("g;x=1/../y" "http://a/b/c/y")
("g?y/./x" "http://a/b/c/g?y/./x")
("g?y/../x" "http://a/b/c/g?y/../x")
("g#s/./x" "http://a/b/c/g#s/./x")
("g#s/../x" "http://a/b/c/g#s/../x")
("http:g" "http:g")
))