OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkString.h" | 8 #include "SkString.h" |
9 #include "SkOSFile.h" | 9 #include "SkOSFile.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 static void test_os_path_utils_tests(skiatest::Reporter* reporter) { | 53 static void test_os_path_utils_tests(skiatest::Reporter* reporter) { |
54 SkString dir("dir"); | 54 SkString dir("dir"); |
55 SkString filename("file"); | 55 SkString filename("file"); |
56 test_dir_with_file(reporter, dir, filename); | 56 test_dir_with_file(reporter, dir, filename); |
57 | 57 |
58 // Now make sure this works with a path separator at the end of dir. | 58 // Now make sure this works with a path separator at the end of dir. |
59 dir.appendUnichar(SkPATH_SEPARATOR); | 59 dir.appendUnichar(SkPATH_SEPARATOR); |
60 test_dir_with_file(reporter, dir, filename); | 60 test_dir_with_file(reporter, dir, filename); |
61 | 61 |
| 62 // Test using no filename. |
| 63 test_dir_with_file(reporter, dir, SkString()); |
| 64 |
| 65 // Testing using no directory. |
| 66 test_dir_with_file(reporter, SkString(), filename); |
| 67 |
62 // Test with a sub directory. | 68 // Test with a sub directory. |
63 dir.append("subDir"); | 69 dir.append("subDir"); |
64 test_dir_with_file(reporter, dir, filename); | 70 test_dir_with_file(reporter, dir, filename); |
65 | 71 |
66 // Basename of a directory with a path separator at the end is empty. | 72 // Basename of a directory with a path separator at the end is empty. |
67 dir.appendUnichar(SkPATH_SEPARATOR); | 73 dir.appendUnichar(SkPATH_SEPARATOR); |
68 SkString baseOfDir = SkOSPath::SkBasename(dir.c_str()); | 74 SkString baseOfDir = SkOSPath::SkBasename(dir.c_str()); |
69 REPORTER_ASSERT(reporter, baseOfDir.size() == 0); | 75 REPORTER_ASSERT(reporter, baseOfDir.size() == 0); |
70 | 76 |
71 // Basename of NULL is an empty string. | 77 // Basename of NULL is an empty string. |
72 SkString empty = SkOSPath::SkBasename(NULL); | 78 SkString empty = SkOSPath::SkBasename(NULL); |
73 REPORTER_ASSERT(reporter, empty.size() == 0); | 79 REPORTER_ASSERT(reporter, empty.size() == 0); |
| 80 |
| 81 // Test that NULL can be used for the directory and filename. |
| 82 SkString emptyPath = SkOSPath::SkPathJoin(NULL, NULL); |
| 83 REPORTER_ASSERT(reporter, emptyPath.size() == 1); |
| 84 REPORTER_ASSERT(reporter, emptyPath.contains(SkPATH_SEPARATOR)); |
74 } | 85 } |
75 | 86 |
76 #include "TestClassDef.h" | 87 #include "TestClassDef.h" |
77 DEFINE_TESTCLASS("OSPath", OSPathTestClass, test_os_path_utils_tests) | 88 DEFINE_TESTCLASS("OSPath", OSPathTestClass, test_os_path_utils_tests) |
OLD | NEW |