2
* libdpkg - Debian packaging suite library routines
3
* t-path.c - test path handling code
5
* Copyright © 2009 Guillem Jover <guillem@debian.org>
7
* This is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2,
10
* or (at your option) any later version.
12
* This is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public
18
* License along with dpkg; if not, write to the Free Software
19
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#include <dpkg/test.h>
23
#include <dpkg/path.h>
27
/* Use the test_trim_eq_ref macro to avoid leaking the string and to get
28
* meaningful line numbers from assert. */
29
#define test_trim_eq_ref(p, ref) \
31
char *t = strdup((p)); \
32
path_rtrim_slash_slashdot(t); \
33
test_str(t, ==, (ref)); \
40
test_trim_eq_ref("./././.", ".");
41
test_trim_eq_ref("./././", ".");
42
test_trim_eq_ref("./.", ".");
43
test_trim_eq_ref("./", ".");
44
test_trim_eq_ref("/./././.", "/");
45
test_trim_eq_ref("/./", "/");
46
test_trim_eq_ref("/.", "/");
47
test_trim_eq_ref("/", "/");
48
test_trim_eq_ref("", "");
49
test_trim_eq_ref("/./../.", "/./..");
50
test_trim_eq_ref("/foo/bar/./", "/foo/bar");
51
test_trim_eq_ref("./foo/bar/./", "./foo/bar");
52
test_trim_eq_ref("/./foo/bar/./", "/./foo/bar");
58
test_str(path_skip_slash_dotslash("./././."), ==, ".");
59
test_str(path_skip_slash_dotslash("./././"), ==, "");
60
test_str(path_skip_slash_dotslash("./."), ==, ".");
61
test_str(path_skip_slash_dotslash("./"), ==, "");
62
test_str(path_skip_slash_dotslash("/./././."), ==, ".");
63
test_str(path_skip_slash_dotslash("/./"), ==, "");
64
test_str(path_skip_slash_dotslash("/."), ==, ".");
65
test_str(path_skip_slash_dotslash("/"), ==, "");
66
test_str(path_skip_slash_dotslash("/./../."), ==, "../.");
67
test_str(path_skip_slash_dotslash("/foo/bar/./"), ==, "foo/bar/./");
68
test_str(path_skip_slash_dotslash("./foo/bar/./"), ==, "foo/bar/./");
69
test_str(path_skip_slash_dotslash("/./foo/bar/./"), ==, "foo/bar/./");