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_strdelsuffix.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_strdelsuffix.c')
| -rw-r--r-- | tests/test_str_strdelsuffix.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_str_strdelsuffix.c b/tests/test_str_strdelsuffix.c new file mode 100644 index 0000000..0bc9c85 --- /dev/null +++ b/tests/test_str_strdelsuffix.c @@ -0,0 +1,24 @@ +#include "spm.h" +#include "framework.h" + +const char *testFmt = "could not remove '%s' from '%s', expecting '%s'\n"; +struct TestCase testCase[] = { + {.inputValue.sptr = "gumball", .caseValue.str = "abracadabra brisket gumball", .truthValue.sptr = "abracadabra brisket"}, + {.inputValue.sptr = "y", .caseValue.str = "balloons are falling from the sky", .truthValue.sptr = "balloons are falling from the sk"}, + {.inputValue.sptr = "ickly", .caseValue.str = "mangled mangoes oxidize quickly", .truthValue.sptr = "mangled mangoes oxidize qu"}, + {.inputValue.sptr = "B", .caseValue.str = "bBbB", .truthValue.sptr = "bBb"}, + {.inputValue.sptr = NULL, .caseValue.str = "bBbB", .truthValue.sptr = "bBbB"}, + {.inputValue.sptr = "test", .caseValue.str = "\0", .truthValue.sptr = ""}, + {.inputValue.sptr = NULL, .caseValue.str = "\0", .truthValue.sptr = ""}, +}; +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); + strdelsuffix(testCase[i].caseValue.str, testCase[i].inputValue.sptr); + myassert(strcmp(testCase[i].caseValue.str, testCase[i].truthValue.sptr) == 0, testFmt, testCase[i].inputValue.sptr, orig, testCase[i].truthValue.sptr); + free(orig); + } + return 0; +}
\ No newline at end of file |
