]> mj.ucw.cz Git - libucw.git/commitdiff
Libucw: Added tests of the URL module.
authorMichal Vaner <vorner@ucw.cz>
Tue, 22 Jul 2008 15:35:36 +0000 (17:35 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 22 Jul 2008 16:32:44 +0000 (18:32 +0200)
Mostly merging of relative paths.

ucw/Makefile
ucw/url.c
ucw/url.t [new file with mode: 0644]

index 3db20b9f155a746eafbef4cd36ee2de20a10b584..a10c465751b24d1ade2dd22a598d72e9034cffda 100644 (file)
@@ -94,7 +94,7 @@ TESTS+=$(addprefix $(o)/ucw/,regex.test unicode.test hash-test.test mempool.test
     slists.test kmp-test.test bbuf.test getopt.test ff-unicode.test eltpool.test \
     fb-socket.test trie-test.test string.test sha1.test asort-test.test binheap-test.test \
     redblack-test.test basecode.test fb-file.test fb-grow.test fb-pool.test fb-atomic.test \
-    fb-limfd.test fb-temp.test fb-mem.test fb-buffer.test fb-mmap.test)
+    fb-limfd.test fb-temp.test fb-mem.test fb-buffer.test fb-mmap.test url.test)
 
 $(o)/ucw/regex.test: $(o)/ucw/regex-t
 $(o)/ucw/unicode.test: $(o)/ucw/unicode-t
@@ -117,6 +117,7 @@ $(o)/ucw/redblack-test.test: $(o)/ucw/redblack-test
 $(o)/ucw/basecode.test: $(o)/ucw/basecode
 $(addprefix $(o)/ucw/fb-,file.test grow.test pool.test socket.test atomic.test \
        limfd.test temp.test mem.test buffer.test mmap.test): %.test: %-t
+$(o)/ucw/url.test: $(o)/ucw/url-t
 
 ifdef CONFIG_UCW_THREADS
 TESTS+=$(addprefix $(o)/ucw/,asio.test)
index 39f13a5f2f31b72fa90923b155739a82f021fbc6..7145af5f764e80b9b9ed60cd223743a76093b008 100644 (file)
--- a/ucw/url.c
+++ b/ucw/url.c
@@ -605,7 +605,7 @@ int main(int argc, char **argv)
   char buf1[MAX_URL_SIZE], buf2[MAX_URL_SIZE], buf3[MAX_URL_SIZE], buf4[MAX_URL_SIZE];
   int err;
   struct url url, url0;
-  char *base = "http://mj@www.hell.org/123/sub_dir/index.html;param?query&zzz/subquery#fragment";
+  char *base = "http://mj@www.hell.org/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?";
 
   if (argc != 2 && argc != 3)
     return 1;
diff --git a/ucw/url.t b/ucw/url.t
new file mode 100644 (file)
index 0000000..37e6def
--- /dev/null
+++ b/ucw/url.t
@@ -0,0 +1,91 @@
+# Tests for url.c
+
+Name:  Absolute
+Run:   ../obj/ucw/url-t 'ftp://example.com/other'
+Out:   deesc: ftp://example.com/other
+       split: @ftp@(null)@(null)@example.com@-1@/other
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @ftp@(null)@(null)@example.com@21@/other
+       canonicalize: @ftp@(null)@(null)@example.com@21@/other
+       pack: ftp://example.com/other
+       enesc: ftp://example.com/other
+
+Name:  Simple
+Run:   ../obj/ucw/url-t 'object'
+Out:   deesc: object
+       split: @(null)@(null)@(null)@(null)@-1@object
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/object
+       canonicalize: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/object
+       pack: http://mj@www.hell.org/123/sub_dir;param/object
+       enesc: http://mj@www.hell.org/123/sub_dir;param/object
+
+Name:  Toplevel
+Run:   ../obj/ucw/url-t '/object'
+Out:   deesc: /object
+       split: @(null)@(null)@(null)@(null)@-1@/object
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @http@mj@(null)@www.hell.org@80@/object
+       canonicalize: @http@mj@(null)@www.hell.org@80@/object
+       pack: http://mj@www.hell.org/object
+       enesc: http://mj@www.hell.org/object
+
+Name:  Domain
+Run:   ../obj/ucw/url-t '//www.example.com'
+Out:   deesc: //www.example.com
+       split: @(null)@(null)@(null)@www.example.com@-1@
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @http@(null)@(null)@www.example.com@80@
+       canonicalize: @http@(null)@(null)@www.example.com@80@/
+       pack: http://www.example.com/
+       enesc: http://www.example.com/
+
+Name:  Levels
+Run:   ../obj/ucw/url-t '../a/b;paramb/c/.././x?a#frag'
+Out:   deesc: ../a/b;paramb/c/.././x?a#frag
+       split: @(null)@(null)@(null)@(null)@-1@../a/b;paramb/c/.././x?a#frag
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @http@mj@(null)@www.hell.org@80@/123/a/b;paramb/x?a#frag
+       canonicalize: @http@mj@(null)@www.hell.org@80@/123/a/b;paramb/x?a
+       pack: http://mj@www.hell.org/123/a/b;paramb/x?a
+       enesc: http://mj@www.hell.org/123/a/b;paramb/x?a
+
+Name:  Query
+Run:   ../obj/ucw/url-t '?query'
+Out:   deesc: ?query
+       split: @(null)@(null)@(null)@(null)@-1@?query
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query
+       canonicalize: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query
+       pack: http://mj@www.hell.org/123/sub_dir;param/index.html;param?query
+       enesc: http://mj@www.hell.org/123/sub_dir;param/index.html;param?query
+
+Name:  Fragments
+Run:   ../obj/ucw/url-t '#../?a' 'http://example.com/?query#@?/x'
+Out:   deesc: #../?a
+       split: @(null)@(null)@(null)@(null)@-1@#../?a
+       base: @http@(null)@(null)@example.com@80@/?query#@?/x
+       normalize: @http@(null)@(null)@example.com@80@/?query#../?a
+       canonicalize: @http@(null)@(null)@example.com@80@/?query
+       pack: http://example.com/?query
+       enesc: http://example.com/?query
+
+Name:  Deescape
+Run:   ../obj/ucw/url-t '/%20%25'
+Out:   deesc: / %
+       split: @(null)@(null)@(null)@(null)@-1@/ %
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @http@mj@(null)@www.hell.org@80@/ %
+       canonicalize: @http@mj@(null)@www.hell.org@80@/ %
+       pack: http://mj@www.hell.org/ %
+       enesc: http://mj@www.hell.org/%20%25
+
+Name:  Dots
+Run:   ../obj/ucw/url-t '..a/./x.?a/x'
+Out:   deesc: ..a/./x.?a/x
+       split: @(null)@(null)@(null)@(null)@-1@..a/./x.?a/x
+       base: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?
+       normalize: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/..a/x.?a/x
+       canonicalize: @http@mj@(null)@www.hell.org@80@/123/sub_dir;param/..a/x.?a/x
+       pack: http://mj@www.hell.org/123/sub_dir;param/..a/x.?a/x
+       enesc: http://mj@www.hell.org/123/sub_dir;param/..a/x.?a/x