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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_path.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 for (size_t i = 0; i < arraysize(cases); ++i) { 529 for (size_t i = 0; i < arraysize(cases); ++i) {
530 FilePath a(cases[i].inputs[0]); 530 FilePath a(cases[i].inputs[0]);
531 FilePath b(cases[i].inputs[1]); 531 FilePath b(cases[i].inputs[1]);
532 532
533 EXPECT_EQ(a == b, cases[i].expected) << 533 EXPECT_EQ(a == b, cases[i].expected) <<
534 "equality i: " << i << ", a: " << a.value() << ", b: " << 534 "equality i: " << i << ", a: " << a.value() << ", b: " <<
535 b.value(); 535 b.value();
536 } 536 }
537 537
538
539 for (size_t i = 0; i < arraysize(cases); ++i) { 538 for (size_t i = 0; i < arraysize(cases); ++i) {
540 FilePath a(cases[i].inputs[0]); 539 FilePath a(cases[i].inputs[0]);
541 FilePath b(cases[i].inputs[1]); 540 FilePath b(cases[i].inputs[1]);
542 541
543 EXPECT_EQ(a != b, !cases[i].expected) << 542 EXPECT_EQ(a != b, !cases[i].expected) <<
544 "inequality i: " << i << ", a: " << a.value() << ", b: " << 543 "inequality i: " << i << ", a: " << a.value() << ", b: " <<
545 b.value(); 544 b.value();
546 } 545 }
547 } 546 }
548 547
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 }; 726 };
728 727
729 for (size_t i = 0; i < arraysize(cases); ++i) { 728 for (size_t i = 0; i < arraysize(cases); ++i) {
730 FilePath path(cases[i].inputs[0]); 729 FilePath path(cases[i].inputs[0]);
731 FilePath::StringType ext(cases[i].inputs[1]); 730 FilePath::StringType ext(cases[i].inputs[1]);
732 731
733 EXPECT_EQ(cases[i].expected, path.MatchesExtension(ext)) << 732 EXPECT_EQ(cases[i].expected, path.MatchesExtension(ext)) <<
734 "i: " << i << ", path: " << path.value() << ", ext: " << ext; 733 "i: " << i << ", path: " << path.value() << ", ext: " << ext;
735 } 734 }
736 } 735 }
736
737 TEST_F(FilePathTest, ReferencesParent) {
738 const struct UnaryBooleanTestData cases[] = {
739 { FPL("."), false },
740 { FPL(".."), true },
741 { FPL("a.."), false },
742 { FPL("..a"), false },
743 { FPL("../"), true },
744 { FPL("/.."), true },
745 { FPL("/../"), true },
746 { FPL("/a../"), false },
747 { FPL("/..a/"), false },
748 { FPL("//.."), true },
749 { FPL("..//"), true },
750 { FPL("//..//"), true },
751 { FPL("a//..//c"), true },
752 { FPL("../b/c"), true },
753 { FPL("/../b/c"), true },
754 { FPL("a/b/.."), true },
755 { FPL("a/b/../"), true },
756 { FPL("a/../c"), true },
757 { FPL("a/b/c"), false },
758 };
759
760 for (size_t i = 0; i < arraysize(cases); ++i) {
761 FilePath input(cases[i].input);
762 bool observed = input.ReferencesParent();
763 EXPECT_EQ(cases[i].expected, observed) <<
764 "i: " << i << ", input: " << input.value();
765 }
766 }
767
OLDNEW
« 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