}
TEST(path) {
+ assert_se(!path_is_absolute(NULL));
+ assert_se(!path_is_absolute(""));
assert_se( path_is_absolute("/"));
+ assert_se( path_is_absolute("//"));
assert_se(!path_is_absolute("./"));
+ assert_se(!path_is_absolute("foo/bar"));
assert_se( PATH_IN_SET("/bin", "/", "/bin", "/foo"));
assert_se( PATH_IN_SET("/bin", "/bin"));
assert_se(!path_equal(NULL, "a"));
}
+TEST(path_is_normalized) {
+ assert_se( path_is_normalized("/"));
+ assert_se( path_is_normalized("/usr/bin"));
+ assert_se( path_is_normalized("usr/bin"));
+
+ assert_se(!path_is_normalized(""));
+ assert_se(!path_is_normalized("."));
+ assert_se(!path_is_normalized("./usr/bin"));
+ assert_se(!path_is_normalized("/usr//bin"));
+ assert_se(!path_is_normalized("/usr/./bin"));
+ assert_se(!path_is_normalized("/usr/bin/."));
+ assert_se(!path_is_normalized("../usr/bin"));
+ assert_se(!path_is_normalized("/usr/../bin"));
+}
+
TEST(is_path) {
assert_se(!is_path("foo"));
assert_se(!is_path("dos.ext"));
test_path_startswith_one("/foo/bar/barfoo/", "/foo/bar/barfo", NULL, NULL);
test_path_startswith_one("/foo/bar/barfoo/", "/foo/bar/bar", NULL, NULL);
test_path_startswith_one("/foo/bar/barfoo/", "/fo", NULL, NULL);
+ test_path_startswith_one("/usr/binary", "/usr/bin", NULL, NULL);
+ test_path_startswith_one("/foo/barista", "/foo/bar", NULL, NULL);
+ test_path_startswith_one("foo/barista", "foo/bar", NULL, NULL);
}
static void test_path_startswith_return_leading_slash_one(const char *path, const char *prefix, const char *expected) {