From 69f5f704e15c834cdb9808940859df411e13ce2f Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Tue, 22 Jul 2008 17:35:36 +0200 Subject: [PATCH] Libucw: Added tests of the URL module. Mostly merging of relative paths. --- ucw/Makefile | 3 +- ucw/url.c | 2 +- ucw/url.t | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 ucw/url.t diff --git a/ucw/Makefile b/ucw/Makefile index 3db20b9f..a10c4657 100644 --- a/ucw/Makefile +++ b/ucw/Makefile @@ -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) diff --git a/ucw/url.c b/ucw/url.c index 39f13a5f..7145af5f 100644 --- 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 index 00000000..37e6defc --- /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 -- 2.39.2