diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-03-05 15:53:21 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-03-06 22:08:36 +0100 |
commit | b950412ca3a91aa37349cf51ebe98cc84767d448 (patch) | |
tree | e3bb062114d019984321a5a21b29818c88c36795 /tests/filename_sane.c | |
parent | 3fc6bf24b5cc071fc323f08ece541e37578f6369 (diff) |
Cleanup: add some structure to the test directory
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/filename_sane.c')
-rw-r--r-- | tests/filename_sane.c | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/tests/filename_sane.c b/tests/filename_sane.c deleted file mode 100644 index 86270b3..0000000 --- a/tests/filename_sane.c +++ /dev/null @@ -1,93 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * filename_sane.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" -#include "fstree.h" -#include "test.h" - -static const char *must_work[] = { - "foobar", - "test.txt", -#if !defined(_WIN32) && !defined(__WINDOWS__) && !defined(TEST_WIN32) - "\\foo", "foo\\", "foo\\bar", -#endif - NULL, -}; - -static const char *must_not_work[] = { - ".", - "..", - "/foo", - "foo/", - "foo/bar", - NULL, -}; - -static const char *must_not_work_here[] = { -#if defined(_WIN32) || defined(__WINDOWS__) || defined(TEST_WIN32) - "\\foo", "foo\\", "foo\\bar", - "fo<o", "fo>o", "fo:o", "fo\"o", - "fo|o", "fo?o", "fo*o", "fo\ro", - "CON", "PRN", "AUX", "NUL", - "COM1", "COM2", "LPT1", "LPT2", - "con", "prn", "aux", "nul", - "com1", "com2", "lpt1", "lpt2", - "AUX.txt", "aux.txt", "NUL.txt", "nul.txt", -#endif - NULL, -}; - -int main(void) -{ - size_t i; - - for (i = 0; must_work[i] != NULL; ++i) { - if (!is_filename_sane(must_work[i], false)) { - fprintf(stderr, "%s was rejected!\n", must_work[i]); - return EXIT_FAILURE; - } - - if (!is_filename_sane(must_work[i], true)) { - fprintf(stderr, - "%s was rejected when testing for " - "OS specific stuff!\n", must_work[i]); - return EXIT_FAILURE; - } - } - - for (i = 0; must_not_work[i] != NULL; ++i) { - if (is_filename_sane(must_not_work[i], false)) { - fprintf(stderr, "%s was accepted!\n", - must_not_work[i]); - return EXIT_FAILURE; - } - - if (is_filename_sane(must_not_work[i], true)) { - fprintf(stderr, - "%s was accepted when testing for " - "OS specific stuff!\n", must_not_work[i]); - return EXIT_FAILURE; - } - } - - for (i = 0; must_not_work_here[i] != NULL; ++i) { - if (!is_filename_sane(must_not_work_here[i], false)) { - fprintf(stderr, - "%s was rejected in the generic test!\n", - must_not_work_here[i]); - return EXIT_FAILURE; - } - - if (is_filename_sane(must_not_work_here[i], true)) { - fprintf(stderr, - "%s was accepted when testing for " - "OS specific stuff!\n", must_not_work_here[i]); - return EXIT_FAILURE; - } - } - - return EXIT_SUCCESS; -} |