diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2020-04-14 01:31:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 01:31:46 -0400 |
commit | b266c1a943c3aee2d3aea05141fb2f21f9ea168b (patch) | |
tree | 99eecfeb2b63f34dc1b3d279264eca49d9b16043 /tests/test_fs_touch.c | |
parent | f04a13fd4b7c665dfecdeaef82e2ab628d6f402d (diff) | |
parent | 9dca29e8cc93aef68f638a06c19f4165dfc32e3d (diff) | |
download | spmc-b266c1a943c3aee2d3aea05141fb2f21f9ea168b.tar.gz |
Merge pull request #23 from jhunkeler/touch-fslist
Add functions w/ tests
Diffstat (limited to 'tests/test_fs_touch.c')
-rw-r--r-- | tests/test_fs_touch.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_fs_touch.c b/tests/test_fs_touch.c new file mode 100644 index 0000000..dfd7ddb --- /dev/null +++ b/tests/test_fs_touch.c @@ -0,0 +1,31 @@ +#include "spm.h" +#include "framework.h" + +#define FILENAME "touched_file" + +const char *testFmt = "case: '%s': returned '%d', expected '%d'\n"; +struct TestCase testCase[] = { + {.caseValue.sptr = FILENAME, .truthValue.signed_integer = 0}, // create file + {.caseValue.sptr = FILENAME, .truthValue.signed_integer = 0}, // update file + {.caseValue.sptr = FILENAME, .truthValue.signed_integer = 0}, // update file + {.caseValue.sptr = ".", .truthValue.signed_integer = -1}, +}; +size_t numCases = sizeof(testCase) / sizeof(struct TestCase); + +static void cleanup() { + if (access(FILENAME, F_OK) == 0) { + unlink(FILENAME); + } +} + +int main(int argc, char *argv[]) { + cleanup(); + + for (size_t i = 0; i < numCases; i++) { + int result = touch(testCase[i].caseValue.sptr); + myassert(result == testCase[i].truthValue.signed_integer, testFmt, testCase[i].caseValue.sptr, result, testCase[i].truthValue.signed_integer); + } + + cleanup(); + return 0; +}
\ No newline at end of file |