summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-08-14 23:49:53 +0100
committerVincent Sanders <vince@kyllikki.org>2016-08-14 23:49:53 +0100
commit02360ec7be6b061513f07638d015da066afef7dc (patch)
tree6fdb8232420102d0185a700bebe414afd879e36b
parent0e5824c8e851ee6fd29868eddd3be2b738f3351e (diff)
downloadnetsurf-02360ec7be6b061513f07638d015da066afef7dc.tar.gz
netsurf-02360ec7be6b061513f07638d015da066afef7dc.tar.bz2
add some corestrings API tests and fix corestrings fini.
-rw-r--r--test/Makefile1
-rw-r--r--test/utils.c54
-rw-r--r--utils/corestrings.c4
3 files changed, 58 insertions, 1 deletions
diff --git a/test/Makefile b/test/Makefile
index d62e2fd8d..a3f84f35a 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -51,6 +51,7 @@ urlescape_SRCS := utils/url.c test/log.c test/urlescape.c
# utility test sources
utils_SRCS := utils/utils.c utils/messages.c utils/hashtable.c \
+ utils/corestrings.c utils/nsurl.c utils/idna.c \
test/log.c test/utils.c
# time test sources
diff --git a/test/utils.c b/test/utils.c
index e00ab3dc4..62ccf512d 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -29,6 +29,7 @@
#include <check.h>
#include "utils/string.h"
+#include "utils/corestrings.h"
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
#define SLEN(x) (sizeof((x)) - 1)
@@ -128,6 +129,58 @@ static TCase *squash_whitespace_case_create(void)
return tc;
}
+
+START_TEST(corestrings_init_fini_test)
+{
+ nserror res;
+
+ res = corestrings_init();
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ corestrings_fini();
+}
+END_TEST
+
+START_TEST(corestrings_double_init_test)
+{
+ nserror res;
+
+ res = corestrings_init();
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ res = corestrings_init();
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ corestrings_fini();
+}
+END_TEST
+
+START_TEST(corestrings_double_fini_test)
+{
+ nserror res;
+
+ res = corestrings_init();
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ corestrings_fini();
+
+ corestrings_fini();
+}
+END_TEST
+
+
+static TCase *corestrings_case_create(void)
+{
+ TCase *tc;
+ tc = tcase_create("Corestrings");
+
+ tcase_add_test(tc, corestrings_init_fini_test);
+ tcase_add_test(tc, corestrings_double_init_test);
+ tcase_add_test(tc, corestrings_double_fini_test);
+
+ return tc;
+}
+
static Suite *utils_suite_create(void)
{
Suite *s;
@@ -135,6 +188,7 @@ static Suite *utils_suite_create(void)
suite_add_tcase(s, human_friendly_bytesize_case_create());
suite_add_tcase(s, squash_whitespace_case_create());
+ suite_add_tcase(s, corestrings_case_create());
return s;
}
diff --git a/utils/corestrings.c b/utils/corestrings.c
index 38da76d14..0afad9f4a 100644
--- a/utils/corestrings.c
+++ b/utils/corestrings.c
@@ -570,8 +570,10 @@ void corestrings_fini(void)
#undef CSS_DOM_STRING_UNREF
/* nsurl URLs */
- if (corestring_nsurl_about_blank != NULL)
+ if (corestring_nsurl_about_blank != NULL) {
nsurl_unref(corestring_nsurl_about_blank);
+ corestring_nsurl_about_blank = NULL;
+ }
}