From f6f306d5aebc8399fe8be07230fe886df6bf653f Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Tue, 20 Jan 2015 02:12:50 +0100 Subject: test: Add sdstoupper/sdstolower tests Taken from https://github.com/ZheYuan/sds/commit/1970dec9ab13cecb8 by @ZheYuan --- test/test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; +} -- cgit v1.2.3-70-g09d2