summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-03-10 11:36:02 +0000
committerVincent Sanders <vince@kyllikki.org>2017-03-10 11:36:02 +0000
commit363c32c07aad6cdaf9b430781137bfca726f7761 (patch)
treed31bf48c8a832de9615f809543b127ee52668b0f /test
parentfc1be0144cec6e339a5e715dab142a0dfb98e10e (diff)
downloadnetsurf-363c32c07aad6cdaf9b430781137bfca726f7761.tar.gz
netsurf-363c32c07aad6cdaf9b430781137bfca726f7761.tar.bz2
extend nsurl component API test case
Diffstat (limited to 'test')
-rw-r--r--test/nsurl.c71
1 files changed, 46 insertions, 25 deletions
diff --git a/test/nsurl.c b/test/nsurl.c
index 80534feee..a8c4bc027 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -605,6 +605,8 @@ START_TEST(nsurl_compare_test)
END_TEST
+/* component test case */
+
/**
* url component tests
*
@@ -613,18 +615,27 @@ END_TEST
* result is checked against test1 and res as approprite.
*/
static const struct test_compare component_tests[] = {
- { "http://a/b/c/d;p?q",
- "http",
- NSURL_SCHEME,
- true },
-
- { "file:///",
- NULL,
- NSURL_HOST,
- false },
+ { "http://u:p@a:66/b/c/d;p?q#f", "http", NSURL_SCHEME, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "u", NSURL_USERNAME, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "p", NSURL_PASSWORD, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "a", NSURL_HOST, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "66", NSURL_PORT, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "/b/c/d;p", NSURL_PATH, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "?q", NSURL_QUERY, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "f", NSURL_FRAGMENT, true },
+
+ { "file:", "file", NSURL_SCHEME, true },
+ { "file:", NULL, NSURL_USERNAME, false },
+ { "file:", NULL, NSURL_PASSWORD, false },
+ { "file:", NULL, NSURL_HOST, false },
+ { "file:", NULL, NSURL_PORT, false },
+ { "file:", NULL, NSURL_PATH, false },
+ { "file:", NULL, NSURL_QUERY, false },
+ { "file:", NULL, NSURL_FRAGMENT, false },
};
+
/**
* get component
*/
@@ -651,6 +662,7 @@ START_TEST(nsurl_get_component_test)
}
END_TEST
+
/**
* has component
*/
@@ -672,6 +684,30 @@ START_TEST(nsurl_has_component_test)
}
END_TEST
+
+/**
+ * test case for componnet get and has API
+ */
+static TCase *nsurl_component_case_create(void)
+{
+ TCase *tc;
+ tc = tcase_create("Component");
+
+ tcase_add_unchecked_fixture(tc,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc,
+ nsurl_get_component_test,
+ 0, NELEMS(component_tests));
+ tcase_add_loop_test(tc,
+ nsurl_has_component_test,
+ 0, NELEMS(component_tests));
+
+ return tc;
+}
+
+
static const struct test_pairs fragment_tests[] = {
{ "http://www.f.org/a/b/c#def", "http://www.f.org/a/b/c" },
};
@@ -1261,7 +1297,6 @@ static TCase *nsurl_utf8_case_create(void)
}
-
/* test suite */
/**
@@ -1279,7 +1314,6 @@ static Suite *nsurl_suite(void)
TCase *tc_join;
TCase *tc_compare;
TCase *tc_fragment;
- TCase *tc_component;
s = suite_create("nsurl");
@@ -1457,20 +1491,7 @@ static Suite *nsurl_suite(void)
/* component */
- tc_component = tcase_create("Component");
-
- tcase_add_unchecked_fixture(tc_component,
- corestring_create,
- corestring_teardown);
-
- tcase_add_loop_test(tc_component,
- nsurl_get_component_test,
- 0, NELEMS(component_tests));
- tcase_add_loop_test(tc_component,
- nsurl_has_component_test,
- 0, NELEMS(component_tests));
-
- suite_add_tcase(s, tc_component);
+ suite_add_tcase(s, nsurl_component_case_create());
/* parent */