From e50cbd51e06912810016142307fc67c7703bcd36 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 24 May 2020 10:52:57 -0400 Subject: Add tests for: * isdigit_s * tolower_s * version_* functions --- tests/test_str_isdigit_s.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/test_str_isdigit_s.c (limited to 'tests/test_str_isdigit_s.c') diff --git a/tests/test_str_isdigit_s.c b/tests/test_str_isdigit_s.c new file mode 100644 index 0000000..5dd729c --- /dev/null +++ b/tests/test_str_isdigit_s.c @@ -0,0 +1,21 @@ +#include "spm.h" +#include "framework.h" + +const char *testFmt = "case '%s': returned '%d', expected '%d'\n"; +struct TestCase testCase[] = { + {.caseValue.str = "1234", .truthValue.signed_int = 1}, + {.caseValue.str = "1234000000000", .truthValue.signed_int = 1}, + {.caseValue.str = "1234aa", .truthValue.signed_int = 0}, + {.caseValue.str = "z1234a", .truthValue.signed_int = 0}, + {.caseValue.str = "gabcde", .truthValue.signed_int = 0}, +}; +size_t numCases = sizeof(testCase) / sizeof(struct TestCase); + +int main(int argc, char *argv[]) { + for (size_t i = 0; i < numCases; i++) { + int result = isdigit_s(testCase[i].caseValue.str); + int truth = testCase[i].truthValue.signed_int; + myassert(result == truth, testFmt, testCase[i].caseValue.str, result, truth); + } + return 0; +} \ No newline at end of file -- cgit