aboutsummaryrefslogtreecommitdiff
path: root/tests/test_str_tolower_s.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2020-05-24 13:25:01 -0400
committerGitHub <noreply@github.com>2020-05-24 13:25:01 -0400
commitc205840e737b23614a686a9675b896106cee5c64 (patch)
treef2eb9d93edb1540221daea3682bf13254d28128c /tests/test_str_tolower_s.c
parent03e39ae5dcd4002ac9657a550c48b8e9f85c449c (diff)
parenta38fbb5766b48a9695ea139f79634fc746642bdd (diff)
downloadspmc-c205840e737b23614a686a9675b896106cee5c64.tar.gz
Merge pull request #37 from jhunkeler/version-fixups
Version fixups
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