diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2020-03-24 12:35:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-24 12:35:30 -0400 |
commit | ae3eb38592cb40011fd026d3c7c64ebc022bedca (patch) | |
tree | 5b576d374cc2d12bc5593c8b09adaa25c4453346 /tests/test_str_strchroff.c | |
parent | ccaeb7092b5ad40b1b3833c987ba3ec4d47f0bb8 (diff) | |
parent | 239251d34af9137acf7e84c6969e118d3b0593c0 (diff) | |
download | spmc-ae3eb38592cb40011fd026d3c7c64ebc022bedca.tar.gz |
Merge pull request #2 from jhunkeler/ctest
Implement ctest testing
Diffstat (limited to 'tests/test_str_strchroff.c')
-rw-r--r-- | tests/test_str_strchroff.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_str_strchroff.c b/tests/test_str_strchroff.c new file mode 100644 index 0000000..805a96d --- /dev/null +++ b/tests/test_str_strchroff.c @@ -0,0 +1,31 @@ +#include "spm.h" +#include "framework.h" + +const char *testFmt = "case '%s': returned %d, expected %d\n"; +struct TestCase testCase[] = { + {.inputValue.unsigned_integer = 'a', .caseValue.sptr = "after the world stops spinning", .truthValue.signed_integer = 0}, + {.inputValue.unsigned_integer = 'p', .caseValue.sptr = "apples exploded all over the place", .truthValue.signed_integer = 1}, + {.inputValue.unsigned_integer = '2', .caseValue.sptr = "a1a2a3a4a z!z@z#z$z a5a6a7a8a9", .truthValue.signed_integer = 3}, + {.inputValue.unsigned_integer = 'a', .caseValue.sptr = "aAaA", .truthValue.signed_integer = 0}, + {.inputValue.unsigned_integer = 'A', .caseValue.sptr = "aAaA", .truthValue.signed_integer = 1}, + {.inputValue.unsigned_integer = 'g', .caseValue.sptr = "abracadabra brisket gumball", .truthValue.signed_integer = 20}, + {.inputValue.unsigned_integer = 'r', .caseValue.sptr = "balloons are falling from the sky", .truthValue.signed_integer = 10}, + {.inputValue.unsigned_integer = 'b', .caseValue.sptr = "mangled mangoes oxidize quickly", .truthValue.signed_integer = -1}, + {.inputValue.unsigned_integer = 'b', .caseValue.sptr = "bBbB", .truthValue.signed_integer = 0}, + {.inputValue.unsigned_integer = 'B', .caseValue.sptr = "bBbB", .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 = strchroff(testCase[i].caseValue.sptr, testCase[i].inputValue.unsigned_integer); + myassert(result == testCase[i].truthValue.signed_integer, + testFmt, + testCase[i].caseValue.sptr, + result, + testCase[i].truthValue.signed_integer); + } + + return 0; +} |