44 path =
"./foo/./bar.h";
48 path =
"./x/foo/../bar.h";
52 path =
"./x/foo/../../bar.h";
60 path =
"foo//.//..///bar";
64 path =
"./x/../foo/../../bar.h";
76 path =
"foo/.hidden_bar";
128 path =
".\\foo\\.\\bar.h";
132 path =
".\\x\\foo\\..\\bar.h";
136 path =
".\\x\\foo\\..\\..\\bar.h";
144 path =
"foo\\\\.\\\\..\\\\\\bar";
148 path =
".\\x\\..\\foo\\..\\..\\bar.h";
156 path =
"foo\\bar\\..";
160 path =
"foo\\.hidden_bar";
191 path =
"a/bcd/efh\\foo.h";
196 path =
"a\\bcd/efh\\foo.h";
201 path =
"a\\bcd\\efh\\foo.h";
206 path =
"a/bcd/efh/foo.h";
211 path =
"a\\./efh\\foo.h";
216 path =
"a\\../efh\\foo.h";
221 path =
"a\\b\\c\\d\\e\\f\\g\\foo.h";
226 path =
"a\\b\\c\\..\\..\\..\\g\\foo.h";
231 path =
"a\\b/c\\../../..\\g\\foo.h";
236 path =
"a\\b/c\\./../..\\g\\foo.h";
241 path =
"a\\b/c\\./../..\\g/foo.h";
246 path =
"a\\\\\\foo.h";
251 path =
"a/\\\\foo.h";
264 char buf[] =
"foo/bar\\baz.h\\";
268 EXPECT_EQ(0, strncmp(
"foo/bar/baz.h", buf, size));
277 path =
"a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./" 278 "a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./x.h";
284 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" 285 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" 286 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" 287 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\x.h";
293 path =
"a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./" 294 "a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./x/y.h";
300 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" 301 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" 302 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" 303 "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\x\\y.h";
309 path =
"a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/" 310 "a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/x/y.h";
311 EXPECT_EQ(58, std::count(path.begin(), path.end(),
'/'));
317 "a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\" 318 "a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\" 319 "a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\" 320 "a\\a\\a\\a\\a\\a\\a\\a\\a\\x\\y.h";
321 EXPECT_EQ(58, std::count(path.begin(), path.end(),
'\\'));
323 EXPECT_EQ(slash_bits, 0x3ffffffffffffff);
329 path =
"../../foo/bar.h";
333 path =
"test/../../foo/bar.h";
339 string path =
"/usr/include/stdio.h";
350 path =
"foo/. bar/.";
351 len = strlen(
"foo/.");
356 path =
"foo/../file bar/.";
357 len = strlen(
"foo/../file");
360 EXPECT_EQ(
"file ./file bar/.",
string(path));
363 TEST(PathEscaping, TortureTest) {
367 EXPECT_EQ(
"\"foo bar\\\\\\\"'$@d!st!c'\\path'\\\\\"", result);
371 EXPECT_EQ(
"'foo bar\"/'\\''$@d!st!c'\\''/path'\\'''", result);
374 TEST(PathEscaping, SensiblePathsAreNotNeedlesslyEscaped) {
375 const char* path =
"some/sensible/path/without/crazy/characters.c++";
386 TEST(PathEscaping, SensibleWin32PathsAreNotNeedlesslyEscaped) {
387 const char* path =
"some\\sensible\\path\\without\\crazy\\characters.c++";
404 string input =
"\33[1maffixmgr.cxx:286:15: \33[0m\33[0;1;35mwarning: " 405 "\33[0m\33[1musing the result... [-Wparentheses]\33[0m";
407 EXPECT_EQ(
"affixmgr.cxx:286:15: warning: using the result... [-Wparentheses]",
412 string input =
"Nothing to elide in this short string.";
422 string input =
"01234567890123456789";
void GetWin32EscapedString(const string &input, string *result)
void GetShellEscapedString(const string &input, string *result)
TEST(CanonicalizePath, PathSamples)
string StripAnsiEscapeCodes(const string &in)
void CanonicalizePath(string *path, uint64_t *slash_bits)
unsigned long long uint64_t
string ElideMiddle(const string &str, size_t width)