OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 }; | 1037 }; |
1038 | 1038 |
1039 for (size_t i = 0; i < arraysize(cases); ++i) { | 1039 for (size_t i = 0; i < arraysize(cases); ++i) { |
1040 FilePath input(cases[i].input); | 1040 FilePath input(cases[i].input); |
1041 bool observed = input.ReferencesParent(); | 1041 bool observed = input.ReferencesParent(); |
1042 EXPECT_EQ(cases[i].expected, observed) << | 1042 EXPECT_EQ(cases[i].expected, observed) << |
1043 "i: " << i << ", input: " << input.value(); | 1043 "i: " << i << ", input: " << input.value(); |
1044 } | 1044 } |
1045 } | 1045 } |
1046 | 1046 |
1047 TEST_F(FilePathTest, FromUTF8) { | |
1048 FilePath path = FilePath::FromUTF8("foo.txt"); | |
1049 EXPECT_EQ(FPL("foo.txt"), path.value()); | |
1050 } | |
1051 | |
1052 TEST_F(FilePathTest, AsUTF8) { | |
1053 FilePath path(FPL("foo.txt")); | |
1054 EXPECT_EQ("foo.txt", path.AsUTF8()); | |
jungshik at Google
2011/10/31 21:29:03
Would you consider adding some non-trivial cases h
| |
1055 } | |
1056 | |
1047 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 1057 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
1048 TEST_F(FilePathTest, NormalizeWindowsPathSeparators) { | 1058 TEST_F(FilePathTest, NormalizeWindowsPathSeparators) { |
1049 const struct UnaryTestData cases[] = { | 1059 const struct UnaryTestData cases[] = { |
1050 { FPL("foo/bar"), FPL("foo\\bar") }, | 1060 { FPL("foo/bar"), FPL("foo\\bar") }, |
1051 { FPL("foo/bar\\betz"), FPL("foo\\bar\\betz") }, | 1061 { FPL("foo/bar\\betz"), FPL("foo\\bar\\betz") }, |
1052 { FPL("foo\\bar"), FPL("foo\\bar") }, | 1062 { FPL("foo\\bar"), FPL("foo\\bar") }, |
1053 { FPL("foo\\bar/betz"), FPL("foo\\bar\\betz") }, | 1063 { FPL("foo\\bar/betz"), FPL("foo\\bar\\betz") }, |
1054 { FPL("foo"), FPL("foo") }, | 1064 { FPL("foo"), FPL("foo") }, |
1055 // Trailing slashes don't automatically get stripped. That's what | 1065 // Trailing slashes don't automatically get stripped. That's what |
1056 // StripTrailingSeparators() is for. | 1066 // StripTrailingSeparators() is for. |
(...skipping 22 matching lines...) Expand all Loading... | |
1079 { FPL("foo/\\bar/\\"), FPL("foo\\\\bar\\\\") }, | 1089 { FPL("foo/\\bar/\\"), FPL("foo\\\\bar\\\\") }, |
1080 { FPL("/\\foo\\/bar"), FPL("\\\\foo\\\\bar") }, | 1090 { FPL("/\\foo\\/bar"), FPL("\\\\foo\\\\bar") }, |
1081 }; | 1091 }; |
1082 for (size_t i = 0; i < arraysize(cases); ++i) { | 1092 for (size_t i = 0; i < arraysize(cases); ++i) { |
1083 FilePath input(cases[i].input); | 1093 FilePath input(cases[i].input); |
1084 FilePath observed = input.NormalizeWindowsPathSeparators(); | 1094 FilePath observed = input.NormalizeWindowsPathSeparators(); |
1085 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) << | 1095 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) << |
1086 "i: " << i << ", input: " << input.value(); | 1096 "i: " << i << ", input: " << input.value(); |
1087 } | 1097 } |
1088 } | 1098 } |
1099 | |
1089 #endif | 1100 #endif |
OLD | NEW |