Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1654)

Unified Diff: base/file_path_unittest.cc

Issue 172012: Add "bool FilePath::ReferencesParent()" which adds a clean & simple way for... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_path.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_path_unittest.cc
===================================================================
--- base/file_path_unittest.cc (revision 23136)
+++ base/file_path_unittest.cc (working copy)
@@ -535,7 +535,6 @@
b.value();
}
-
for (size_t i = 0; i < arraysize(cases); ++i) {
FilePath a(cases[i].inputs[0]);
FilePath b(cases[i].inputs[1]);
@@ -734,3 +733,35 @@
"i: " << i << ", path: " << path.value() << ", ext: " << ext;
}
}
+
+TEST_F(FilePathTest, ReferencesParent) {
+ const struct UnaryBooleanTestData cases[] = {
+ { FPL("."), false },
+ { FPL(".."), true },
+ { FPL("a.."), false },
+ { FPL("..a"), false },
+ { FPL("../"), true },
+ { FPL("/.."), true },
+ { FPL("/../"), true },
+ { FPL("/a../"), false },
+ { FPL("/..a/"), false },
+ { FPL("//.."), true },
+ { FPL("..//"), true },
+ { FPL("//..//"), true },
+ { FPL("a//..//c"), true },
+ { FPL("../b/c"), true },
+ { FPL("/../b/c"), true },
+ { FPL("a/b/.."), true },
+ { FPL("a/b/../"), true },
+ { FPL("a/../c"), true },
+ { FPL("a/b/c"), false },
+ };
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ FilePath input(cases[i].input);
+ bool observed = input.ReferencesParent();
+ EXPECT_EQ(cases[i].expected, observed) <<
+ "i: " << i << ", input: " << input.value();
+ }
+}
+
« no previous file with comments | « base/file_path.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698