aboutsummaryrefslogtreecommitdiffstats
path: root/camel/tests/misc
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-03-26 06:55:27 +0800
committerDan Winship <danw@src.gnome.org>2001-03-26 06:55:27 +0800
commit182c699c3909ff7e052f05259bac368b72c464f3 (patch)
treeeafe49670084a3dd4b78536098969579eae38129 /camel/tests/misc
parentbedb486193f38c72e20754a4d7bd28142689f1ae (diff)
downloadgsoc2013-evolution-182c699c3909ff7e052f05259bac368b72c464f3.tar
gsoc2013-evolution-182c699c3909ff7e052f05259bac368b72c464f3.tar.gz
gsoc2013-evolution-182c699c3909ff7e052f05259bac368b72c464f3.tar.bz2
gsoc2013-evolution-182c699c3909ff7e052f05259bac368b72c464f3.tar.lz
gsoc2013-evolution-182c699c3909ff7e052f05259bac368b72c464f3.tar.xz
gsoc2013-evolution-182c699c3909ff7e052f05259bac368b72c464f3.tar.zst
gsoc2013-evolution-182c699c3909ff7e052f05259bac368b72c464f3.zip
New URL parser with full RFC1808 relative URL support. Yum.
* camel-url.c (camel_url_new_with_base): New URL parser with full RFC1808 relative URL support. Yum. (camel_url_new): Wrapper around camel_url_new_with_base now. Removed the CamelException since no one ever used it... * tests/Makefile.am: add misc subdir * tests/misc/url.c: relative URL test cases from RFC 1808 * camel-session.c (camel_session_get_service): Update camel_url_new call. svn path=/trunk/; revision=8933
Diffstat (limited to 'camel/tests/misc')
-rw-r--r--camel/tests/misc/.cvsignore11
-rw-r--r--camel/tests/misc/Makefile.am21
-rw-r--r--camel/tests/misc/README3
-rw-r--r--camel/tests/misc/url.c103
4 files changed, 138 insertions, 0 deletions
diff --git a/camel/tests/misc/.cvsignore b/camel/tests/misc/.cvsignore
new file mode 100644
index 0000000000..3fa8afaa38
--- /dev/null
+++ b/camel/tests/misc/.cvsignore
@@ -0,0 +1,11 @@
+.deps
+Makefile
+Makefile.in
+.libs
+.deps
+*.lo
+*.la
+*.bb
+*.bbg
+*.da
+*.gcov
diff --git a/camel/tests/misc/Makefile.am b/camel/tests/misc/Makefile.am
new file mode 100644
index 0000000000..1cbcab8c26
--- /dev/null
+++ b/camel/tests/misc/Makefile.am
@@ -0,0 +1,21 @@
+
+INCLUDES = -I$(top_srcdir)/intl -I$(top_srcdir) -I$(top_srcdir)/camel \
+ -I$(includedir) \
+ -I$(top_srcdir)/camel/tests/lib \
+ -DG_LOG_DOMAIN=\"evolution-tests\"
+
+LDADD = \
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libibex/libibex.la \
+ $(GNOME_LIBDIR) \
+ $(top_builddir)/camel/tests/lib/libcameltest.a \
+ $(GNOMEUI_LIBS) $(INTLLIBS) $(EXTRA_GNOME_LIBS)
+
+check_PROGRAMS = \
+ url
+
+TESTS = url
+
+
+
diff --git a/camel/tests/misc/README b/camel/tests/misc/README
new file mode 100644
index 0000000000..d972108860
--- /dev/null
+++ b/camel/tests/misc/README
@@ -0,0 +1,3 @@
+
+url URL parsing
+
diff --git a/camel/tests/misc/url.c b/camel/tests/misc/url.c
new file mode 100644
index 0000000000..128eb29fc5
--- /dev/null
+++ b/camel/tests/misc/url.c
@@ -0,0 +1,103 @@
+#include <config.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <camel/camel-url.h>
+
+#include "camel-test.h"
+
+char *base = "http://a/b/c/d;p?q#f";
+
+struct {
+ char *url_string, *result;
+} tests[] = {
+ { "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" },
+ { "g?y/./x", "http://a/b/c/g?y/./x" },
+ { "#s", "http://a/b/c/d;p?q#s" },
+ { "g#s", "http://a/b/c/g#s" },
+ { "g#s/./x", "http://a/b/c/g#s/./x" },
+ { "g?y#s", "http://a/b/c/g?y#s" },
+ { ";x", "http://a/b/c/d;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/" },
+ { "./", "http://a/b/c/" },
+ { "..", "http://a/b/" },
+ { "../", "http://a/b/" },
+ { "../g", "http://a/b/g" },
+ { "../..", "http://a/" },
+ { "../../", "http://a/" },
+ { "../../g", "http://a/g" },
+ { "", "http://a/b/c/d;p?q#f" },
+ { "../../../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" },
+ { "http:g", "http:g" },
+ { "http:", "http:" }
+};
+int num_tests = sizeof (tests) / sizeof (tests[0]);
+
+int
+main (int argc, char **argv)
+{
+ CamelURL *base_url, *url;
+ char *url_string;
+ int i;
+
+ camel_test_init (argc, argv);
+
+ camel_test_start ("RFC1808 relative URL parsing");
+
+ camel_test_push ("base URL parsing");
+ base_url = camel_url_new (base);
+ if (!base_url)
+ camel_test_fail ("Could not parse %s\n", base);
+ camel_test_pull ();
+
+ camel_test_push ("base URL unparsing");
+ url_string = camel_url_to_string (base_url, TRUE);
+ if (strcmp (url_string, base) != 0) {
+ camel_test_fail ("URL <%s> unparses to <%s>\n",
+ base, url_string);
+ }
+ camel_test_pull ();
+ g_free (url_string);
+
+ for (i = 0; i < num_tests; i++) {
+ camel_test_push ("<%s> + <%s> = <%s>?", base, tests[i].url_string, tests[i].result);
+ url = camel_url_new_with_base (base_url, tests[i].url_string);
+ if (!url) {
+ camel_test_fail ("could not parse");
+ camel_test_pull ();
+ continue;
+ }
+
+ url_string = camel_url_to_string (url, TRUE);
+ if (strcmp (url_string, tests[i].result) != 0)
+ camel_test_fail ("got <%s>!", url_string);
+ g_free (url_string);
+ camel_test_pull ();
+ }
+
+ camel_test_end ();
+
+ return 0;
+}