aboutsummaryrefslogtreecommitdiff
path: root/tests/test_str_startswith.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2020-03-24 12:35:30 -0400
committerGitHub <noreply@github.com>2020-03-24 12:35:30 -0400
commitae3eb38592cb40011fd026d3c7c64ebc022bedca (patch)
tree5b576d374cc2d12bc5593c8b09adaa25c4453346 /tests/test_str_startswith.c
parentccaeb7092b5ad40b1b3833c987ba3ec4d47f0bb8 (diff)
parent239251d34af9137acf7e84c6969e118d3b0593c0 (diff)
downloadspmc-ae3eb38592cb40011fd026d3c7c64ebc022bedca.tar.gz
Merge pull request #2 from jhunkeler/ctest
Implement ctest testing
Diffstat (limited to 'tests/test_str_startswith.c')
-rw-r--r--tests/test_str_startswith.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_str_startswith.c b/tests/test_str_startswith.c
new file mode 100644
index 0000000..da25341
--- /dev/null
+++ b/tests/test_str_startswith.c
@@ -0,0 +1,22 @@
+#include "spm.h"
+#include "framework.h"
+
+const char *testFmt = "'%s' does not start with '%s' (%d)\n";
+struct TestCase testCase[] = {
+ {.inputValue.sptr = "abra", .caseValue.sptr = "abracadabra brisket gumball", .truthValue.signed_integer = 1},
+ {.inputValue.sptr = "ball", .caseValue.sptr = "balloons are falling from the sky", .truthValue.signed_integer = 1},
+ {.inputValue.sptr = "mangle", .caseValue.sptr = "mangled mangoes oxidize quickly", .truthValue.signed_integer = 1},
+ {.inputValue.sptr = "b", .caseValue.sptr = "bBbB", .truthValue.signed_integer = 1},
+ {.inputValue.sptr = NULL, .caseValue.sptr = "bBbB", .truthValue.signed_integer = -1},
+ {.inputValue.sptr = "test", .caseValue.sptr = NULL, .truthValue.signed_integer = -1},
+ {.inputValue.sptr = NULL, .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 = startswith(testCase[i].caseValue.sptr, testCase[i].inputValue.sptr);
+ myassert(result == testCase[i].truthValue.signed_integer, testFmt, testCase[i].inputValue.str, testCase[i].truthValue.sptr, result);
+ }
+ return 0;
+} \ No newline at end of file