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

Unified Diff: tests/OSPathTest.cpp

Issue 450743002: Add option to dump images from nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move the clear Created 6 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 | « src/utils/SkOSFile.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/OSPathTest.cpp
diff --git a/tests/OSPathTest.cpp b/tests/OSPathTest.cpp
index 1452c3852e499e23aa542f5af1e6917ff064cf42..facc6ad3f70a6020a13a171994f1cc595355eddf 100644
--- a/tests/OSPathTest.cpp
+++ b/tests/OSPathTest.cpp
@@ -10,7 +10,7 @@
#include "Test.h"
/**
- * Test SkOSPath::Join and SkOSPath::Basename.
+ * Test SkOSPath::Join, SkOSPath::Basename, and SkOSPath::Dirname.
* Will use SkOSPath::Join to append filename to dir, test that it works correctly,
* and tests using SkOSPath::Basename on the result.
* @param reporter Reporter for test conditions.
@@ -32,16 +32,28 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir,
// fullName should be the combined size of dir and file, plus one if
// dir did not include the final path separator.
size_t expectedSize = dir.size() + filename.size();
- if (!dir.endsWith(SkPATH_SEPARATOR)) {
+ if (!dir.endsWith(SkPATH_SEPARATOR) && !dir.isEmpty()) {
expectedSize++;
}
REPORTER_ASSERT(reporter, fullName.size() == expectedSize);
SkString basename = SkOSPath::Basename(fullName.c_str());
+ SkString dirname = SkOSPath::Dirname(fullName.c_str());
// basename should be the same as filename
REPORTER_ASSERT(reporter, basename.equals(filename));
+ // dirname should be the same as dir with any trailing seperators removed.
+ // Except when the the string is just "/".
+ SkString strippedDir = dir;
+ while (strippedDir.size() > 2 && strippedDir[strippedDir.size() - 1] == SkPATH_SEPARATOR) {
+ strippedDir.remove(strippedDir.size() - 1, 1);
+ }
+ if (!dirname.equals(strippedDir)) {
+ SkDebugf("OOUCH %s %s %s\n", dir.c_str(), strippedDir.c_str(), dirname.c_str());
+ }
+ REPORTER_ASSERT(reporter, dirname.equals(strippedDir));
+
// basename will not contain a path separator
REPORTER_ASSERT(reporter, !basename.contains(SkPATH_SEPARATOR));
@@ -78,8 +90,16 @@ DEF_TEST(OSPath, reporter) {
SkString empty = SkOSPath::Basename(NULL);
REPORTER_ASSERT(reporter, empty.size() == 0);
+ // File in root dir
+ dir.printf("%c", SkPATH_SEPARATOR);
+ filename.set("file");
+ test_dir_with_file(reporter, dir, filename);
+
+ // Just the root dir
+ filename.reset();
+ test_dir_with_file(reporter, dir, filename);
+
// Test that NULL can be used for the directory and filename.
SkString emptyPath = SkOSPath::Join(NULL, NULL);
- REPORTER_ASSERT(reporter, emptyPath.size() == 1);
- REPORTER_ASSERT(reporter, emptyPath.contains(SkPATH_SEPARATOR));
+ REPORTER_ASSERT(reporter, emptyPath.isEmpty());
}
« no previous file with comments | « src/utils/SkOSFile.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698