Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/9a004753d2c53062ed4a9dca94d6674e11df7e0f
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/9a004753d2c53062ed4a9dca94d6674e11df7e0f
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/9a004753d2c53062ed4a9dca94d6674e11df7e0f

The branch, master has been updated
       via  9a004753d2c53062ed4a9dca94d6674e11df7e0f (commit)
       via  44ad580a7586b39f168603bab40fb73f511c4a8a (commit)
       via  5078bffad799d41f8098e59b50d29dc018549663 (commit)
      from  363c32c07aad6cdaf9b430781137bfca726f7761 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=9a004753d2c53062ed4a9dca94d6674e11df7e0f
commit 9a004753d2c53062ed4a9dca94d6674e11df7e0f
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    extend the session addition test with all the urls from the add/set/get test

diff --git a/test/urldbtest.c b/test/urldbtest.c
index 2796637..19d0f9e 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -421,6 +421,7 @@ static const struct test_triplets add_set_get_tests[] = {
        { "http://www2.2checkout.com/"; , "foobar", NULL }, /* Mantis bug #913 */
        { 
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";,
          "a more complex title" , NULL }, /* Numeric subdomains */
+       { 
"http://tree.example.com/this_url_has_a_ridiculously_long_path/made_up_from_a_number_of_inoranately_long_elments_some_of_well_over_forty/characters_in_length/foo.png";,
 NULL, NULL },
        { "file:///home/", NULL, NULL}, /* no title */
        { "http://[email protected]/";, NULL, NULL }, /* Mantis bug #996 */
        { "http://a.xn--11b4c3d/a";, "a title", NULL },
@@ -551,6 +552,7 @@ START_TEST(urldb_session_add_test)
        nserror res;
        char *outnam;
        nsurl *url;
+       int t;
 
        /* writing output requires options initialising */
        res = nsoption_init(NULL, NULL, NULL);
@@ -561,28 +563,37 @@ START_TEST(urldb_session_add_test)
 
        urldb_load_cookies(test_cookies_path);
 
-       /* add something to db */
-       url = make_url("http://tree.example.com/";);
-       urldb_add_url(url);
+       /* add to db */
+       for (t = 0; t < NELEMS(add_set_get_tests); t++) {
+               const struct test_triplets *tst = &add_set_get_tests[t];
 
-       res = urldb_update_url_visit_data(url);
-       ck_assert_int_eq(res, NSERROR_OK);
+               /* not testing url creation, this should always succeed */
+               res = nsurl_create(tst->url, &url);
+               ck_assert_int_eq(res, NSERROR_OK);
 
-       nsurl_unref(url);
+               /* add the url to the database */
+               ck_assert(urldb_add_url(url) == true);
+
+               /* update the visit time so it gets serialised */
+               res = urldb_update_url_visit_data(url);
+               ck_assert_int_eq(res, NSERROR_OK);
+
+               nsurl_unref(url);
+       }
 
        /* write database out */
        outnam = testnam(NULL);
        res = urldb_save(outnam);
        ck_assert_int_eq(res, NSERROR_OK);
 
-       /* remove test output */
+       /* remove urldb test output */
        unlink(outnam);
 
        /* write cookies out */
        outnam = testnam(NULL);
        urldb_save_cookies(outnam);
 
-       /* remove test output */
+       /* remove cookies test output */
        unlink(outnam);
 
        /* finalise options */
@@ -967,10 +978,10 @@ static Suite *urldb_suite_create(void)
        s = suite_create("URLDB");
 
        suite_add_tcase(s, urldb_api_case_create());
+       suite_add_tcase(s, urldb_add_get_case_create());
        suite_add_tcase(s, urldb_session_case_create());
        suite_add_tcase(s, urldb_case_create());
        suite_add_tcase(s, urldb_cookie_case_create());
-       suite_add_tcase(s, urldb_add_get_case_create());
        suite_add_tcase(s, urldb_original_case_create());
 
        return s;


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=44ad580a7586b39f168603bab40fb73f511c4a8a
commit 44ad580a7586b39f168603bab40fb73f511c4a8a
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    extend urldb tests with url creation, setting and getting operations

diff --git a/test/urldbtest.c b/test/urldbtest.c
index 555ca96..2796637 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -65,6 +65,17 @@ const char *wikipedia_url = "http://www.wikipedia.org/";;
 
 struct netsurf_table *guit = NULL;
 
+
+struct test_triplets {
+       const char* url;
+       const char* title;
+       const char* res;
+};
+
+
+#define NELEMS(x)  (sizeof(x) / sizeof((x)[0]))
+
+
 /**
  * generate test output filenames
  */
@@ -248,14 +259,6 @@ START_TEST(urldb_original_test)
        nsurl *url;
        nsurl *urlr;
 
-       /* ensure title can be set */
-       url = make_url("http://intranet/";);
-       urldb_add_url(url);
-       urldb_set_url_title(url, "foo");
-
-       u = urldb_get_url_data(url);
-       ck_assert(u && strcmp(u->title, "foo") == 0);
-       nsurl_unref(url);
 
        /* fragments */
        url = 
make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm?a=b";);
@@ -274,9 +277,6 @@ START_TEST(urldb_original_test)
        ck_assert(urldb_add_url(url) == true);
        nsurl_unref(url);
 
-       url = make_url("file:///home/");
-       ck_assert(urldb_add_url(url) == true);
-       nsurl_unref(url);
 
        /* set cookies on urls */
        url = 
make_url("http://www.minimarcos.org.uk/cgi-bin/forum/Blah.pl?,v=login,p=2";);
@@ -311,37 +311,6 @@ START_TEST(urldb_original_test)
        urldb_get_cookie(url, true);
        nsurl_unref(url);
 
-       /* Mantis bug #993 */
-       url = make_url("http:moodle.org");
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
-
-       /* Mantis bug #993 */
-       url = make_url("http://a_a/";);
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
-
-       /* Mantis bug #996 */
-       url = make_url("http://[email protected]/";);
-       if (urldb_add_url(url)) {
-               LOG("added %s", nsurl_access(url));
-               ck_assert(urldb_get_url(url) != NULL);
-       }
-       nsurl_unref(url);
-
-       /* Mantis bug #913 */
-       url = make_url("http://www2.2checkout.com/";);
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
-
-       /* Numeric subdomains */
-       url = 
make_url("http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";);
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
 
        /* Valid path */
        ck_assert(test_urldb_set_cookie("name=value;Path=/\r\n", 
"http://www.google.com/";, NULL));
@@ -420,6 +389,12 @@ START_TEST(urldb_original_test)
 }
 END_TEST
 
+/**
+ * test case comprised of tests historicaly found in netsurf
+ *
+ * These tests are carried forward from original open coded tests
+ * found in the url database code.
+ */
 static TCase *urldb_original_case_create(void)
 {
        TCase *tc;
@@ -435,6 +410,90 @@ static TCase *urldb_original_case_create(void)
        return tc;
 }
 
+
+/**
+ * add set and get tests
+ */
+static const struct test_triplets add_set_get_tests[] = {
+       { "http://intranet/";, "foo", NULL }, /* from legacy tests */
+       { "http:moodle.org", "buggy", NULL }, /* Mantis bug #993 */
+       { "http://a_a/";, "buggsy", NULL }, /* Mantis bug #993 */
+       { "http://www2.2checkout.com/"; , "foobar", NULL }, /* Mantis bug #913 */
+       { 
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";,
+         "a more complex title" , NULL }, /* Numeric subdomains */
+       { "file:///home/", NULL, NULL}, /* no title */
+       { "http://[email protected]/";, NULL, NULL }, /* Mantis bug #996 */
+       { "http://a.xn--11b4c3d/a";, "a title", NULL },
+       { "https://smog.大众汽车/test";, "unicode title 大众汽车", NULL},
+};
+
+
+/**
+ * add set and get test
+ */
+START_TEST(urldb_add_set_get_test)
+{
+       nserror err;
+       nsurl *url;
+       nsurl *res_url;
+       struct url_data *data;
+       const struct test_triplets *tst = &add_set_get_tests[_i];
+
+       /* not testing create, this should always succeed */
+       err = nsurl_create(tst->url, &url);
+       ck_assert(err == NSERROR_OK);
+
+       /* add the url to the database */
+       ck_assert(urldb_add_url(url) == true);
+
+       /* set title */
+       err = urldb_set_url_title(url, tst->title);
+       ck_assert(err == NSERROR_OK);
+
+       /* retrieve the url from the database and check it matches */
+       res_url = urldb_get_url(url);
+       ck_assert(res_url != NULL);
+       ck_assert(nsurl_compare(url, res_url, NSURL_COMPLETE) == true);
+
+       /* retrieve url data and check title matches */
+       data = urldb_get_url_data(url);
+       ck_assert(data != NULL);
+
+       /* ensure title matches */
+       if (tst->title != NULL) {
+               ck_assert_str_eq(data->title, tst->title);
+       } else {
+               ck_assert(data->title == NULL);
+       }
+
+       /* release test url */
+       nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * test cases that simply add and then get a url
+ *
+ * these tests exercise the adding and retrival of urls verifying the
+ * data added.
+ */
+static TCase *urldb_add_get_case_create(void)
+{
+       TCase *tc;
+       tc = tcase_create("Add Get tests");
+
+       /* ensure corestrings are initialised and finalised for every test */
+       tcase_add_checked_fixture(tc,
+                                 urldb_create,
+                                 urldb_teardown);
+
+       tcase_add_loop_test(tc,
+                           urldb_add_set_get_test,
+                           0, NELEMS(add_set_get_tests));
+
+       return tc;
+}
+
 /**
  * Session basic test case
  *
@@ -899,7 +958,9 @@ static TCase *urldb_api_case_create(void)
        return tc;
 }
 
-
+/**
+ * Test suite for url database
+ */
 static Suite *urldb_suite_create(void)
 {
        Suite *s;
@@ -909,6 +970,7 @@ static Suite *urldb_suite_create(void)
        suite_add_tcase(s, urldb_session_case_create());
        suite_add_tcase(s, urldb_case_create());
        suite_add_tcase(s, urldb_cookie_case_create());
+       suite_add_tcase(s, urldb_add_get_case_create());
        suite_add_tcase(s, urldb_original_case_create());
 
        return s;


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=5078bffad799d41f8098e59b50d29dc018549663
commit 5078bffad799d41f8098e59b50d29dc018549663
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    change urldb_set_title API to return an error status

diff --git a/content/urldb.c b/content/urldb.c
index b190da5..2c2ba15 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -218,9 +218,9 @@ struct path_data {
 
        struct path_data *next; /**< Next sibling */
        struct path_data *prev; /**< Previous sibling */
-       struct path_data *parent;       /**< Parent path segment */
-       struct path_data *children;     /**< Child path segments */
-       struct path_data *last;         /**< Last child */
+       struct path_data *parent; /**< Parent path segment */
+       struct path_data *children; /**< Child path segments */
+       struct path_data *last; /**< Last child */
 };
 
 struct host_part {
@@ -241,15 +241,15 @@ struct host_part {
        char *part;
 
        /**
-        * Linked list of all known proctection spaces known for his
+        * Linked list of all known proctection spaces known for this
         * host and all its schems and ports.
         */
        struct prot_space_data *prot_space;
 
        struct host_part *next; /**< Next sibling */
        struct host_part *prev; /**< Previous sibling */
-       struct host_part *parent;       /**< Parent host part */
-       struct host_part *children;     /**< Child host parts */
+       struct host_part *parent; /**< Parent host part */
+       struct host_part *children; /**< Child host parts */
 };
 
 
@@ -3171,23 +3171,32 @@ bool urldb_add_url(nsurl *url)
 
 
 /* exported interface documented in content/urldb.h */
-void urldb_set_url_title(nsurl *url, const char *title)
+nserror urldb_set_url_title(nsurl *url, const char *title)
 {
        struct path_data *p;
        char *temp;
 
-       assert(url && title);
+       assert(url);
 
        p = urldb_find_url(url);
-       if (!p)
-               return;
+       if (p == NULL) {
+               return NSERROR_NOT_FOUND;
+       }
 
-       temp = strdup(title);
-       if (!temp)
-               return;
+       /* copy the parameter if necessary */
+       if (title != NULL) {
+               temp = strdup(title);
+               if (temp == NULL) {
+                       return NSERROR_NOMEM;
+               }
+       } else {
+               temp = NULL;
+       }
 
        free(p->urld.title);
        p->urld.title = temp;
+
+       return NSERROR_OK;
 }
 
 
diff --git a/content/urldb.h b/content/urldb.h
index 7230d0b..734b94a 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -58,8 +58,9 @@ bool urldb_add_url(struct nsurl *url);
  *
  * \param url The URL to look for
  * \param title The title string to use (copied)
+ * \return NSERROR_OK on success otherwise appropriate error code
  */
-void urldb_set_url_title(struct nsurl *url, const char *title);
+nserror urldb_set_url_title(struct nsurl *url, const char *title);
 
 
 /**


-----------------------------------------------------------------------

Summary of changes:
 content/urldb.c  |   35 +++++++----
 content/urldb.h  |    3 +-
 test/urldbtest.c |  175 ++++++++++++++++++++++++++++++++++++++----------------
 3 files changed, 148 insertions(+), 65 deletions(-)

diff --git a/content/urldb.c b/content/urldb.c
index b190da5..2c2ba15 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -218,9 +218,9 @@ struct path_data {
 
        struct path_data *next; /**< Next sibling */
        struct path_data *prev; /**< Previous sibling */
-       struct path_data *parent;       /**< Parent path segment */
-       struct path_data *children;     /**< Child path segments */
-       struct path_data *last;         /**< Last child */
+       struct path_data *parent; /**< Parent path segment */
+       struct path_data *children; /**< Child path segments */
+       struct path_data *last; /**< Last child */
 };
 
 struct host_part {
@@ -241,15 +241,15 @@ struct host_part {
        char *part;
 
        /**
-        * Linked list of all known proctection spaces known for his
+        * Linked list of all known proctection spaces known for this
         * host and all its schems and ports.
         */
        struct prot_space_data *prot_space;
 
        struct host_part *next; /**< Next sibling */
        struct host_part *prev; /**< Previous sibling */
-       struct host_part *parent;       /**< Parent host part */
-       struct host_part *children;     /**< Child host parts */
+       struct host_part *parent; /**< Parent host part */
+       struct host_part *children; /**< Child host parts */
 };
 
 
@@ -3171,23 +3171,32 @@ bool urldb_add_url(nsurl *url)
 
 
 /* exported interface documented in content/urldb.h */
-void urldb_set_url_title(nsurl *url, const char *title)
+nserror urldb_set_url_title(nsurl *url, const char *title)
 {
        struct path_data *p;
        char *temp;
 
-       assert(url && title);
+       assert(url);
 
        p = urldb_find_url(url);
-       if (!p)
-               return;
+       if (p == NULL) {
+               return NSERROR_NOT_FOUND;
+       }
 
-       temp = strdup(title);
-       if (!temp)
-               return;
+       /* copy the parameter if necessary */
+       if (title != NULL) {
+               temp = strdup(title);
+               if (temp == NULL) {
+                       return NSERROR_NOMEM;
+               }
+       } else {
+               temp = NULL;
+       }
 
        free(p->urld.title);
        p->urld.title = temp;
+
+       return NSERROR_OK;
 }
 
 
diff --git a/content/urldb.h b/content/urldb.h
index 7230d0b..734b94a 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -58,8 +58,9 @@ bool urldb_add_url(struct nsurl *url);
  *
  * \param url The URL to look for
  * \param title The title string to use (copied)
+ * \return NSERROR_OK on success otherwise appropriate error code
  */
-void urldb_set_url_title(struct nsurl *url, const char *title);
+nserror urldb_set_url_title(struct nsurl *url, const char *title);
 
 
 /**
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 555ca96..19d0f9e 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -65,6 +65,17 @@ const char *wikipedia_url = "http://www.wikipedia.org/";;
 
 struct netsurf_table *guit = NULL;
 
+
+struct test_triplets {
+       const char* url;
+       const char* title;
+       const char* res;
+};
+
+
+#define NELEMS(x)  (sizeof(x) / sizeof((x)[0]))
+
+
 /**
  * generate test output filenames
  */
@@ -248,14 +259,6 @@ START_TEST(urldb_original_test)
        nsurl *url;
        nsurl *urlr;
 
-       /* ensure title can be set */
-       url = make_url("http://intranet/";);
-       urldb_add_url(url);
-       urldb_set_url_title(url, "foo");
-
-       u = urldb_get_url_data(url);
-       ck_assert(u && strcmp(u->title, "foo") == 0);
-       nsurl_unref(url);
 
        /* fragments */
        url = 
make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm?a=b";);
@@ -274,9 +277,6 @@ START_TEST(urldb_original_test)
        ck_assert(urldb_add_url(url) == true);
        nsurl_unref(url);
 
-       url = make_url("file:///home/");
-       ck_assert(urldb_add_url(url) == true);
-       nsurl_unref(url);
 
        /* set cookies on urls */
        url = 
make_url("http://www.minimarcos.org.uk/cgi-bin/forum/Blah.pl?,v=login,p=2";);
@@ -311,37 +311,6 @@ START_TEST(urldb_original_test)
        urldb_get_cookie(url, true);
        nsurl_unref(url);
 
-       /* Mantis bug #993 */
-       url = make_url("http:moodle.org");
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
-
-       /* Mantis bug #993 */
-       url = make_url("http://a_a/";);
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
-
-       /* Mantis bug #996 */
-       url = make_url("http://[email protected]/";);
-       if (urldb_add_url(url)) {
-               LOG("added %s", nsurl_access(url));
-               ck_assert(urldb_get_url(url) != NULL);
-       }
-       nsurl_unref(url);
-
-       /* Mantis bug #913 */
-       url = make_url("http://www2.2checkout.com/";);
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
-
-       /* Numeric subdomains */
-       url = 
make_url("http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";);
-       ck_assert(urldb_add_url(url) == true);
-       ck_assert(urldb_get_url(url) != NULL);
-       nsurl_unref(url);
 
        /* Valid path */
        ck_assert(test_urldb_set_cookie("name=value;Path=/\r\n", 
"http://www.google.com/";, NULL));
@@ -420,6 +389,12 @@ START_TEST(urldb_original_test)
 }
 END_TEST
 
+/**
+ * test case comprised of tests historicaly found in netsurf
+ *
+ * These tests are carried forward from original open coded tests
+ * found in the url database code.
+ */
 static TCase *urldb_original_case_create(void)
 {
        TCase *tc;
@@ -435,6 +410,91 @@ static TCase *urldb_original_case_create(void)
        return tc;
 }
 
+
+/**
+ * add set and get tests
+ */
+static const struct test_triplets add_set_get_tests[] = {
+       { "http://intranet/";, "foo", NULL }, /* from legacy tests */
+       { "http:moodle.org", "buggy", NULL }, /* Mantis bug #993 */
+       { "http://a_a/";, "buggsy", NULL }, /* Mantis bug #993 */
+       { "http://www2.2checkout.com/"; , "foobar", NULL }, /* Mantis bug #913 */
+       { 
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";,
+         "a more complex title" , NULL }, /* Numeric subdomains */
+       { 
"http://tree.example.com/this_url_has_a_ridiculously_long_path/made_up_from_a_number_of_inoranately_long_elments_some_of_well_over_forty/characters_in_length/foo.png";,
 NULL, NULL },
+       { "file:///home/", NULL, NULL}, /* no title */
+       { "http://[email protected]/";, NULL, NULL }, /* Mantis bug #996 */
+       { "http://a.xn--11b4c3d/a";, "a title", NULL },
+       { "https://smog.大众汽车/test";, "unicode title 大众汽车", NULL},
+};
+
+
+/**
+ * add set and get test
+ */
+START_TEST(urldb_add_set_get_test)
+{
+       nserror err;
+       nsurl *url;
+       nsurl *res_url;
+       struct url_data *data;
+       const struct test_triplets *tst = &add_set_get_tests[_i];
+
+       /* not testing create, this should always succeed */
+       err = nsurl_create(tst->url, &url);
+       ck_assert(err == NSERROR_OK);
+
+       /* add the url to the database */
+       ck_assert(urldb_add_url(url) == true);
+
+       /* set title */
+       err = urldb_set_url_title(url, tst->title);
+       ck_assert(err == NSERROR_OK);
+
+       /* retrieve the url from the database and check it matches */
+       res_url = urldb_get_url(url);
+       ck_assert(res_url != NULL);
+       ck_assert(nsurl_compare(url, res_url, NSURL_COMPLETE) == true);
+
+       /* retrieve url data and check title matches */
+       data = urldb_get_url_data(url);
+       ck_assert(data != NULL);
+
+       /* ensure title matches */
+       if (tst->title != NULL) {
+               ck_assert_str_eq(data->title, tst->title);
+       } else {
+               ck_assert(data->title == NULL);
+       }
+
+       /* release test url */
+       nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * test cases that simply add and then get a url
+ *
+ * these tests exercise the adding and retrival of urls verifying the
+ * data added.
+ */
+static TCase *urldb_add_get_case_create(void)
+{
+       TCase *tc;
+       tc = tcase_create("Add Get tests");
+
+       /* ensure corestrings are initialised and finalised for every test */
+       tcase_add_checked_fixture(tc,
+                                 urldb_create,
+                                 urldb_teardown);
+
+       tcase_add_loop_test(tc,
+                           urldb_add_set_get_test,
+                           0, NELEMS(add_set_get_tests));
+
+       return tc;
+}
+
 /**
  * Session basic test case
  *
@@ -492,6 +552,7 @@ START_TEST(urldb_session_add_test)
        nserror res;
        char *outnam;
        nsurl *url;
+       int t;
 
        /* writing output requires options initialising */
        res = nsoption_init(NULL, NULL, NULL);
@@ -502,28 +563,37 @@ START_TEST(urldb_session_add_test)
 
        urldb_load_cookies(test_cookies_path);
 
-       /* add something to db */
-       url = make_url("http://tree.example.com/";);
-       urldb_add_url(url);
+       /* add to db */
+       for (t = 0; t < NELEMS(add_set_get_tests); t++) {
+               const struct test_triplets *tst = &add_set_get_tests[t];
 
-       res = urldb_update_url_visit_data(url);
-       ck_assert_int_eq(res, NSERROR_OK);
+               /* not testing url creation, this should always succeed */
+               res = nsurl_create(tst->url, &url);
+               ck_assert_int_eq(res, NSERROR_OK);
 
-       nsurl_unref(url);
+               /* add the url to the database */
+               ck_assert(urldb_add_url(url) == true);
+
+               /* update the visit time so it gets serialised */
+               res = urldb_update_url_visit_data(url);
+               ck_assert_int_eq(res, NSERROR_OK);
+
+               nsurl_unref(url);
+       }
 
        /* write database out */
        outnam = testnam(NULL);
        res = urldb_save(outnam);
        ck_assert_int_eq(res, NSERROR_OK);
 
-       /* remove test output */
+       /* remove urldb test output */
        unlink(outnam);
 
        /* write cookies out */
        outnam = testnam(NULL);
        urldb_save_cookies(outnam);
 
-       /* remove test output */
+       /* remove cookies test output */
        unlink(outnam);
 
        /* finalise options */
@@ -899,13 +969,16 @@ static TCase *urldb_api_case_create(void)
        return tc;
 }
 
-
+/**
+ * Test suite for url database
+ */
 static Suite *urldb_suite_create(void)
 {
        Suite *s;
        s = suite_create("URLDB");
 
        suite_add_tcase(s, urldb_api_case_create());
+       suite_add_tcase(s, urldb_add_get_case_create());
        suite_add_tcase(s, urldb_session_case_create());
        suite_add_tcase(s, urldb_case_create());
        suite_add_tcase(s, urldb_cookie_case_create());


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to