diff options
author | Vincent Sanders <vince@kyllikki.org> | 2017-03-14 23:07:26 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2017-03-14 23:07:26 +0000 |
commit | 925c69f16ac2f4f843448cabbcef319350758260 (patch) | |
tree | c526a4bf5ec9a7b4260fd5629f185fb8f4ade9dc /test/utils.c | |
parent | 0e8ab0405178c97bec177614b28e8e2074ce1199 (diff) | |
download | netsurf-925c69f16ac2f4f843448cabbcef319350758260.tar.gz netsurf-925c69f16ac2f4f843448cabbcef319350758260.tar.bz2 |
add additional string handling tests
Diffstat (limited to 'test/utils.c')
-rw-r--r-- | test/utils.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/utils.c b/test/utils.c index 4202792fb..3d5319a28 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; } |