diff options
Diffstat (limited to 'tests/test_str_tolower_s.c')
-rw-r--r-- | tests/test_str_tolower_s.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_str_tolower_s.c b/tests/test_str_tolower_s.c new file mode 100644 index 0000000..f36b23d --- /dev/null +++ b/tests/test_str_tolower_s.c @@ -0,0 +1,25 @@ +#include "spm.h" +#include "framework.h" + +const char *testFmt = "case '%s': returned '%d', expected '%d'\n"; +struct TestCase testCase[] = { + {.caseValue.str = "ThE", .truthValue.sptr = "the"}, + {.caseValue.str = "KIdS", .truthValue.sptr = "kids"}, + {.caseValue.str = "AREn'T", .truthValue.sptr= "aren't"}, + {.caseValue.str = "aLL", .truthValue.sptr = "all"}, + {.caseValue.str = "RiGHt", .truthValue.sptr = "right"}, + {.caseValue.str = "By", .truthValue.sptr = "by"}, + {.caseValue.str = "THe oFfSpRiNg", .truthValue.sptr = "the offspring"}, +}; +size_t numCases = sizeof(testCase) / sizeof(struct TestCase); + +int main(int argc, char *argv[]) { + for (size_t i = 0; i < numCases; i++) { + char *orig = strdup(testCase[i].caseValue.str); + char *result = tolower_s(testCase[i].caseValue.str); + const char *truth = testCase[i].truthValue.sptr; + myassert(strcmp(result, truth) == 0, testFmt, orig, result, truth); + free(orig); + } + return 0; +}
\ No newline at end of file |