From d55d7f3e1e50ad4b5199d1ea84922fedff859e78 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 13 Mar 2017 21:53:42 +0000 Subject: add urldb tests for urls which cannot be found --- test/urldbtest.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/urldbtest.c b/test/urldbtest.c index 01cee7948..3c43833e5 100644 --- a/test/urldbtest.c +++ b/test/urldbtest.c @@ -1010,6 +1010,49 @@ START_TEST(urldb_api_add_url_assert_test) END_TEST +/** + * Test urldb find failing for differing bad url. + */ +START_TEST(urldb_api_url_find_test) +{ + nsurl *url; + nserror res; + + urldb_create(); + + /* search for a url with mailto scheme */ + res = nsurl_create("mailto:", &url); + ck_assert_int_eq(res, NSERROR_OK); + + res = urldb_set_url_persistence(url, true); + ck_assert_int_eq(res, NSERROR_NOT_FOUND); + + nsurl_unref(url); + + /* search for a url with odd scheme and no host */ + res = nsurl_create("fish:///", &url); + ck_assert_int_eq(res, NSERROR_OK); + ck_assert(nsurl_has_component(url, NSURL_HOST) == false); + + res = urldb_set_url_persistence(url, true); + ck_assert_int_eq(res, NSERROR_NOT_FOUND); + + nsurl_unref(url); + + /* search for a url with not found url */ + res = nsurl_create("http://no.example.com/", &url); + ck_assert_int_eq(res, NSERROR_OK); + ck_assert(nsurl_has_component(url, NSURL_HOST) == true); + + res = urldb_set_url_persistence(url, true); + ck_assert_int_eq(res, NSERROR_NOT_FOUND); + + nsurl_unref(url); + + +} +END_TEST + /** * test url database finalisation without initialisation. */ @@ -1032,6 +1075,8 @@ static TCase *urldb_api_case_create(void) urldb_api_add_url_assert_test, 6); + tcase_add_test(tc, urldb_api_url_find_test); + tcase_add_test(tc, urldb_api_destroy_no_init_test); -- cgit v1.2.3