aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2015-01-20 02:12:50 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2015-01-20 02:12:50 +0100
commitf6f306d5aebc8399fe8be07230fe886df6bf653f (patch)
tree625f2d6ca0e4eab9d28c2d2c07195b3ee73575df
parent0ad2e70d12143179fafcfba924c390fc45527ba9 (diff)
downloadsds-f6f306d5aebc8399fe8be07230fe886df6bf653f.tar.xz
test: Add sdstoupper/sdstolower tests
Taken from https://github.com/ZheYuan/sds/commit/1970dec9ab13cecb8 by @ZheYuan
-rw-r--r--test/test.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test.c b/test/test.c
index bb3f64f..243826e 100644
--- a/test/test.c
+++ b/test/test.c
@@ -26,6 +26,8 @@ bool sdsMakeRoomFor_test (void);
bool sdsIncrLen_content (void);
bool sdsIncrLen_len (void);
bool sdsIncrLen_free (void);
+bool test_sdstolower (void);
+bool test_sdstoupper (void);
static const struct test test_list [] = {
{ "create a string and obtain the length", check_string_length },
@@ -50,6 +52,8 @@ static const struct test test_list [] = {
{ "content after sdsIncrLen()", sdsIncrLen_content },
{ "len after sdsIncrLen()", sdsIncrLen_len },
{ "free after sdsIncrLen()", sdsIncrLen_free },
+ { "sdstolower()", test_sdstolower },
+ { "sdstoupper()", test_sdstoupper },
};
static inline void sdsfrees(sds *string) { if (*string) sdsfree(*string); }
@@ -221,3 +225,17 @@ sdsIncrLen_free (void) {
sdsIncrLen(x, 1);
return (sh->free == oldfree-1);
}
+
+bool
+test_sdstolower (void) {
+ _sds_cleanup_ sds x = sdsauto("0FoO1bar\n");
+ sdstolower(x);
+ return memcmp(x, "0foo1bar\n\0", 10) == 0;
+}
+
+bool
+test_sdstoupper (void) {
+ _sds_cleanup_ sds x = sdsauto("0FoO1bar\n");
+ sdstoupper(x);
+ return memcmp(x, "0FOO1BAR\n\0", 10) == 0;
+}