From ad07c35f12ca10bd3dfea50aaf8a9db8dcc9f630 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 24 Mar 2020 12:27:33 -0400 Subject: Initial commit of tests --- tests/test_str_isempty.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/test_str_isempty.c (limited to 'tests/test_str_isempty.c') diff --git a/tests/test_str_isempty.c b/tests/test_str_isempty.c new file mode 100644 index 0000000..840b811 --- /dev/null +++ b/tests/test_str_isempty.c @@ -0,0 +1,22 @@ +#include "spm.h" +#include "framework.h" + +const char *testFmt = "case: '%s': returned %d, expected %d\n"; +struct TestCase testCase[] = { + {.caseValue.sptr = " not empty", .truthValue.signed_integer = 0}, + {.caseValue.sptr = "not empty", .truthValue.signed_integer = 0}, + {.caseValue.sptr = " ", .truthValue.signed_integer = 1}, + {.caseValue.sptr = "\t", .truthValue.signed_integer = 1}, + {.caseValue.sptr = "\n", .truthValue.signed_integer = 1}, + {.caseValue.sptr = "", .truthValue.signed_integer = 1}, + {.caseValue.sptr = NULL, .truthValue.signed_integer = -1}, +}; +size_t numCases = sizeof(testCase) / sizeof(struct TestCase); + +int main(int argc, char *argv[]) { + for (size_t i = 0; i < numCases; i++) { + int result = isempty(testCase[i].caseValue.sptr); + myassert(result == testCase[i].truthValue.signed_integer, testFmt, testCase[i].caseValue.sptr, result, testCase[i].truthValue.sptr); + } + return 0; +} \ No newline at end of file -- cgit