Changeset 12841 in project for release/4/uri-generic/trunk/tests


Ignore:
Timestamp:
12/17/08 22:08:26 (12 years ago)
Author:
sjamaan
Message:

Implement percent decoding/encoding of slashes in path segments, add more tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/uri-generic/trunk/tests/run.scm

    r12827 r12841  
    196196            encode/decode-cases))
    197197
    198 (define update-cases
    199   '(("/foo" (path: (/ "bar")) "/bar")
    200     ("/foo" (path: ("bar")) "bar")
    201     ("/foo" (host: "localhost") "//localhost/foo")
    202     ("http://foo" (query: "a=b&c&d?=%2fe") "http://foo?a=b&c&d?=%2fe")
    203     ("http://foo" (host: #f) "http:")
    204     ("http://foo" (authority: #f) "http:")))
    205 
    206 (test-group "update-uri test"
    207   (for-each (lambda (p)
    208               (let ((expected (uri-reference (third p)))
    209                     (updated (apply update-uri (uri-reference (first p)) (second p))))
    210                   (test (sprintf "~S * ~S -> ~S" (first p) (second p) (third p)) expected updated)))
    211             update-cases))
    212 
    213198(define normalize-case-cases
    214199  '(("http://exa%2fmple/FOO%2fbar" "http://exa%2Fmple/FOO%2Fbar")
     
    226211                  (test (sprintf "~S -> ~S" (first p) (second p)) expected (uri->string case-normalized (lambda (user pass) (conc user ":" pass))))))
    227212            normalize-case-cases))
     213
     214(define internal-representation-cases
     215  `((,uri-scheme
     216     ;; pct-encoding not allowed in scheme
     217     ("http.:" http.)
     218     ("http+:" http+)
     219     ("http-:" http-)
     220     ("HTTP:" HTTP)
     221     ("" #f)
     222     ("/foo" #f)
     223     (":" ||))
     224    (,uri-path
     225     ("foo%20bar" ("foo%20bar"))
     226     ("foo%2Fbar" ("foo/bar"))
     227     ("foo%2ebar" ("foo.bar") "foo.bar")
     228     ("foo/bar%2Fqux" ("foo" "bar/qux"))
     229     ("foo/" ("foo" ""))
     230     ("foo/bar:qux" ("foo" "bar:qux"))
     231     ("/foo%2Fbar" (/ "foo/bar"))
     232     ("/foo/" (/ "foo" ""))
     233     ("/foo:bar" (/ "foo:bar")))))
     234
     235(test-group "internal representations"
     236  (for-each (lambda (p)
     237              (for-each (lambda (u)
     238                          (let ((in (first u))
     239                                (internal (second u))
     240                                (out (if (null? (cddr u))
     241                                         (first u)
     242                                         (third u)))
     243                                (uri (uri-reference (first u))))
     244                            (test (sprintf "~S decoded as ~S" in internal)
     245                                  internal ((car p) uri))
     246                            (test (sprintf "~S encoded to ~S" internal out)
     247                                  out (uri->string uri))))
     248                        (cdr p)))
     249            internal-representation-cases))
     250
     251(test-group "miscellaneous"
     252  ;; Special case, see section 4.2
     253  (test "./foo:bar" (uri->string (update-uri (uri-reference "") path: '("foo:bar")))))
Note: See TracChangeset for help on using the changeset viewer.