diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2020-05-24 13:25:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 13:25:01 -0400 |
commit | c205840e737b23614a686a9675b896106cee5c64 (patch) | |
tree | f2eb9d93edb1540221daea3682bf13254d28128c /tests/test_str_isdigit_s.c | |
parent | 03e39ae5dcd4002ac9657a550c48b8e9f85c449c (diff) | |
parent | a38fbb5766b48a9695ea139f79634fc746642bdd (diff) | |
download | spmc-c205840e737b23614a686a9675b896106cee5c64.tar.gz |
Merge pull request #37 from jhunkeler/version-fixups
Version fixups
Diffstat (limited to 'tests/test_str_isdigit_s.c')
-rw-r--r-- | tests/test_str_isdigit_s.c | 21 |
1 files changed, 21 insertions, 0 deletions
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 |