24 EXPECT_EQ(
"empty path", err);
26 path =
"foo.h"; err =
"";
28 EXPECT_EQ(
"foo.h", path);
32 EXPECT_EQ(
"foo.h", path);
34 path =
"./foo/./bar.h";
36 EXPECT_EQ(
"foo/bar.h", path);
38 path =
"./x/foo/../bar.h";
40 EXPECT_EQ(
"x/bar.h", path);
42 path =
"./x/foo/../../bar.h";
44 EXPECT_EQ(
"bar.h", path);
48 EXPECT_EQ(
"foo/bar", path);
50 path =
"foo//.//..///bar";
52 EXPECT_EQ(
"bar", path);
54 path =
"./x/../foo/../../bar.h";
56 EXPECT_EQ(
"../bar.h", path);
60 EXPECT_EQ(
"foo", path);
64 EXPECT_EQ(
"foo", path);
66 path =
"foo/.hidden_bar";
68 EXPECT_EQ(
"foo/.hidden_bar", path);
72 EXPECT_EQ(
"/foo", path);
77 EXPECT_EQ(
"//foo", path);
79 EXPECT_EQ(
"/foo", path);
92 EXPECT_EQ(
"empty path", err);
96 EXPECT_EQ(
"path canonicalizes to the empty path", err);
100 EXPECT_EQ(
"path canonicalizes to the empty path", err);
105 path =
"../../foo/bar.h";
107 EXPECT_EQ(
"../../foo/bar.h", path);
109 path =
"test/../../foo/bar.h";
111 EXPECT_EQ(
"../foo/bar.h", path);
115 string path =
"/usr/include/stdio.h";
118 EXPECT_EQ(
"/usr/include/stdio.h", path);
126 path =
"foo/. bar/.";
127 len = strlen(
"foo/.");
129 EXPECT_EQ(strlen(
"foo"), len);
130 EXPECT_EQ(
"foo/. bar/.",
string(path));
132 path =
"foo/../file bar/.";
133 len = strlen(
"foo/../file");
135 EXPECT_EQ(strlen(
"file"), len);
136 EXPECT_EQ(
"file ./file bar/.",
string(path));
141 EXPECT_EQ(
"foo", stripped);
144 EXPECT_EQ(
"foo", stripped);
149 string input =
"\33[1maffixmgr.cxx:286:15: \33[0m\33[0;1;35mwarning: "
150 "\33[0m\33[1musing the result... [-Wparentheses]\33[0m";
152 EXPECT_EQ(
"affixmgr.cxx:286:15: warning: using the result... [-Wparentheses]",
157 string input =
"Nothing to elide in this short string.";
162 string input =
"01234567890123456789";
164 EXPECT_EQ(
"012...789", elided);
bool CanonicalizePath(string *path, string *err)
Canonicalize a path like "foo/../bar.h" into just "bar.h".
TEST(CanonicalizePath, PathSamples)
string StripAnsiEscapeCodes(const string &in)
Removes all Ansi escape codes (http://www.termsys.demon.co.uk/vtansi.htm).
string ElideMiddle(const string &str, size_t width)
Elide the given string str with '...' in the middle if the length exceeds width.