From 02360ec7be6b061513f07638d015da066afef7dc Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 14 Aug 2016 23:49:53 +0100 Subject: add some corestrings API tests and fix corestrings fini. --- test/Makefile | 1 + test/utils.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ utils/corestrings.c | 4 +++- 3 files changed, 58 insertions(+), 1 deletion(-) 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 #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; + } } -- cgit v1.2.3