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

Side by Side Diff: base/file_path_unittest.cc

Issue 272039: Add FilePathTest.StripTrailingSeparator to base_unittests to test FilePath::StripTrailingSeparator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | « no previous file | 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 std::string ascii = WideToASCII(leaf); 305 std::string ascii = WideToASCII(leaf);
306 #elif defined(OS_POSIX) 306 #elif defined(OS_POSIX)
307 std::string ascii = leaf; 307 std::string ascii = leaf;
308 #endif 308 #endif
309 observed_str = root.AppendASCII(ascii); 309 observed_str = root.AppendASCII(ascii);
310 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed_str.value()) << 310 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed_str.value()) <<
311 "i: " << i << ", root: " << root.value() << ", leaf: " << leaf; 311 "i: " << i << ", root: " << root.value() << ", leaf: " << leaf;
312 } 312 }
313 } 313 }
314 314
315 TEST_F(FilePathTest, StripTrailingSeparators) {
316 const struct UnaryTestData cases[] = {
317 { FPL(""), FPL("") },
318 { FPL("/"), FPL("/") },
319 { FPL("//"), FPL("//") },
Erik does not do reviews 2009/10/13 16:57:01 is this use case for windows network paths using /
320 { FPL("///"), FPL("/") },
321 { FPL("////"), FPL("/") },
322 { FPL("a/"), FPL("a") },
323 { FPL("a//"), FPL("a") },
324 { FPL("a///"), FPL("a") },
325 { FPL("a////"), FPL("a") },
326 { FPL("/a"), FPL("/a") },
327 { FPL("/a/"), FPL("/a") },
328 { FPL("/a//"), FPL("/a") },
329 { FPL("/a///"), FPL("/a") },
330 { FPL("/a////"), FPL("/a") },
331 #if defined(FILE_PATH_USES_DRIVE_LETTERS)
332 { FPL("c:"), FPL("c:") },
333 { FPL("c:/"), FPL("c:/") },
334 { FPL("c://"), FPL("c://") },
Erik does not do reviews 2009/10/13 16:57:01 just curious, what is this use case for?
335 { FPL("c:///"), FPL("c:/") },
336 { FPL("c:////"), FPL("c:/") },
337 { FPL("c:/a"), FPL("c:/a") },
338 { FPL("c:/a/"), FPL("c:/a") },
339 { FPL("c:/a//"), FPL("c:/a") },
340 { FPL("c:/a///"), FPL("c:/a") },
341 { FPL("c:/a////"), FPL("c:/a") },
342 #endif // FILE_PATH_USES_DRIVE_LETTERS
343 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
344 { FPL("\\"), FPL("\\") },
345 { FPL("\\\\"), FPL("\\\\") },
346 { FPL("\\\\\\"), FPL("\\") },
347 { FPL("\\\\\\\\"), FPL("\\") },
348 { FPL("a\\"), FPL("a") },
349 { FPL("a\\\\"), FPL("a") },
350 { FPL("a\\\\\\"), FPL("a") },
351 { FPL("a\\\\\\\\"), FPL("a") },
352 { FPL("\\a"), FPL("\\a") },
353 { FPL("\\a\\"), FPL("\\a") },
354 { FPL("\\a\\\\"), FPL("\\a") },
355 { FPL("\\a\\\\\\"), FPL("\\a") },
356 { FPL("\\a\\\\\\\\"), FPL("\\a") },
357 #if defined(FILE_PATH_USES_DRIVE_LETTERS)
358 { FPL("c:\\"), FPL("c:\\") },
359 { FPL("c:\\\\"), FPL("c:\\\\") },
360 { FPL("c:\\\\\\"), FPL("c:\\") },
361 { FPL("c:\\\\\\\\"), FPL("c:\\") },
362 { FPL("c:\\a"), FPL("c:\\a") },
363 { FPL("c:\\a\\"), FPL("c:\\a") },
364 { FPL("c:\\a\\\\"), FPL("c:\\a") },
365 { FPL("c:\\a\\\\\\"), FPL("c:\\a") },
366 { FPL("c:\\a\\\\\\\\"), FPL("c:\\a") },
367 #endif // FILE_PATH_USES_DRIVE_LETTERS
368 #endif // FILE_PATH_USES_WIN_SEPARATORS
369 };
370
371 for (size_t i = 0; i < arraysize(cases); ++i) {
372 FilePath input(cases[i].input);
373 FilePath observed = input.StripTrailingSeparators();
374 EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) <<
375 "i: " << i << ", input: " << input.value();
376 }
377 }
378
315 TEST_F(FilePathTest, IsAbsolute) { 379 TEST_F(FilePathTest, IsAbsolute) {
316 const struct UnaryBooleanTestData cases[] = { 380 const struct UnaryBooleanTestData cases[] = {
317 { FPL(""), false }, 381 { FPL(""), false },
318 { FPL("a"), false }, 382 { FPL("a"), false },
319 { FPL("c:"), false }, 383 { FPL("c:"), false },
320 { FPL("c:a"), false }, 384 { FPL("c:a"), false },
321 { FPL("a/b"), false }, 385 { FPL("a/b"), false },
322 { FPL("//"), true }, 386 { FPL("//"), true },
323 { FPL("//a"), true }, 387 { FPL("//a"), true },
324 { FPL("c:a/b"), false }, 388 { FPL("c:a/b"), false },
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 }; 902 };
839 903
840 for (size_t i = 0; i < arraysize(cases); ++i) { 904 for (size_t i = 0; i < arraysize(cases); ++i) {
841 FilePath input(cases[i].input); 905 FilePath input(cases[i].input);
842 bool observed = input.ReferencesParent(); 906 bool observed = input.ReferencesParent();
843 EXPECT_EQ(cases[i].expected, observed) << 907 EXPECT_EQ(cases[i].expected, observed) <<
844 "i: " << i << ", input: " << input.value(); 908 "i: " << i << ", input: " << input.value();
845 } 909 }
846 } 910 }
847 911
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698