Gitweb links:

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

The branch, master has been updated
       via  eb5e5ff48636cd4a63f9517087490c296cde9c69 (commit)
       via  5395c2b98ef9ab14b8bc8d084276d3218df5b950 (commit)
       via  925c69f16ac2f4f843448cabbcef319350758260 (commit)
       via  0e8ab0405178c97bec177614b28e8e2074ce1199 (commit)
       via  f7c0ea5156c1d2a98d4f136645187ac48ab185f4 (commit)
      from  3d33157a863f979c57043d9aec1fb477d36e2dd4 (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=eb5e5ff48636cd4a63f9517087490c296cde9c69
commit eb5e5ff48636cd4a63f9517087490c296cde9c69
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    add test to messages buffer lookup api

diff --git a/test/messages.c b/test/messages.c
index 9ea5527..d102e36 100644
--- a/test/messages.c
+++ b/test/messages.c
@@ -110,6 +110,28 @@ START_TEST(message_file_load_test)
 }
 END_TEST
 
+START_TEST(message_get_buff_test)
+{
+       nserror res;
+       char *buf;
+       res = messages_add_from_inline(test_data_Messages,
+                                      test_data_Messages_len);
+       ck_assert_int_eq(res, NSERROR_OK);
+
+       buf = messages_get_buff("DefinitelyNotAKey");
+       ck_assert_str_eq(buf, "DefinitelyNotAKey");
+       free(buf);
+
+       buf = messages_get_buff("NoMemory");
+       ck_assert_str_eq(buf, "NetSurf is running out of memory. Please free 
some memory and try again.");
+       free(buf);
+
+       /* cleanup */
+       messages_destroy();
+}
+END_TEST
+
+
 static TCase *message_session_case_create(void)
 {
        TCase *tc;
@@ -119,6 +141,7 @@ static TCase *message_session_case_create(void)
        tcase_add_test(tc, message_inline_load_test);
        tcase_add_loop_test(tc, messages_errorcode_test,
                            0, NELEMS(message_errorcode_test_vec));
+       tcase_add_test(tc, message_get_buff_test);
 
        return tc;
 }


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

    free resources in messages test

diff --git a/test/messages.c b/test/messages.c
index 050b6d4..9ea5527 100644
--- a/test/messages.c
+++ b/test/messages.c
@@ -81,6 +81,9 @@ START_TEST(messages_errorcode_test)
 
        /* ensure result data is correct */
        ck_assert_str_eq(res_str, tst->res);
+
+       /* cleanup */
+       messages_destroy();
 }
 END_TEST
 
@@ -90,6 +93,9 @@ START_TEST(message_inline_load_test)
        res = messages_add_from_inline(test_data_Messages,
                                       test_data_Messages_len);
        ck_assert_int_eq(res, NSERROR_OK);
+
+       /* cleanup */
+       messages_destroy();
 }
 END_TEST
 
@@ -98,6 +104,9 @@ START_TEST(message_file_load_test)
        nserror res;
        res = messages_add_from_file(test_messages_path);
        ck_assert_int_eq(res, NSERROR_OK);
+
+       /* cleanup */
+       messages_destroy();
 }
 END_TEST
 


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

    add additional string handling tests

diff --git a/test/utils.c b/test/utils.c
index 4202792..3d5319a 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -21,6 +21,8 @@
  * Tests for utility functions.
  */
 
+#include "utils/config.h"
+
 #include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -230,6 +232,41 @@ START_TEST(string_utils_cnv_space2nbsp_test)
 }
 END_TEST
 
+START_TEST(string_utils_strcasestr_test)
+{
+
+       char *res;
+       const char *haystack = "A big old long haystack string that has a small 
Needle in the middle of it with a different case";
+
+       res = strcasestr(haystack, "notfound");
+       ck_assert(res == NULL);
+
+       res = strcasestr(haystack, "needle");
+       ck_assert(res != NULL);
+
+       ck_assert_str_eq(res, haystack + 48);
+
+}
+END_TEST
+
+START_TEST(string_utils_strchrnul_test)
+{
+
+       char *res;
+       const char *haystack = "A big old long haystack string that has a small 
Needle in the middle of it with a different case";
+
+       res = strchrnul(haystack, 'Z');
+       ck_assert(res != NULL);
+       ck_assert(*res == 0);
+
+       res = strchrnul(haystack, 'N');
+       ck_assert(res != NULL);
+
+       ck_assert_str_eq(res, haystack + 48);
+
+}
+END_TEST
+
 
 static TCase *string_utils_case_create(void)
 {
@@ -237,6 +274,8 @@ static TCase *string_utils_case_create(void)
        tc = tcase_create("String utilities");
 
        tcase_add_test(tc, string_utils_cnv_space2nbsp_test);
+       tcase_add_test(tc, string_utils_strcasestr_test);
+       tcase_add_test(tc, string_utils_strchrnul_test);
 
        return tc;
 }


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

    extend human readable size tests to cover buffer cycling

diff --git a/test/utils.c b/test/utils.c
index 9a3fc2c..4202792 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -53,6 +53,9 @@ static const struct test_pairs 
human_friendly_bytesize_test_vec[] = {
        { 4294967295, "4.00GBytes" },
 };
 
+/**
+ * check each response one at a time
+ */
 START_TEST(human_friendly_bytesize_test)
 {
        char *res_str;
@@ -65,6 +68,26 @@ START_TEST(human_friendly_bytesize_test)
 }
 END_TEST
 
+/**
+ * check each response one after another
+ */
+START_TEST(human_friendly_bytesize_all_test)
+{
+       char *res_str;
+       const struct test_pairs *tst;
+       unsigned int idx;
+
+       for (idx = 0; idx < NELEMS(human_friendly_bytesize_test_vec); idx++) {
+               tst = &human_friendly_bytesize_test_vec[idx];
+
+               res_str = human_friendly_bytesize(tst->test);
+
+               /* ensure result data is correct */
+               ck_assert_str_eq(res_str, tst->res);
+       }
+}
+END_TEST
+
 static TCase *human_friendly_bytesize_case_create(void)
 {
        TCase *tc;
@@ -73,6 +96,8 @@ static TCase *human_friendly_bytesize_case_create(void)
        tcase_add_loop_test(tc, human_friendly_bytesize_test,
                            0, NELEMS(human_friendly_bytesize_test_vec));
 
+       tcase_add_test(tc, human_friendly_bytesize_all_test);
+
        return tc;
 }
 


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

    have more comprehensive separate test case for snstrjoin

diff --git a/test/utils.c b/test/utils.c
index e74057e..9a3fc2c 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -88,6 +88,10 @@ static const struct test_strings 
squash_whitespace_test_vec[] = {
        { " \n\r\t   ", " " },
        { " a ", " a " },
        { " a   b ", " a b " },
+       {
+               "   A string  with \t  \r \n  \t   lots\tof\nwhitespace\r    ",
+               " A string with lots of whitespace "
+       },
 };
 
 START_TEST(squash_whitespace_test)
@@ -181,16 +185,6 @@ static TCase *corestrings_case_create(void)
        return tc;
 }
 
-START_TEST(string_utils_squash_whitespace_test)
-{
-       char *res;
-       res = squash_whitespace("   A string  with \t      \t   lots of 
whitespace    ");
-       ck_assert(res != NULL);
-       ck_assert_str_eq(res, " A string with lots of whitespace ");
-
-       free(res);
-}
-END_TEST
 
 
 START_TEST(string_utils_cnv_space2nbsp_test)
@@ -212,7 +206,55 @@ START_TEST(string_utils_cnv_space2nbsp_test)
 END_TEST
 
 
-START_TEST(string_utils_snstrjoin_test)
+static TCase *string_utils_case_create(void)
+{
+       TCase *tc;
+       tc = tcase_create("String utilities");
+
+       tcase_add_test(tc, string_utils_cnv_space2nbsp_test);
+
+       return tc;
+}
+
+
+/**
+ * api tests
+ */
+START_TEST(string_utils_snstrjoin_api_test)
+{
+       nserror res;
+       char outstr[32];
+       char *resstr = &outstr[0];
+       size_t resstrlen = 32;
+
+       /* bad count parameters */
+       res = snstrjoin(&resstr, &resstrlen, ',', 0, "1");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       res = snstrjoin(&resstr, &resstrlen, ',', 17, "1");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       /* if there is a buffer must set length */
+       res = snstrjoin(&resstr, NULL, ',', 4, "1", "2", "3", "4");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       /* null argument value is bad parameter */
+       res = snstrjoin(&resstr, &resstrlen, ',', 4, "1", NULL, "3", "4");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       /* attempt to use an undersize buffer */
+       resstrlen = 1;
+       res = snstrjoin(&resstr, &resstrlen, ',', 4, "1", "2", "3", "4");
+       ck_assert_int_eq(res, NSERROR_NOSPACE);
+
+}
+END_TEST
+
+
+/**
+ * good four parameter join
+ */
+START_TEST(string_utils_snstrjoin_four_test)
 {
        nserror res;
        char *resstr = NULL;
@@ -228,26 +270,68 @@ START_TEST(string_utils_snstrjoin_test)
 END_TEST
 
 
-static TCase *string_utils_case_create(void)
+/**
+ * good three parameter join with no length
+ */
+START_TEST(string_utils_snstrjoin_three_test)
+{
+       nserror res;
+       char *resstr = NULL;
+
+       res = snstrjoin(&resstr, NULL, ',', 3, "1", "2,", "3");
+       ck_assert_int_eq(res, NSERROR_OK);
+       ck_assert(resstr != NULL);
+       ck_assert_str_eq(resstr, "1,2,3");
+       free(resstr);
+}
+END_TEST
+
+/**
+ * good two parameter join into pre allocated buffer
+ */
+START_TEST(string_utils_snstrjoin_two_test)
+{
+       nserror res;
+       char outstr[32];
+       char *resstr = &outstr[0];
+       size_t resstrlen = 32;
+
+       res = snstrjoin(&resstr, &resstrlen, ',', 2, "1", "2");
+       ck_assert_int_eq(res, NSERROR_OK);
+       ck_assert(resstr != NULL);
+       ck_assert_int_eq(resstrlen, 4);
+       ck_assert_str_eq(resstr, "1,2");
+}
+END_TEST
+
+
+static TCase *snstrjoin_case_create(void)
 {
        TCase *tc;
-       tc = tcase_create("String utilities");
+       tc = tcase_create("snstrjoin utilities");
 
-       tcase_add_test(tc, string_utils_squash_whitespace_test);
-       tcase_add_test(tc, string_utils_cnv_space2nbsp_test);
-       tcase_add_test(tc, string_utils_snstrjoin_test);
+       tcase_add_test(tc, string_utils_snstrjoin_api_test);
+       tcase_add_test(tc, string_utils_snstrjoin_four_test);
+       tcase_add_test(tc, string_utils_snstrjoin_three_test);
+       tcase_add_test(tc, string_utils_snstrjoin_three_test);
+       tcase_add_test(tc, string_utils_snstrjoin_two_test);
 
        return tc;
 }
 
+
+/*
+ * Utility test suite creation
+ */
 static Suite *utils_suite_create(void)
 {
        Suite *s;
-       s = suite_create("String utils");
+       s = suite_create("Utility API");
 
        suite_add_tcase(s, human_friendly_bytesize_case_create());
        suite_add_tcase(s, squash_whitespace_case_create());
        suite_add_tcase(s, corestrings_case_create());
+       suite_add_tcase(s, snstrjoin_case_create());
        suite_add_tcase(s, string_utils_case_create());
 
        return s;


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

Summary of changes:
 test/messages.c |   32 ++++++++++
 test/utils.c    |  182 +++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 197 insertions(+), 17 deletions(-)

diff --git a/test/messages.c b/test/messages.c
index 050b6d4..d102e36 100644
--- a/test/messages.c
+++ b/test/messages.c
@@ -81,6 +81,9 @@ START_TEST(messages_errorcode_test)
 
        /* ensure result data is correct */
        ck_assert_str_eq(res_str, tst->res);
+
+       /* cleanup */
+       messages_destroy();
 }
 END_TEST
 
@@ -90,6 +93,9 @@ START_TEST(message_inline_load_test)
        res = messages_add_from_inline(test_data_Messages,
                                       test_data_Messages_len);
        ck_assert_int_eq(res, NSERROR_OK);
+
+       /* cleanup */
+       messages_destroy();
 }
 END_TEST
 
@@ -98,9 +104,34 @@ START_TEST(message_file_load_test)
        nserror res;
        res = messages_add_from_file(test_messages_path);
        ck_assert_int_eq(res, NSERROR_OK);
+
+       /* cleanup */
+       messages_destroy();
 }
 END_TEST
 
+START_TEST(message_get_buff_test)
+{
+       nserror res;
+       char *buf;
+       res = messages_add_from_inline(test_data_Messages,
+                                      test_data_Messages_len);
+       ck_assert_int_eq(res, NSERROR_OK);
+
+       buf = messages_get_buff("DefinitelyNotAKey");
+       ck_assert_str_eq(buf, "DefinitelyNotAKey");
+       free(buf);
+
+       buf = messages_get_buff("NoMemory");
+       ck_assert_str_eq(buf, "NetSurf is running out of memory. Please free 
some memory and try again.");
+       free(buf);
+
+       /* cleanup */
+       messages_destroy();
+}
+END_TEST
+
+
 static TCase *message_session_case_create(void)
 {
        TCase *tc;
@@ -110,6 +141,7 @@ static TCase *message_session_case_create(void)
        tcase_add_test(tc, message_inline_load_test);
        tcase_add_loop_test(tc, messages_errorcode_test,
                            0, NELEMS(message_errorcode_test_vec));
+       tcase_add_test(tc, message_get_buff_test);
 
        return tc;
 }
diff --git a/test/utils.c b/test/utils.c
index e74057e..3d5319a 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -21,6 +21,8 @@
  * Tests for utility functions.
  */
 
+#include "utils/config.h"
+
 #include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -53,6 +55,9 @@ static const struct test_pairs 
human_friendly_bytesize_test_vec[] = {
        { 4294967295, "4.00GBytes" },
 };
 
+/**
+ * check each response one at a time
+ */
 START_TEST(human_friendly_bytesize_test)
 {
        char *res_str;
@@ -65,6 +70,26 @@ START_TEST(human_friendly_bytesize_test)
 }
 END_TEST
 
+/**
+ * check each response one after another
+ */
+START_TEST(human_friendly_bytesize_all_test)
+{
+       char *res_str;
+       const struct test_pairs *tst;
+       unsigned int idx;
+
+       for (idx = 0; idx < NELEMS(human_friendly_bytesize_test_vec); idx++) {
+               tst = &human_friendly_bytesize_test_vec[idx];
+
+               res_str = human_friendly_bytesize(tst->test);
+
+               /* ensure result data is correct */
+               ck_assert_str_eq(res_str, tst->res);
+       }
+}
+END_TEST
+
 static TCase *human_friendly_bytesize_case_create(void)
 {
        TCase *tc;
@@ -73,6 +98,8 @@ static TCase *human_friendly_bytesize_case_create(void)
        tcase_add_loop_test(tc, human_friendly_bytesize_test,
                            0, NELEMS(human_friendly_bytesize_test_vec));
 
+       tcase_add_test(tc, human_friendly_bytesize_all_test);
+
        return tc;
 }
 
@@ -88,6 +115,10 @@ static const struct test_strings 
squash_whitespace_test_vec[] = {
        { " \n\r\t   ", " " },
        { " a ", " a " },
        { " a   b ", " a b " },
+       {
+               "   A string  with \t  \r \n  \t   lots\tof\nwhitespace\r    ",
+               " A string with lots of whitespace "
+       },
 };
 
 START_TEST(squash_whitespace_test)
@@ -181,16 +212,6 @@ static TCase *corestrings_case_create(void)
        return tc;
 }
 
-START_TEST(string_utils_squash_whitespace_test)
-{
-       char *res;
-       res = squash_whitespace("   A string  with \t      \t   lots of 
whitespace    ");
-       ck_assert(res != NULL);
-       ck_assert_str_eq(res, " A string with lots of whitespace ");
-
-       free(res);
-}
-END_TEST
 
 
 START_TEST(string_utils_cnv_space2nbsp_test)
@@ -211,8 +232,93 @@ START_TEST(string_utils_cnv_space2nbsp_test)
 }
 END_TEST
 
+START_TEST(string_utils_strcasestr_test)
+{
+
+       char *res;
+       const char *haystack = "A big old long haystack string that has a small 
Needle in the middle of it with a different case";
+
+       res = strcasestr(haystack, "notfound");
+       ck_assert(res == NULL);
 
-START_TEST(string_utils_snstrjoin_test)
+       res = strcasestr(haystack, "needle");
+       ck_assert(res != NULL);
+
+       ck_assert_str_eq(res, haystack + 48);
+
+}
+END_TEST
+
+START_TEST(string_utils_strchrnul_test)
+{
+
+       char *res;
+       const char *haystack = "A big old long haystack string that has a small 
Needle in the middle of it with a different case";
+
+       res = strchrnul(haystack, 'Z');
+       ck_assert(res != NULL);
+       ck_assert(*res == 0);
+
+       res = strchrnul(haystack, 'N');
+       ck_assert(res != NULL);
+
+       ck_assert_str_eq(res, haystack + 48);
+
+}
+END_TEST
+
+
+static TCase *string_utils_case_create(void)
+{
+       TCase *tc;
+       tc = tcase_create("String utilities");
+
+       tcase_add_test(tc, string_utils_cnv_space2nbsp_test);
+       tcase_add_test(tc, string_utils_strcasestr_test);
+       tcase_add_test(tc, string_utils_strchrnul_test);
+
+       return tc;
+}
+
+
+/**
+ * api tests
+ */
+START_TEST(string_utils_snstrjoin_api_test)
+{
+       nserror res;
+       char outstr[32];
+       char *resstr = &outstr[0];
+       size_t resstrlen = 32;
+
+       /* bad count parameters */
+       res = snstrjoin(&resstr, &resstrlen, ',', 0, "1");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       res = snstrjoin(&resstr, &resstrlen, ',', 17, "1");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       /* if there is a buffer must set length */
+       res = snstrjoin(&resstr, NULL, ',', 4, "1", "2", "3", "4");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       /* null argument value is bad parameter */
+       res = snstrjoin(&resstr, &resstrlen, ',', 4, "1", NULL, "3", "4");
+       ck_assert_int_eq(res, NSERROR_BAD_PARAMETER);
+
+       /* attempt to use an undersize buffer */
+       resstrlen = 1;
+       res = snstrjoin(&resstr, &resstrlen, ',', 4, "1", "2", "3", "4");
+       ck_assert_int_eq(res, NSERROR_NOSPACE);
+
+}
+END_TEST
+
+
+/**
+ * good four parameter join
+ */
+START_TEST(string_utils_snstrjoin_four_test)
 {
        nserror res;
        char *resstr = NULL;
@@ -228,26 +334,68 @@ START_TEST(string_utils_snstrjoin_test)
 END_TEST
 
 
-static TCase *string_utils_case_create(void)
+/**
+ * good three parameter join with no length
+ */
+START_TEST(string_utils_snstrjoin_three_test)
+{
+       nserror res;
+       char *resstr = NULL;
+
+       res = snstrjoin(&resstr, NULL, ',', 3, "1", "2,", "3");
+       ck_assert_int_eq(res, NSERROR_OK);
+       ck_assert(resstr != NULL);
+       ck_assert_str_eq(resstr, "1,2,3");
+       free(resstr);
+}
+END_TEST
+
+/**
+ * good two parameter join into pre allocated buffer
+ */
+START_TEST(string_utils_snstrjoin_two_test)
+{
+       nserror res;
+       char outstr[32];
+       char *resstr = &outstr[0];
+       size_t resstrlen = 32;
+
+       res = snstrjoin(&resstr, &resstrlen, ',', 2, "1", "2");
+       ck_assert_int_eq(res, NSERROR_OK);
+       ck_assert(resstr != NULL);
+       ck_assert_int_eq(resstrlen, 4);
+       ck_assert_str_eq(resstr, "1,2");
+}
+END_TEST
+
+
+static TCase *snstrjoin_case_create(void)
 {
        TCase *tc;
-       tc = tcase_create("String utilities");
+       tc = tcase_create("snstrjoin utilities");
 
-       tcase_add_test(tc, string_utils_squash_whitespace_test);
-       tcase_add_test(tc, string_utils_cnv_space2nbsp_test);
-       tcase_add_test(tc, string_utils_snstrjoin_test);
+       tcase_add_test(tc, string_utils_snstrjoin_api_test);
+       tcase_add_test(tc, string_utils_snstrjoin_four_test);
+       tcase_add_test(tc, string_utils_snstrjoin_three_test);
+       tcase_add_test(tc, string_utils_snstrjoin_three_test);
+       tcase_add_test(tc, string_utils_snstrjoin_two_test);
 
        return tc;
 }
 
+
+/*
+ * Utility test suite creation
+ */
 static Suite *utils_suite_create(void)
 {
        Suite *s;
-       s = suite_create("String utils");
+       s = suite_create("Utility API");
 
        suite_add_tcase(s, human_friendly_bytesize_case_create());
        suite_add_tcase(s, squash_whitespace_case_create());
        suite_add_tcase(s, corestrings_case_create());
+       suite_add_tcase(s, snstrjoin_case_create());
        suite_add_tcase(s, string_utils_case_create());
 
        return s;


-- 
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