44 CHECK(result ==
"C:\\");
49 CHECK(result ==
"C:\\");
51 SUBCASE(
"C:\\Documents\\foo.txt") {
54 CHECK(result ==
"C:\\Documents");
59 CHECK(result ==
"C:");
102 CHECK(
split(
"", PathFormat::kWindows) == std::vector<std::string>({}));
103 CHECK(
split(
".", PathFormat::kWindows) == std::vector<std::string>({
"."}));
104 CHECK(
split(
".\\", PathFormat::kWindows) == std::vector<std::string>({
".",
""}));
105 CHECK(
split(
"one\\two\\three", PathFormat::kWindows) == std::vector<std::string>({
"one",
"two",
"three"}));
106 CHECK(
split(
"one\\two\\three\\", PathFormat::kWindows) == std::vector<std::string>({
"one",
"two",
"three",
""}));
107 CHECK(
split(
"one\\two\\\\three\\", PathFormat::kWindows) == std::vector<std::string>({
"one",
"two",
"three",
""}));
108 CHECK(
split(
"C:\\one\\two\\\\three\\", PathFormat::kWindows) == std::vector<std::string>({
"C:",
"\\",
"one",
"two",
"three",
""}));
109 CHECK(
split(
"\\one\\two\\\\three\\", PathFormat::kWindows) == std::vector<std::string>({
"\\",
"one",
"two",
"three",
""}));
110 CHECK(
split(
"C:\\one\\two\\\\three\\", PathFormat::kWindows) == std::vector<std::string>({
"C:",
"\\",
"one",
"two",
"three",
""}));
111 CHECK(
split(
"C:foo\\bar\\", PathFormat::kWindows) == std::vector<std::string>({
"C:",
"foo",
"bar",
""}));
112 CHECK(
split(
"C:\\", PathFormat::kWindows) == std::vector<std::string>({
"C:",
"\\"}));
114 CHECK(
split(
"", PathFormat::kPOSIX) == std::vector<std::string>({}));
115 CHECK(
split(
".", PathFormat::kPOSIX) == std::vector<std::string>({
"."}));
116 CHECK(
split(
"./", PathFormat::kPOSIX) == std::vector<std::string>({
".",
""}));
117 CHECK(
split(
"one/two/three", PathFormat::kPOSIX) == std::vector<std::string>({
"one",
"two",
"three"}));
118 CHECK(
split(
"one/two/three/", PathFormat::kPOSIX) == std::vector<std::string>({
"one",
"two",
"three",
""}));
119 CHECK(
split(
"/two//three/", PathFormat::kPOSIX) == std::vector<std::string>({
"/",
"two",
"three",
""}));
120 CHECK(
split(
"/one/two/three/", PathFormat::kPOSIX) == std::vector<std::string>({
"/",
"one",
"two",
"three",
""}));
121 CHECK(
split(
"/", PathFormat::kPOSIX) == std::vector<std::string>({
"/"}));
125 CHECK(
join({}, PathFormat::kPOSIX) ==
"");
126 CHECK(
join({
"."}, PathFormat::kPOSIX) ==
".");
127 CHECK(
join({
".",
""}, PathFormat::kPOSIX) ==
"./");
128 CHECK(
join({
""}, PathFormat::kPOSIX) ==
"./");
129 CHECK(
join({
"hello"}, PathFormat::kPOSIX) ==
"hello");
130 CHECK(
join({
"hello",
"world"}, PathFormat::kPOSIX) ==
"hello/world");
131 CHECK(
join({
"/hello",
"world"}, PathFormat::kPOSIX) ==
"/hello/world");
132 CHECK(
join({
"/hello/",
"world"}, PathFormat::kPOSIX) ==
"/hello/world");
133 CHECK(
join({
"/",
"hello",
"world"}, PathFormat::kPOSIX) ==
"/hello/world");
134 CHECK(
join({
"..",
".."}, PathFormat::kPOSIX) ==
"../..");
136 CHECK(
join({}, PathFormat::kWindows) ==
"");
137 CHECK(
join({
"."}, PathFormat::kWindows) ==
".");
138 CHECK(
join({
".",
""}, PathFormat::kWindows) ==
".\\");
139 CHECK(
join({
"C:",
""}, PathFormat::kWindows) ==
"C:.\\");
140 CHECK(
join({
"C:",
".",
""}, PathFormat::kWindows) ==
"C:.\\");
141 CHECK(
join({
"hello",
"world"}, PathFormat::kWindows) ==
"hello\\world");
142 CHECK(
join({
"C:\\hello",
"world"}, PathFormat::kWindows) ==
"C:\\hello\\world");
143 CHECK(
join({
"C:\\hello\\",
"world"}, PathFormat::kWindows) ==
"C:\\hello\\world");
144 CHECK(
join({
"C:\\",
"hello",
"world"}, PathFormat::kWindows) ==
"C:\\hello\\world");
145 CHECK(
join({
"C:",
"hello",
"world"}, PathFormat::kWindows) ==
"C:hello\\world");
146 CHECK(
join({
"C:",
"\\",
"hello",
"world"}, PathFormat::kWindows) ==
"C:\\hello\\world");
147 CHECK(
join({
"..",
".."}, PathFormat::kWindows) ==
"..\\..");
150 CHECK(
join({
""}, PathFormat::kWindows) ==
".\\");
151 CHECK(
join({
"\\",
""}, PathFormat::kWindows) ==
"\\");
152 CHECK(
join({
"C:",
""}, PathFormat::kWindows) ==
"C:.\\");
153 CHECK(
join({
"C:",
"\\",
""}, PathFormat::kWindows) ==
"C:\\");
154 CHECK(
join({
"C:",
"\\",
"mnt\\",
""}, PathFormat::kWindows) ==
"C:\\mnt\\");
155 CHECK(
join({
"C:",
"\\",
"mnt",
""}, PathFormat::kWindows) ==
"C:\\mnt\\");
156 CHECK(
join({
""}, PathFormat::kPOSIX) ==
"./");
157 CHECK(
join({
"/",
""}, PathFormat::kPOSIX) ==
"/");
158 CHECK(
join({
"/",
"mnt",
""}, PathFormat::kPOSIX) ==
"/mnt/");
159 CHECK(
join({
"/",
"mnt/",
""}, PathFormat::kPOSIX) ==
"/mnt/");
167 CHECK(
resolve_path(
"/foo/bar/baz",
"/one/two", PathFormat::kPOSIX) ==
"/foo/bar/baz");
187 CHECK(
resolve_path(
"C:\\foo\\bar\\baz",
"", PathFormat::kWindows) ==
"C:\\foo\\bar\\baz");
188 CHECK(
resolve_path(
"C:\\foo\\bar\\baz",
"C:\\one\\two", PathFormat::kWindows) ==
"C:\\foo\\bar\\baz");
190 CHECK(
resolve_path(
"baz",
"C:\\foo\\bar", PathFormat::kWindows) ==
"C:\\foo\\bar\\baz");
191 CHECK(
resolve_path(
"..\\baz",
"D:\\foo\\bar", PathFormat::kWindows) ==
"D:\\foo\\baz");
193 CHECK(
resolve_path(
"..\\..\\..",
"C:\\foo", PathFormat::kWindows) ==
"C:\\..\\..");
195 CHECK(
resolve_path(
"baz",
"\\foo\\bar", PathFormat::kWindows) ==
"\\foo\\bar\\baz");
196 CHECK(
resolve_path(
"..\\baz",
"\\foo\\bar", PathFormat::kWindows) ==
"\\foo\\baz");
200 CHECK(
resolve_path(
"baz",
"\\foo\\bar\\", PathFormat::kWindows) ==
"\\foo\\bar\\baz");
201 CHECK(
resolve_path(
"..\\baz",
"\\foo\\bar\\", PathFormat::kWindows) ==
"\\foo\\baz");
203 CHECK(
resolve_path(
"..\\..\\..",
"\\foo\\", PathFormat::kWindows) ==
"\\..\\..");
205 CHECK(
resolve_path(
"baz",
"C:foo\\bar", PathFormat::kWindows) ==
"C:foo\\bar\\baz");
206 CHECK(
resolve_path(
"..\\baz",
"C:foo\\bar", PathFormat::kWindows) ==
"C:foo\\baz");
219 CHECK(
resolve_path(
"C:\\foo\\bar",
"D:\\baz", PathFormat::kWindows) ==
"C:\\foo\\bar");
221 CHECK(
resolve_path(
"\\foo\\bar",
"D:\\baz", PathFormat::kWindows) ==
"D:\\foo\\bar");
223 CHECK(
resolve_path(
"C:\\foo\\bar",
"D:\\baz", PathFormat::kWindows) ==
"C:\\foo\\bar");
Conveniences for working with paths.
char * epoc_dirname(const char *path)
Compute parent directory of an EPOC directory.
std::vector< std::string > split(const std::string &path, const PathFormat format)
Split a path, path, into its components, using the path separator, separator.
std::string appending_components(const std::string &path, const std::vector< std::string > &components, const PathFormat format)
Convenience wrapper for join that returns a new path resulting from appending path components,...
std::string resolve_path(const std::string &path, const std::string &startingPath, const PathFormat format)
Returns a path by resolving a relative or absolute path against a starting path.
std::string epoc_basename(std::string path)
Returns the last path component of an EPOC path.
std::string join(const std::vector< std::string > &components, const PathFormat format)
Return a new path by joining the path components, components, with path separator,...
static bool is_absolute(const std::vector< std::string > &components, const pathutils::PathFormat format)