aboutsummaryrefslogtreecommitdiff
path: root/tests/canonicalize_name.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-05 15:53:21 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-06 22:08:36 +0100
commitb950412ca3a91aa37349cf51ebe98cc84767d448 (patch)
treee3bb062114d019984321a5a21b29818c88c36795 /tests/canonicalize_name.c
parent3fc6bf24b5cc071fc323f08ece541e37578f6369 (diff)
Cleanup: add some structure to the test directory
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/canonicalize_name.c')
-rw-r--r--tests/canonicalize_name.c77
1 files changed, 0 insertions, 77 deletions
diff --git a/tests/canonicalize_name.c b/tests/canonicalize_name.c
deleted file mode 100644
index 2ab73a0..0000000
--- a/tests/canonicalize_name.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * canonicalize_name.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-#include "fstree.h"
-#include "test.h"
-
-static const struct {
- const char *in;
- const char *out;
-} must_work[] = {
- { "", "" },
- { "/", "" },
- { "\\", "\\" },
- { "///", "" },
- { "\\\\\\", "\\\\\\" },
- { "/\\//\\\\/", "\\/\\\\" },
- { "foo/bar/test", "foo/bar/test" },
- { "foo\\bar\\test", "foo\\bar\\test" },
- { "/foo/bar/test/", "foo/bar/test" },
- { "\\foo\\bar\\test\\", "\\foo\\bar\\test\\" },
- { "///foo//bar//test///", "foo/bar/test" },
- { "./foo/././bar/test/./.", "foo/bar/test" },
- { "./foo/././", "foo" },
- { ".", "" },
- { "./", "" },
- { "./.", "" },
- { "foo/.../bar", "foo/.../bar" },
- { "foo/.test/bar", "foo/.test/bar" },
-};
-
-static const char *must_not_work[] = {
- "..",
- "foo/../bar",
- "../foo/bar",
- "foo/bar/..",
- "foo/bar/../",
-};
-
-int main(void)
-{
- char buffer[512];
- size_t i;
-
- for (i = 0; i < sizeof(must_work) / sizeof(must_work[0]); ++i) {
- strcpy(buffer, must_work[i].in);
-
- if (canonicalize_name(buffer)) {
- fprintf(stderr, "Test case rejected: '%s'\n",
- must_work[i].in);
- return EXIT_FAILURE;
- }
-
- if (strcmp(buffer, must_work[i].out) != 0) {
- fprintf(stderr, "Expected result: %s\n",
- must_work[i].out);
- fprintf(stderr, "Actual result: %s\n", buffer);
- return EXIT_FAILURE;
- }
- }
-
- for (i = 0; i < sizeof(must_not_work) / sizeof(must_not_work[0]); ++i) {
- strcpy(buffer, must_not_work[i]);
-
- if (canonicalize_name(buffer) == 0) {
- fprintf(stderr, "Test case accepted: '%s'\n",
- must_not_work[i]);
- fprintf(stderr, "Transformed into: '%s'\n", buffer);
- return EXIT_FAILURE;
- }
- }
-
- return EXIT_SUCCESS;
-}