summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-08-09 12:15:36 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2016-08-09 12:15:36 (GMT)
commit94de23dce9b4cb490bcaf08433c6ba75abf4a29c (patch)
tree1db65364bf0aad9ca50f0595fd6b8fa706207ae5
parent9176d3233fc395f579a33484ed714649e1fd8f46 (diff)
downloadnetsurf-94de23dce9b4cb490bcaf08433c6ba75abf4a29c.tar.gz
netsurf-94de23dce9b4cb490bcaf08433c6ba75abf4a29c.tar.bz2
add more tests for partial iterator in url database
-rw-r--r--test/urldbtest.c86
1 files changed, 83 insertions, 3 deletions
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 67f833e..bc707ed 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -483,12 +483,20 @@ END_TEST
/**
* iterate through partial matches
*/
-START_TEST(urldb_iterate_partial_test)
+START_TEST(urldb_iterate_partial_www_test)
{
cb_count = 0;
urldb_iterate_partial("www", urldb_iterate_entries_cb);
ck_assert_int_eq(cb_count, 7);
+}
+END_TEST
+
+/**
+ * iterate through partial matches
+ */
+START_TEST(urldb_iterate_partial_nomatch_test)
+{
cb_count = 0;
urldb_iterate_partial("/", urldb_iterate_entries_cb);
ck_assert_int_eq(cb_count, 0);
@@ -496,6 +504,62 @@ START_TEST(urldb_iterate_partial_test)
}
END_TEST
+/**
+ * iterate through partial matches
+ */
+START_TEST(urldb_iterate_partial_add_test)
+{
+ nsurl *url;
+
+ cb_count = 0;
+ urldb_iterate_partial("wikipedia", urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 0);
+
+ url = make_url(wikipedia_url);
+ urldb_add_url(url);
+ nsurl_unref(url);
+
+ cb_count = 0;
+ urldb_iterate_partial("wikipedia", urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 1);
+}
+END_TEST
+
+/**
+ * iterate through partial matches
+ */
+START_TEST(urldb_iterate_partial_path_test)
+{
+
+ cb_count = 0;
+ urldb_iterate_partial("en.wikipedia.org/wiki", urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 2);
+}
+END_TEST
+
+/**
+ * iterate through partial matches
+ */
+START_TEST(urldb_iterate_partial_numeric_test)
+{
+ nsurl *url;
+
+ cb_count = 0;
+ urldb_iterate_partial("192.168.7.1/", urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 0);
+
+ url = make_url("http://192.168.7.1/index.html");
+ urldb_add_url(url);
+ nsurl_unref(url);
+
+ cb_count = 0;
+ urldb_iterate_partial("192.168.7.1/", urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 1);
+
+
+}
+END_TEST
+
START_TEST(urldb_auth_details_test)
{
nsurl *url;
@@ -509,7 +573,6 @@ START_TEST(urldb_auth_details_test)
ck_assert_str_eq(res, auth);
nsurl_unref(url);
-
}
END_TEST
@@ -623,7 +686,11 @@ static TCase *urldb_case_create(void)
urldb_teardown);
tcase_add_test(tc, urldb_iterate_entries_test);
- tcase_add_test(tc, urldb_iterate_partial_test);
+ tcase_add_test(tc, urldb_iterate_partial_www_test);
+ tcase_add_test(tc, urldb_iterate_partial_nomatch_test);
+ tcase_add_test(tc, urldb_iterate_partial_add_test);
+ tcase_add_test(tc, urldb_iterate_partial_path_test);
+ tcase_add_test(tc, urldb_iterate_partial_numeric_test);
tcase_add_test(tc, urldb_auth_details_test);
tcase_add_test(tc, urldb_thumbnail_test);
tcase_add_test(tc, urldb_cert_permissions_test);
@@ -716,6 +783,16 @@ START_TEST(urldb_api_add_host_assert_test)
END_TEST
/**
+ * test url database finalisation without initialisation.
+ */
+START_TEST(urldb_api_destroy_no_init_test)
+{
+ urldb_destroy();
+}
+END_TEST
+
+
+/**
* test case for urldb API including error returns and asserts
*/
static TCase *urldb_api_case_create(void)
@@ -727,6 +804,9 @@ static TCase *urldb_api_case_create(void)
urldb_api_add_host_assert_test,
6);
+ tcase_add_test(tc, urldb_api_destroy_no_init_test);
+
+
return tc;
}