summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2016-01-30 12:16:29 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2016-01-30 12:17:21 (GMT)
commit08c5618a803fa32243dfa434225604566c5dac91 (patch)
treea9542977a466f35ae4fe12faf5c3f4ed020cb9b1
parent43b2081b8d5e23c8582e2729f18ccd7555be8a40 (diff)
downloadlibwapcaplet-08c5618a803fa32243dfa434225604566c5dac91.tar.gz
libwapcaplet-08c5618a803fa32243dfa434225604566c5dac91.tar.bz2
Add lwc_string_tolower() tests.
-rw-r--r--test/basictests.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/basictests.c b/test/basictests.c
index ec9bf20..c23b547 100644
--- a/test/basictests.c
+++ b/test/basictests.c
@@ -50,6 +50,22 @@ START_TEST (test_lwc_intern_substring_aborts2)
}
END_TEST
+START_TEST (test_lwc_string_tolower_aborts1)
+{
+ lwc_string_tolower(null_lwc, null_lwc_p);
+}
+END_TEST
+
+START_TEST (test_lwc_string_tolower_aborts2)
+{
+ lwc_string *str;
+ fail_unless(lwc_intern_string("Badger", 6, &str) == lwc_error_ok,
+ "unable to intern 'Badger'");
+
+ lwc_string_tolower(str, null_lwc_p);
+}
+END_TEST
+
START_TEST (test_lwc_string_ref_aborts)
{
lwc_string_ref(null_lwc);
@@ -330,6 +346,41 @@ START_TEST (test_lwc_substring_is_nul_terminated)
}
END_TEST
+START_TEST (test_lwc_string_tolower_ok1)
+{
+ bool result = true;
+ lwc_string *new_ONE;
+ lwc_string *new_one;
+
+ fail_unless(lwc_intern_string("ONE", 3, &new_ONE) == lwc_error_ok,
+ "Failure interning 'ONE'");
+ fail_unless(lwc_string_tolower(new_ONE, &new_one) == lwc_error_ok);
+ fail_unless(lwc_string_isequal(intern_one, new_ONE, &result) == lwc_error_ok);
+ fail_unless(result == false, "'one' == 'ONE' ?!");
+ fail_unless(lwc_string_isequal(intern_one, new_one, &result) == lwc_error_ok);
+ fail_unless(result == true, "'one' != 'one' ?!");
+}
+END_TEST
+
+START_TEST (test_lwc_string_tolower_ok2)
+{
+ bool result = true;
+ lwc_string *new_ONE;
+ lwc_string *new_one;
+
+ fail_unless(lwc_intern_string("ONE", 3, &new_ONE) == lwc_error_ok,
+ "Failure interning 'ONE'");
+ /* Ensure new_ONE has an insensitive pointer set */
+ fail_unless(lwc_string_caseless_isequal(intern_one, new_ONE, &result) == lwc_error_ok);
+ fail_unless(result == true, "'one' != 'ONE' (caseless) ?!");
+ fail_unless(lwc_string_tolower(new_ONE, &new_one) == lwc_error_ok);
+ fail_unless(lwc_string_isequal(intern_one, new_ONE, &result) == lwc_error_ok);
+ fail_unless(result == false, "'one' == 'ONE' ?!");
+ fail_unless(lwc_string_isequal(intern_one, new_one, &result) == lwc_error_ok);
+ fail_unless(result == true, "'one' != 'one' ?!");
+}
+END_TEST
+
static void
counting_cb(lwc_string *str, void *pw)
{
@@ -368,6 +419,12 @@ lwc_basic_suite(SRunner *sr)
test_lwc_intern_substring_aborts2,
SIGABRT);
tcase_add_test_raise_signal(tc_basic,
+ test_lwc_string_tolower_aborts1,
+ SIGABRT);
+ tcase_add_test_raise_signal(tc_basic,
+ test_lwc_string_tolower_aborts2,
+ SIGABRT);
+ tcase_add_test_raise_signal(tc_basic,
test_lwc_string_ref_aborts,
SIGABRT);
tcase_add_test_raise_signal(tc_basic,
@@ -408,6 +465,8 @@ lwc_basic_suite(SRunner *sr)
tcase_add_test(tc_basic, test_lwc_string_caseless_isequal_ok1);
tcase_add_test(tc_basic, test_lwc_string_caseless_isequal_ok2);
tcase_add_test(tc_basic, test_lwc_string_caseless_isequal_bad);
+ tcase_add_test(tc_basic, test_lwc_string_tolower_ok1);
+ tcase_add_test(tc_basic, test_lwc_string_tolower_ok2);
tcase_add_test(tc_basic, test_lwc_extract_data_ok);
tcase_add_test(tc_basic, test_lwc_string_hash_value_ok);
tcase_add_test(tc_basic, test_lwc_string_is_nul_terminated);