1 /*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2023 Adrian Vovk
5 * All rights reserved.
6 */
7 #include "test.h"
8
9 /* Test d arg - extract to target dir - before zipfile argument */
DEFINE_TEST(test_d_before_zipfile)10 DEFINE_TEST(test_d_before_zipfile)
11 {
12 const char *reffile = "test_basic.zip";
13 int r;
14
15 extract_reference_file(reffile);
16 r = systemf("%s -d foobar %s >test.out 2>test.err", testprog, reffile);
17 assertEqualInt(0, r);
18 assertNonEmptyFile("test.out");
19 assertEmptyFile("test.err");
20
21 assertTextFileContents("contents a\n", "foobar/test_basic/a");
22 assertTextFileContents("contents b\n", "foobar/test_basic/b");
23 assertTextFileContents("contents c\n", "foobar/test_basic/c");
24 assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS");
25 }
26
27 /* Test d arg - extract to target dir - after zipfile argument */
DEFINE_TEST(test_d_after_zipfile)28 DEFINE_TEST(test_d_after_zipfile)
29 {
30 const char *reffile = "test_basic.zip";
31 int r;
32
33 extract_reference_file(reffile);
34 r = systemf("%s %s -d foobar >test.out 2>test.err", testprog, reffile);
35 assertEqualInt(0, r);
36 assertNonEmptyFile("test.out");
37 assertEmptyFile("test.err");
38
39 assertTextFileContents("contents a\n", "foobar/test_basic/a");
40 assertTextFileContents("contents b\n", "foobar/test_basic/b");
41 assertTextFileContents("contents c\n", "foobar/test_basic/c");
42 assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS");
43 }
44