aboutsummaryrefslogtreecommitdiff
path: root/tests/test_str_tolower_s.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-05-24 10:52:57 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-05-24 10:52:57 -0400
commite50cbd51e06912810016142307fc67c7703bcd36 (patch)
tree78c3db85f1b4bc5635f00f2cdb6e50d4dc2e36f9 /tests/test_str_tolower_s.c
parentd5354e6059979054fdfae6caf173617170910b41 (diff)
downloadspmc-e50cbd51e06912810016142307fc67c7703bcd36.tar.gz
Add tests for:
* isdigit_s * tolower_s * version_* functions
Diffstat (limited to 'tests/test_str_tolower_s.c')
-rw-r--r--tests/test_str_tolower_s.c25
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