Lines Matching refs:path

66 // Test cases for the "path" class.
72 set_md_var("descr", "Tests the path's normalization");
76 using atf::fs::path;
78 ATF_REQUIRE_EQ(path(".").str(), ".");
79 ATF_REQUIRE_EQ(path("..").str(), "..");
81 ATF_REQUIRE_EQ(path("foo").str(), "foo");
82 ATF_REQUIRE_EQ(path("foo/bar").str(), "foo/bar");
83 ATF_REQUIRE_EQ(path("foo/bar/").str(), "foo/bar");
85 ATF_REQUIRE_EQ(path("/foo").str(), "/foo");
86 ATF_REQUIRE_EQ(path("/foo/bar").str(), "/foo/bar");
87 ATF_REQUIRE_EQ(path("/foo/bar/").str(), "/foo/bar");
89 ATF_REQUIRE_EQ(path("///foo").str(), "/foo");
90 ATF_REQUIRE_EQ(path("///foo///bar").str(), "/foo/bar");
91 ATF_REQUIRE_EQ(path("///foo///bar///").str(), "/foo/bar");
97 set_md_var("descr", "Tests the path::is_absolute function");
101 using atf::fs::path;
103 ATF_REQUIRE( path("/").is_absolute());
104 ATF_REQUIRE( path("////").is_absolute());
105 ATF_REQUIRE( path("////a").is_absolute());
106 ATF_REQUIRE( path("//a//").is_absolute());
107 ATF_REQUIRE(!path("a////").is_absolute());
108 ATF_REQUIRE(!path("../foo").is_absolute());
114 set_md_var("descr", "Tests the path::is_root function");
118 using atf::fs::path;
120 ATF_REQUIRE( path("/").is_root());
121 ATF_REQUIRE( path("////").is_root());
122 ATF_REQUIRE(!path("////a").is_root());
123 ATF_REQUIRE(!path("//a//").is_root());
124 ATF_REQUIRE(!path("a////").is_root());
125 ATF_REQUIRE(!path("../foo").is_root());
131 set_md_var("descr", "Tests the path::branch_path function");
135 using atf::fs::path;
137 ATF_REQUIRE_EQ(path(".").branch_path().str(), ".");
138 ATF_REQUIRE_EQ(path("foo").branch_path().str(), ".");
139 ATF_REQUIRE_EQ(path("foo/bar").branch_path().str(), "foo");
140 ATF_REQUIRE_EQ(path("/foo").branch_path().str(), "/");
141 ATF_REQUIRE_EQ(path("/foo/bar").branch_path().str(), "/foo");
147 set_md_var("descr", "Tests the path::leaf_name function");
151 using atf::fs::path;
153 ATF_REQUIRE_EQ(path(".").leaf_name(), ".");
154 ATF_REQUIRE_EQ(path("foo").leaf_name(), "foo");
155 ATF_REQUIRE_EQ(path("foo/bar").leaf_name(), "bar");
156 ATF_REQUIRE_EQ(path("/foo").leaf_name(), "foo");
157 ATF_REQUIRE_EQ(path("/foo/bar").leaf_name(), "bar");
167 using atf::fs::path;
169 ATF_REQUIRE(path("/") == path("///"));
170 ATF_REQUIRE(path("/a") == path("///a"));
171 ATF_REQUIRE(path("/a") == path("///a///"));
173 ATF_REQUIRE(path("a/b/c") == path("a//b//c"));
174 ATF_REQUIRE(path("a/b/c") == path("a//b//c///"));
184 using atf::fs::path;
186 ATF_REQUIRE(path("/") != path("//a/"));
187 ATF_REQUIRE(path("/a") != path("a///"));
189 ATF_REQUIRE(path("a/b/c") != path("a/b"));
190 ATF_REQUIRE(path("a/b/c") != path("a//b"));
191 ATF_REQUIRE(path("a/b/c") != path("/a/b/c"));
192 ATF_REQUIRE(path("a/b/c") != path("/a//b//c"));
202 using atf::fs::path;
204 ATF_REQUIRE_EQ((path("foo") / "bar").str(), "foo/bar");
205 ATF_REQUIRE_EQ((path("foo/") / "/bar").str(), "foo/bar");
206 ATF_REQUIRE_EQ((path("foo/") / "/bar/baz").str(), "foo/bar/baz");
207 ATF_REQUIRE_EQ((path("foo/") / "///bar///baz").str(), "foo/bar/baz");
213 set_md_var("descr", "Tests the conversion of a relative path to an "
219 using atf::fs::path;
224 const path p(".");
225 path pa = p.to_absolute();
235 const path p("files/reg");
236 path pa = p.to_absolute();
249 set_md_var("descr", "Tests that the path's less-than operator works");
253 using atf::fs::path;
257 ATF_REQUIRE(!(path("aaa") < path("aaa")));
259 ATF_REQUIRE( path("aab") < path("abc"));
260 ATF_REQUIRE(!(path("abc") < path("aab")));
276 using atf::fs::path;
280 directory d(path("files"));
298 using atf::fs::path;
302 directory d(path("files"));
327 using atf::fs::path;
331 directory d(path("files"));
352 using atf::fs::path;
357 path p("files/dir");
363 path p("files/reg");
378 using atf::fs::path;
380 path p("file");
453 using atf::fs::path;
457 ATF_REQUIRE( exists(path("files")));
458 ATF_REQUIRE(!exists(path("file")));
459 ATF_REQUIRE(!exists(path("files2")));
461 ATF_REQUIRE( exists(path("files/.")));
462 ATF_REQUIRE( exists(path("files/..")));
463 ATF_REQUIRE( exists(path("files/dir")));
464 ATF_REQUIRE( exists(path("files/reg")));
465 ATF_REQUIRE(!exists(path("files/foo")));
476 using atf::fs::path;
480 ATF_REQUIRE( is_executable(path("files")));
481 ATF_REQUIRE( is_executable(path("files/.")));
482 ATF_REQUIRE( is_executable(path("files/..")));
483 ATF_REQUIRE( is_executable(path("files/dir")));
485 ATF_REQUIRE(!is_executable(path("non-existent")));
487 ATF_REQUIRE(!is_executable(path("files/reg")));
489 ATF_REQUIRE( is_executable(path("files/reg")));
500 using atf::fs::path;
505 ATF_REQUIRE( exists(path("files/reg")));
506 remove(path("files/reg"));
507 ATF_REQUIRE(!exists(path("files/reg")));
509 ATF_REQUIRE( exists(path("files/dir")));
510 ATF_REQUIRE_THROW(atf::system_error, remove(path("files/dir")));
511 ATF_REQUIRE( exists(path("files/dir")));
520 // Add the tests for the "path" class.