Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | // Copyright 2008, Google Inc. |
michael@0 | 2 | // All rights reserved. |
michael@0 | 3 | // |
michael@0 | 4 | // Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | // modification, are permitted provided that the following conditions are |
michael@0 | 6 | // met: |
michael@0 | 7 | // |
michael@0 | 8 | // * Redistributions of source code must retain the above copyright |
michael@0 | 9 | // notice, this list of conditions and the following disclaimer. |
michael@0 | 10 | // * Redistributions in binary form must reproduce the above |
michael@0 | 11 | // copyright notice, this list of conditions and the following disclaimer |
michael@0 | 12 | // in the documentation and/or other materials provided with the |
michael@0 | 13 | // distribution. |
michael@0 | 14 | // * Neither the name of Google Inc. nor the names of its |
michael@0 | 15 | // contributors may be used to endorse or promote products derived from |
michael@0 | 16 | // this software without specific prior written permission. |
michael@0 | 17 | // |
michael@0 | 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 29 | // |
michael@0 | 30 | // Authors: keith.ray@gmail.com (Keith Ray) |
michael@0 | 31 | // |
michael@0 | 32 | // Google Test filepath utilities |
michael@0 | 33 | // |
michael@0 | 34 | // This file tests classes and functions used internally by |
michael@0 | 35 | // Google Test. They are subject to change without notice. |
michael@0 | 36 | // |
michael@0 | 37 | // This file is #included from gtest_unittest.cc, to avoid changing |
michael@0 | 38 | // build or make-files for some existing Google Test clients. Do not |
michael@0 | 39 | // #include this file anywhere else! |
michael@0 | 40 | |
michael@0 | 41 | #include "gtest/internal/gtest-filepath.h" |
michael@0 | 42 | #include "gtest/gtest.h" |
michael@0 | 43 | |
michael@0 | 44 | // Indicates that this translation unit is part of Google Test's |
michael@0 | 45 | // implementation. It must come before gtest-internal-inl.h is |
michael@0 | 46 | // included, or there will be a compiler error. This trick is to |
michael@0 | 47 | // prevent a user from accidentally including gtest-internal-inl.h in |
michael@0 | 48 | // his code. |
michael@0 | 49 | #define GTEST_IMPLEMENTATION_ 1 |
michael@0 | 50 | #include "src/gtest-internal-inl.h" |
michael@0 | 51 | #undef GTEST_IMPLEMENTATION_ |
michael@0 | 52 | |
michael@0 | 53 | #if GTEST_OS_WINDOWS_MOBILE |
michael@0 | 54 | # include <windows.h> // NOLINT |
michael@0 | 55 | #elif GTEST_OS_WINDOWS |
michael@0 | 56 | # include <direct.h> // NOLINT |
michael@0 | 57 | #endif // GTEST_OS_WINDOWS_MOBILE |
michael@0 | 58 | |
michael@0 | 59 | namespace testing { |
michael@0 | 60 | namespace internal { |
michael@0 | 61 | namespace { |
michael@0 | 62 | |
michael@0 | 63 | #if GTEST_OS_WINDOWS_MOBILE |
michael@0 | 64 | // TODO(wan@google.com): Move these to the POSIX adapter section in |
michael@0 | 65 | // gtest-port.h. |
michael@0 | 66 | |
michael@0 | 67 | // Windows CE doesn't have the remove C function. |
michael@0 | 68 | int remove(const char* path) { |
michael@0 | 69 | LPCWSTR wpath = String::AnsiToUtf16(path); |
michael@0 | 70 | int ret = DeleteFile(wpath) ? 0 : -1; |
michael@0 | 71 | delete [] wpath; |
michael@0 | 72 | return ret; |
michael@0 | 73 | } |
michael@0 | 74 | // Windows CE doesn't have the _rmdir C function. |
michael@0 | 75 | int _rmdir(const char* path) { |
michael@0 | 76 | FilePath filepath(path); |
michael@0 | 77 | LPCWSTR wpath = String::AnsiToUtf16( |
michael@0 | 78 | filepath.RemoveTrailingPathSeparator().c_str()); |
michael@0 | 79 | int ret = RemoveDirectory(wpath) ? 0 : -1; |
michael@0 | 80 | delete [] wpath; |
michael@0 | 81 | return ret; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | #else |
michael@0 | 85 | |
michael@0 | 86 | TEST(GetCurrentDirTest, ReturnsCurrentDir) { |
michael@0 | 87 | const FilePath original_dir = FilePath::GetCurrentDir(); |
michael@0 | 88 | EXPECT_FALSE(original_dir.IsEmpty()); |
michael@0 | 89 | |
michael@0 | 90 | posix::ChDir(GTEST_PATH_SEP_); |
michael@0 | 91 | const FilePath cwd = FilePath::GetCurrentDir(); |
michael@0 | 92 | posix::ChDir(original_dir.c_str()); |
michael@0 | 93 | |
michael@0 | 94 | # if GTEST_OS_WINDOWS |
michael@0 | 95 | |
michael@0 | 96 | // Skips the ":". |
michael@0 | 97 | const char* const cwd_without_drive = strchr(cwd.c_str(), ':'); |
michael@0 | 98 | ASSERT_TRUE(cwd_without_drive != NULL); |
michael@0 | 99 | EXPECT_STREQ(GTEST_PATH_SEP_, cwd_without_drive + 1); |
michael@0 | 100 | |
michael@0 | 101 | # else |
michael@0 | 102 | |
michael@0 | 103 | EXPECT_STREQ(GTEST_PATH_SEP_, cwd.c_str()); |
michael@0 | 104 | |
michael@0 | 105 | # endif |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | #endif // GTEST_OS_WINDOWS_MOBILE |
michael@0 | 109 | |
michael@0 | 110 | TEST(IsEmptyTest, ReturnsTrueForEmptyPath) { |
michael@0 | 111 | EXPECT_TRUE(FilePath("").IsEmpty()); |
michael@0 | 112 | EXPECT_TRUE(FilePath(NULL).IsEmpty()); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | TEST(IsEmptyTest, ReturnsFalseForNonEmptyPath) { |
michael@0 | 116 | EXPECT_FALSE(FilePath("a").IsEmpty()); |
michael@0 | 117 | EXPECT_FALSE(FilePath(".").IsEmpty()); |
michael@0 | 118 | EXPECT_FALSE(FilePath("a/b").IsEmpty()); |
michael@0 | 119 | EXPECT_FALSE(FilePath("a\\b\\").IsEmpty()); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | // RemoveDirectoryName "" -> "" |
michael@0 | 123 | TEST(RemoveDirectoryNameTest, WhenEmptyName) { |
michael@0 | 124 | EXPECT_STREQ("", FilePath("").RemoveDirectoryName().c_str()); |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | // RemoveDirectoryName "afile" -> "afile" |
michael@0 | 128 | TEST(RemoveDirectoryNameTest, ButNoDirectory) { |
michael@0 | 129 | EXPECT_STREQ("afile", |
michael@0 | 130 | FilePath("afile").RemoveDirectoryName().c_str()); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | // RemoveDirectoryName "/afile" -> "afile" |
michael@0 | 134 | TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileName) { |
michael@0 | 135 | EXPECT_STREQ("afile", |
michael@0 | 136 | FilePath(GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str()); |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | // RemoveDirectoryName "adir/" -> "" |
michael@0 | 140 | TEST(RemoveDirectoryNameTest, WhereThereIsNoFileName) { |
michael@0 | 141 | EXPECT_STREQ("", |
michael@0 | 142 | FilePath("adir" GTEST_PATH_SEP_).RemoveDirectoryName().c_str()); |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | // RemoveDirectoryName "adir/afile" -> "afile" |
michael@0 | 146 | TEST(RemoveDirectoryNameTest, ShouldGiveFileName) { |
michael@0 | 147 | EXPECT_STREQ("afile", |
michael@0 | 148 | FilePath("adir" GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str()); |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | // RemoveDirectoryName "adir/subdir/afile" -> "afile" |
michael@0 | 152 | TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) { |
michael@0 | 153 | EXPECT_STREQ("afile", |
michael@0 | 154 | FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile") |
michael@0 | 155 | .RemoveDirectoryName().c_str()); |
michael@0 | 156 | } |
michael@0 | 157 | |
michael@0 | 158 | #if GTEST_HAS_ALT_PATH_SEP_ |
michael@0 | 159 | |
michael@0 | 160 | // Tests that RemoveDirectoryName() works with the alternate separator |
michael@0 | 161 | // on Windows. |
michael@0 | 162 | |
michael@0 | 163 | // RemoveDirectoryName("/afile") -> "afile" |
michael@0 | 164 | TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileNameForAlternateSeparator) { |
michael@0 | 165 | EXPECT_STREQ("afile", |
michael@0 | 166 | FilePath("/afile").RemoveDirectoryName().c_str()); |
michael@0 | 167 | } |
michael@0 | 168 | |
michael@0 | 169 | // RemoveDirectoryName("adir/") -> "" |
michael@0 | 170 | TEST(RemoveDirectoryNameTest, WhereThereIsNoFileNameForAlternateSeparator) { |
michael@0 | 171 | EXPECT_STREQ("", |
michael@0 | 172 | FilePath("adir/").RemoveDirectoryName().c_str()); |
michael@0 | 173 | } |
michael@0 | 174 | |
michael@0 | 175 | // RemoveDirectoryName("adir/afile") -> "afile" |
michael@0 | 176 | TEST(RemoveDirectoryNameTest, ShouldGiveFileNameForAlternateSeparator) { |
michael@0 | 177 | EXPECT_STREQ("afile", |
michael@0 | 178 | FilePath("adir/afile").RemoveDirectoryName().c_str()); |
michael@0 | 179 | } |
michael@0 | 180 | |
michael@0 | 181 | // RemoveDirectoryName("adir/subdir/afile") -> "afile" |
michael@0 | 182 | TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) { |
michael@0 | 183 | EXPECT_STREQ("afile", |
michael@0 | 184 | FilePath("adir/subdir/afile").RemoveDirectoryName().c_str()); |
michael@0 | 185 | } |
michael@0 | 186 | |
michael@0 | 187 | #endif |
michael@0 | 188 | |
michael@0 | 189 | // RemoveFileName "" -> "./" |
michael@0 | 190 | TEST(RemoveFileNameTest, EmptyName) { |
michael@0 | 191 | #if GTEST_OS_WINDOWS_MOBILE |
michael@0 | 192 | // On Windows CE, we use the root as the current directory. |
michael@0 | 193 | EXPECT_STREQ(GTEST_PATH_SEP_, |
michael@0 | 194 | FilePath("").RemoveFileName().c_str()); |
michael@0 | 195 | #else |
michael@0 | 196 | EXPECT_STREQ("." GTEST_PATH_SEP_, |
michael@0 | 197 | FilePath("").RemoveFileName().c_str()); |
michael@0 | 198 | #endif |
michael@0 | 199 | } |
michael@0 | 200 | |
michael@0 | 201 | // RemoveFileName "adir/" -> "adir/" |
michael@0 | 202 | TEST(RemoveFileNameTest, ButNoFile) { |
michael@0 | 203 | EXPECT_STREQ("adir" GTEST_PATH_SEP_, |
michael@0 | 204 | FilePath("adir" GTEST_PATH_SEP_).RemoveFileName().c_str()); |
michael@0 | 205 | } |
michael@0 | 206 | |
michael@0 | 207 | // RemoveFileName "adir/afile" -> "adir/" |
michael@0 | 208 | TEST(RemoveFileNameTest, GivesDirName) { |
michael@0 | 209 | EXPECT_STREQ("adir" GTEST_PATH_SEP_, |
michael@0 | 210 | FilePath("adir" GTEST_PATH_SEP_ "afile") |
michael@0 | 211 | .RemoveFileName().c_str()); |
michael@0 | 212 | } |
michael@0 | 213 | |
michael@0 | 214 | // RemoveFileName "adir/subdir/afile" -> "adir/subdir/" |
michael@0 | 215 | TEST(RemoveFileNameTest, GivesDirAndSubDirName) { |
michael@0 | 216 | EXPECT_STREQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_, |
michael@0 | 217 | FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile") |
michael@0 | 218 | .RemoveFileName().c_str()); |
michael@0 | 219 | } |
michael@0 | 220 | |
michael@0 | 221 | // RemoveFileName "/afile" -> "/" |
michael@0 | 222 | TEST(RemoveFileNameTest, GivesRootDir) { |
michael@0 | 223 | EXPECT_STREQ(GTEST_PATH_SEP_, |
michael@0 | 224 | FilePath(GTEST_PATH_SEP_ "afile").RemoveFileName().c_str()); |
michael@0 | 225 | } |
michael@0 | 226 | |
michael@0 | 227 | #if GTEST_HAS_ALT_PATH_SEP_ |
michael@0 | 228 | |
michael@0 | 229 | // Tests that RemoveFileName() works with the alternate separator on |
michael@0 | 230 | // Windows. |
michael@0 | 231 | |
michael@0 | 232 | // RemoveFileName("adir/") -> "adir/" |
michael@0 | 233 | TEST(RemoveFileNameTest, ButNoFileForAlternateSeparator) { |
michael@0 | 234 | EXPECT_STREQ("adir" GTEST_PATH_SEP_, |
michael@0 | 235 | FilePath("adir/").RemoveFileName().c_str()); |
michael@0 | 236 | } |
michael@0 | 237 | |
michael@0 | 238 | // RemoveFileName("adir/afile") -> "adir/" |
michael@0 | 239 | TEST(RemoveFileNameTest, GivesDirNameForAlternateSeparator) { |
michael@0 | 240 | EXPECT_STREQ("adir" GTEST_PATH_SEP_, |
michael@0 | 241 | FilePath("adir/afile").RemoveFileName().c_str()); |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | // RemoveFileName("adir/subdir/afile") -> "adir/subdir/" |
michael@0 | 245 | TEST(RemoveFileNameTest, GivesDirAndSubDirNameForAlternateSeparator) { |
michael@0 | 246 | EXPECT_STREQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_, |
michael@0 | 247 | FilePath("adir/subdir/afile").RemoveFileName().c_str()); |
michael@0 | 248 | } |
michael@0 | 249 | |
michael@0 | 250 | // RemoveFileName("/afile") -> "\" |
michael@0 | 251 | TEST(RemoveFileNameTest, GivesRootDirForAlternateSeparator) { |
michael@0 | 252 | EXPECT_STREQ(GTEST_PATH_SEP_, |
michael@0 | 253 | FilePath("/afile").RemoveFileName().c_str()); |
michael@0 | 254 | } |
michael@0 | 255 | |
michael@0 | 256 | #endif |
michael@0 | 257 | |
michael@0 | 258 | TEST(MakeFileNameTest, GenerateWhenNumberIsZero) { |
michael@0 | 259 | FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"), |
michael@0 | 260 | 0, "xml"); |
michael@0 | 261 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str()); |
michael@0 | 262 | } |
michael@0 | 263 | |
michael@0 | 264 | TEST(MakeFileNameTest, GenerateFileNameNumberGtZero) { |
michael@0 | 265 | FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"), |
michael@0 | 266 | 12, "xml"); |
michael@0 | 267 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str()); |
michael@0 | 268 | } |
michael@0 | 269 | |
michael@0 | 270 | TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberIsZero) { |
michael@0 | 271 | FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_), |
michael@0 | 272 | FilePath("bar"), 0, "xml"); |
michael@0 | 273 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str()); |
michael@0 | 274 | } |
michael@0 | 275 | |
michael@0 | 276 | TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberGtZero) { |
michael@0 | 277 | FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_), |
michael@0 | 278 | FilePath("bar"), 12, "xml"); |
michael@0 | 279 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str()); |
michael@0 | 280 | } |
michael@0 | 281 | |
michael@0 | 282 | TEST(MakeFileNameTest, GenerateWhenNumberIsZeroAndDirIsEmpty) { |
michael@0 | 283 | FilePath actual = FilePath::MakeFileName(FilePath(""), FilePath("bar"), |
michael@0 | 284 | 0, "xml"); |
michael@0 | 285 | EXPECT_STREQ("bar.xml", actual.c_str()); |
michael@0 | 286 | } |
michael@0 | 287 | |
michael@0 | 288 | TEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) { |
michael@0 | 289 | FilePath actual = FilePath::MakeFileName(FilePath(""), FilePath("bar"), |
michael@0 | 290 | 14, "xml"); |
michael@0 | 291 | EXPECT_STREQ("bar_14.xml", actual.c_str()); |
michael@0 | 292 | } |
michael@0 | 293 | |
michael@0 | 294 | TEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) { |
michael@0 | 295 | FilePath actual = FilePath::ConcatPaths(FilePath("foo"), |
michael@0 | 296 | FilePath("bar.xml")); |
michael@0 | 297 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str()); |
michael@0 | 298 | } |
michael@0 | 299 | |
michael@0 | 300 | TEST(ConcatPathsTest, WorksWhenPath1EndsWithPathSep) { |
michael@0 | 301 | FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_), |
michael@0 | 302 | FilePath("bar.xml")); |
michael@0 | 303 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str()); |
michael@0 | 304 | } |
michael@0 | 305 | |
michael@0 | 306 | TEST(ConcatPathsTest, Path1BeingEmpty) { |
michael@0 | 307 | FilePath actual = FilePath::ConcatPaths(FilePath(""), |
michael@0 | 308 | FilePath("bar.xml")); |
michael@0 | 309 | EXPECT_STREQ("bar.xml", actual.c_str()); |
michael@0 | 310 | } |
michael@0 | 311 | |
michael@0 | 312 | TEST(ConcatPathsTest, Path2BeingEmpty) { |
michael@0 | 313 | FilePath actual = FilePath::ConcatPaths(FilePath("foo"), |
michael@0 | 314 | FilePath("")); |
michael@0 | 315 | EXPECT_STREQ("foo" GTEST_PATH_SEP_, actual.c_str()); |
michael@0 | 316 | } |
michael@0 | 317 | |
michael@0 | 318 | TEST(ConcatPathsTest, BothPathBeingEmpty) { |
michael@0 | 319 | FilePath actual = FilePath::ConcatPaths(FilePath(""), |
michael@0 | 320 | FilePath("")); |
michael@0 | 321 | EXPECT_STREQ("", actual.c_str()); |
michael@0 | 322 | } |
michael@0 | 323 | |
michael@0 | 324 | TEST(ConcatPathsTest, Path1ContainsPathSep) { |
michael@0 | 325 | FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_ "bar"), |
michael@0 | 326 | FilePath("foobar.xml")); |
michael@0 | 327 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "foobar.xml", |
michael@0 | 328 | actual.c_str()); |
michael@0 | 329 | } |
michael@0 | 330 | |
michael@0 | 331 | TEST(ConcatPathsTest, Path2ContainsPathSep) { |
michael@0 | 332 | FilePath actual = FilePath::ConcatPaths( |
michael@0 | 333 | FilePath("foo" GTEST_PATH_SEP_), |
michael@0 | 334 | FilePath("bar" GTEST_PATH_SEP_ "bar.xml")); |
michael@0 | 335 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "bar.xml", |
michael@0 | 336 | actual.c_str()); |
michael@0 | 337 | } |
michael@0 | 338 | |
michael@0 | 339 | TEST(ConcatPathsTest, Path2EndsWithPathSep) { |
michael@0 | 340 | FilePath actual = FilePath::ConcatPaths(FilePath("foo"), |
michael@0 | 341 | FilePath("bar" GTEST_PATH_SEP_)); |
michael@0 | 342 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_, actual.c_str()); |
michael@0 | 343 | } |
michael@0 | 344 | |
michael@0 | 345 | // RemoveTrailingPathSeparator "" -> "" |
michael@0 | 346 | TEST(RemoveTrailingPathSeparatorTest, EmptyString) { |
michael@0 | 347 | EXPECT_STREQ("", |
michael@0 | 348 | FilePath("").RemoveTrailingPathSeparator().c_str()); |
michael@0 | 349 | } |
michael@0 | 350 | |
michael@0 | 351 | // RemoveTrailingPathSeparator "foo" -> "foo" |
michael@0 | 352 | TEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) { |
michael@0 | 353 | EXPECT_STREQ("foo", |
michael@0 | 354 | FilePath("foo").RemoveTrailingPathSeparator().c_str()); |
michael@0 | 355 | } |
michael@0 | 356 | |
michael@0 | 357 | // RemoveTrailingPathSeparator "foo/" -> "foo" |
michael@0 | 358 | TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) { |
michael@0 | 359 | EXPECT_STREQ( |
michael@0 | 360 | "foo", |
michael@0 | 361 | FilePath("foo" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().c_str()); |
michael@0 | 362 | #if GTEST_HAS_ALT_PATH_SEP_ |
michael@0 | 363 | EXPECT_STREQ("foo", |
michael@0 | 364 | FilePath("foo/").RemoveTrailingPathSeparator().c_str()); |
michael@0 | 365 | #endif |
michael@0 | 366 | } |
michael@0 | 367 | |
michael@0 | 368 | // RemoveTrailingPathSeparator "foo/bar/" -> "foo/bar/" |
michael@0 | 369 | TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveLastSeparator) { |
michael@0 | 370 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar", |
michael@0 | 371 | FilePath("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_) |
michael@0 | 372 | .RemoveTrailingPathSeparator().c_str()); |
michael@0 | 373 | } |
michael@0 | 374 | |
michael@0 | 375 | // RemoveTrailingPathSeparator "foo/bar" -> "foo/bar" |
michael@0 | 376 | TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) { |
michael@0 | 377 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar", |
michael@0 | 378 | FilePath("foo" GTEST_PATH_SEP_ "bar") |
michael@0 | 379 | .RemoveTrailingPathSeparator().c_str()); |
michael@0 | 380 | } |
michael@0 | 381 | |
michael@0 | 382 | TEST(DirectoryTest, RootDirectoryExists) { |
michael@0 | 383 | #if GTEST_OS_WINDOWS // We are on Windows. |
michael@0 | 384 | char current_drive[_MAX_PATH]; // NOLINT |
michael@0 | 385 | current_drive[0] = static_cast<char>(_getdrive() + 'A' - 1); |
michael@0 | 386 | current_drive[1] = ':'; |
michael@0 | 387 | current_drive[2] = '\\'; |
michael@0 | 388 | current_drive[3] = '\0'; |
michael@0 | 389 | EXPECT_TRUE(FilePath(current_drive).DirectoryExists()); |
michael@0 | 390 | #else |
michael@0 | 391 | EXPECT_TRUE(FilePath("/").DirectoryExists()); |
michael@0 | 392 | #endif // GTEST_OS_WINDOWS |
michael@0 | 393 | } |
michael@0 | 394 | |
michael@0 | 395 | #if GTEST_OS_WINDOWS |
michael@0 | 396 | TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) { |
michael@0 | 397 | const int saved_drive_ = _getdrive(); |
michael@0 | 398 | // Find a drive that doesn't exist. Start with 'Z' to avoid common ones. |
michael@0 | 399 | for (char drive = 'Z'; drive >= 'A'; drive--) |
michael@0 | 400 | if (_chdrive(drive - 'A' + 1) == -1) { |
michael@0 | 401 | char non_drive[_MAX_PATH]; // NOLINT |
michael@0 | 402 | non_drive[0] = drive; |
michael@0 | 403 | non_drive[1] = ':'; |
michael@0 | 404 | non_drive[2] = '\\'; |
michael@0 | 405 | non_drive[3] = '\0'; |
michael@0 | 406 | EXPECT_FALSE(FilePath(non_drive).DirectoryExists()); |
michael@0 | 407 | break; |
michael@0 | 408 | } |
michael@0 | 409 | _chdrive(saved_drive_); |
michael@0 | 410 | } |
michael@0 | 411 | #endif // GTEST_OS_WINDOWS |
michael@0 | 412 | |
michael@0 | 413 | #if !GTEST_OS_WINDOWS_MOBILE |
michael@0 | 414 | // Windows CE _does_ consider an empty directory to exist. |
michael@0 | 415 | TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) { |
michael@0 | 416 | EXPECT_FALSE(FilePath("").DirectoryExists()); |
michael@0 | 417 | } |
michael@0 | 418 | #endif // !GTEST_OS_WINDOWS_MOBILE |
michael@0 | 419 | |
michael@0 | 420 | TEST(DirectoryTest, CurrentDirectoryExists) { |
michael@0 | 421 | #if GTEST_OS_WINDOWS // We are on Windows. |
michael@0 | 422 | # ifndef _WIN32_CE // Windows CE doesn't have a current directory. |
michael@0 | 423 | |
michael@0 | 424 | EXPECT_TRUE(FilePath(".").DirectoryExists()); |
michael@0 | 425 | EXPECT_TRUE(FilePath(".\\").DirectoryExists()); |
michael@0 | 426 | |
michael@0 | 427 | # endif // _WIN32_CE |
michael@0 | 428 | #else |
michael@0 | 429 | EXPECT_TRUE(FilePath(".").DirectoryExists()); |
michael@0 | 430 | EXPECT_TRUE(FilePath("./").DirectoryExists()); |
michael@0 | 431 | #endif // GTEST_OS_WINDOWS |
michael@0 | 432 | } |
michael@0 | 433 | |
michael@0 | 434 | TEST(NormalizeTest, NullStringsEqualEmptyDirectory) { |
michael@0 | 435 | EXPECT_STREQ("", FilePath(NULL).c_str()); |
michael@0 | 436 | EXPECT_STREQ("", FilePath(String(NULL)).c_str()); |
michael@0 | 437 | } |
michael@0 | 438 | |
michael@0 | 439 | // "foo/bar" == foo//bar" == "foo///bar" |
michael@0 | 440 | TEST(NormalizeTest, MultipleConsecutiveSepaparatorsInMidstring) { |
michael@0 | 441 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar", |
michael@0 | 442 | FilePath("foo" GTEST_PATH_SEP_ "bar").c_str()); |
michael@0 | 443 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar", |
michael@0 | 444 | FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str()); |
michael@0 | 445 | EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar", |
michael@0 | 446 | FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ |
michael@0 | 447 | GTEST_PATH_SEP_ "bar").c_str()); |
michael@0 | 448 | } |
michael@0 | 449 | |
michael@0 | 450 | // "/bar" == //bar" == "///bar" |
michael@0 | 451 | TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringStart) { |
michael@0 | 452 | EXPECT_STREQ(GTEST_PATH_SEP_ "bar", |
michael@0 | 453 | FilePath(GTEST_PATH_SEP_ "bar").c_str()); |
michael@0 | 454 | EXPECT_STREQ(GTEST_PATH_SEP_ "bar", |
michael@0 | 455 | FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str()); |
michael@0 | 456 | EXPECT_STREQ(GTEST_PATH_SEP_ "bar", |
michael@0 | 457 | FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str()); |
michael@0 | 458 | } |
michael@0 | 459 | |
michael@0 | 460 | // "foo/" == foo//" == "foo///" |
michael@0 | 461 | TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) { |
michael@0 | 462 | EXPECT_STREQ("foo" GTEST_PATH_SEP_, |
michael@0 | 463 | FilePath("foo" GTEST_PATH_SEP_).c_str()); |
michael@0 | 464 | EXPECT_STREQ("foo" GTEST_PATH_SEP_, |
michael@0 | 465 | FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str()); |
michael@0 | 466 | EXPECT_STREQ("foo" GTEST_PATH_SEP_, |
michael@0 | 467 | FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str()); |
michael@0 | 468 | } |
michael@0 | 469 | |
michael@0 | 470 | #if GTEST_HAS_ALT_PATH_SEP_ |
michael@0 | 471 | |
michael@0 | 472 | // Tests that separators at the end of the string are normalized |
michael@0 | 473 | // regardless of their combination (e.g. "foo\" =="foo/\" == |
michael@0 | 474 | // "foo\\/"). |
michael@0 | 475 | TEST(NormalizeTest, MixAlternateSeparatorAtStringEnd) { |
michael@0 | 476 | EXPECT_STREQ("foo" GTEST_PATH_SEP_, |
michael@0 | 477 | FilePath("foo/").c_str()); |
michael@0 | 478 | EXPECT_STREQ("foo" GTEST_PATH_SEP_, |
michael@0 | 479 | FilePath("foo" GTEST_PATH_SEP_ "/").c_str()); |
michael@0 | 480 | EXPECT_STREQ("foo" GTEST_PATH_SEP_, |
michael@0 | 481 | FilePath("foo//" GTEST_PATH_SEP_).c_str()); |
michael@0 | 482 | } |
michael@0 | 483 | |
michael@0 | 484 | #endif |
michael@0 | 485 | |
michael@0 | 486 | TEST(AssignmentOperatorTest, DefaultAssignedToNonDefault) { |
michael@0 | 487 | FilePath default_path; |
michael@0 | 488 | FilePath non_default_path("path"); |
michael@0 | 489 | non_default_path = default_path; |
michael@0 | 490 | EXPECT_STREQ("", non_default_path.c_str()); |
michael@0 | 491 | EXPECT_STREQ("", default_path.c_str()); // RHS var is unchanged. |
michael@0 | 492 | } |
michael@0 | 493 | |
michael@0 | 494 | TEST(AssignmentOperatorTest, NonDefaultAssignedToDefault) { |
michael@0 | 495 | FilePath non_default_path("path"); |
michael@0 | 496 | FilePath default_path; |
michael@0 | 497 | default_path = non_default_path; |
michael@0 | 498 | EXPECT_STREQ("path", default_path.c_str()); |
michael@0 | 499 | EXPECT_STREQ("path", non_default_path.c_str()); // RHS var is unchanged. |
michael@0 | 500 | } |
michael@0 | 501 | |
michael@0 | 502 | TEST(AssignmentOperatorTest, ConstAssignedToNonConst) { |
michael@0 | 503 | const FilePath const_default_path("const_path"); |
michael@0 | 504 | FilePath non_default_path("path"); |
michael@0 | 505 | non_default_path = const_default_path; |
michael@0 | 506 | EXPECT_STREQ("const_path", non_default_path.c_str()); |
michael@0 | 507 | } |
michael@0 | 508 | |
michael@0 | 509 | class DirectoryCreationTest : public Test { |
michael@0 | 510 | protected: |
michael@0 | 511 | virtual void SetUp() { |
michael@0 | 512 | testdata_path_.Set(FilePath(String::Format("%s%s%s", |
michael@0 | 513 | TempDir().c_str(), GetCurrentExecutableName().c_str(), |
michael@0 | 514 | "_directory_creation" GTEST_PATH_SEP_ "test" GTEST_PATH_SEP_))); |
michael@0 | 515 | testdata_file_.Set(testdata_path_.RemoveTrailingPathSeparator()); |
michael@0 | 516 | |
michael@0 | 517 | unique_file0_.Set(FilePath::MakeFileName(testdata_path_, FilePath("unique"), |
michael@0 | 518 | 0, "txt")); |
michael@0 | 519 | unique_file1_.Set(FilePath::MakeFileName(testdata_path_, FilePath("unique"), |
michael@0 | 520 | 1, "txt")); |
michael@0 | 521 | |
michael@0 | 522 | remove(testdata_file_.c_str()); |
michael@0 | 523 | remove(unique_file0_.c_str()); |
michael@0 | 524 | remove(unique_file1_.c_str()); |
michael@0 | 525 | posix::RmDir(testdata_path_.c_str()); |
michael@0 | 526 | } |
michael@0 | 527 | |
michael@0 | 528 | virtual void TearDown() { |
michael@0 | 529 | remove(testdata_file_.c_str()); |
michael@0 | 530 | remove(unique_file0_.c_str()); |
michael@0 | 531 | remove(unique_file1_.c_str()); |
michael@0 | 532 | posix::RmDir(testdata_path_.c_str()); |
michael@0 | 533 | } |
michael@0 | 534 | |
michael@0 | 535 | String TempDir() const { |
michael@0 | 536 | #if GTEST_OS_WINDOWS_MOBILE |
michael@0 | 537 | return String("\\temp\\"); |
michael@0 | 538 | #elif GTEST_OS_WINDOWS |
michael@0 | 539 | const char* temp_dir = posix::GetEnv("TEMP"); |
michael@0 | 540 | if (temp_dir == NULL || temp_dir[0] == '\0') |
michael@0 | 541 | return String("\\temp\\"); |
michael@0 | 542 | else if (String(temp_dir).EndsWith("\\")) |
michael@0 | 543 | return String(temp_dir); |
michael@0 | 544 | else |
michael@0 | 545 | return String::Format("%s\\", temp_dir); |
michael@0 | 546 | #else |
michael@0 | 547 | return String("/tmp/"); |
michael@0 | 548 | #endif // GTEST_OS_WINDOWS_MOBILE |
michael@0 | 549 | } |
michael@0 | 550 | |
michael@0 | 551 | void CreateTextFile(const char* filename) { |
michael@0 | 552 | FILE* f = posix::FOpen(filename, "w"); |
michael@0 | 553 | fprintf(f, "text\n"); |
michael@0 | 554 | fclose(f); |
michael@0 | 555 | } |
michael@0 | 556 | |
michael@0 | 557 | // Strings representing a directory and a file, with identical paths |
michael@0 | 558 | // except for the trailing separator character that distinquishes |
michael@0 | 559 | // a directory named 'test' from a file named 'test'. Example names: |
michael@0 | 560 | FilePath testdata_path_; // "/tmp/directory_creation/test/" |
michael@0 | 561 | FilePath testdata_file_; // "/tmp/directory_creation/test" |
michael@0 | 562 | FilePath unique_file0_; // "/tmp/directory_creation/test/unique.txt" |
michael@0 | 563 | FilePath unique_file1_; // "/tmp/directory_creation/test/unique_1.txt" |
michael@0 | 564 | }; |
michael@0 | 565 | |
michael@0 | 566 | TEST_F(DirectoryCreationTest, CreateDirectoriesRecursively) { |
michael@0 | 567 | EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.c_str(); |
michael@0 | 568 | EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively()); |
michael@0 | 569 | EXPECT_TRUE(testdata_path_.DirectoryExists()); |
michael@0 | 570 | } |
michael@0 | 571 | |
michael@0 | 572 | TEST_F(DirectoryCreationTest, CreateDirectoriesForAlreadyExistingPath) { |
michael@0 | 573 | EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.c_str(); |
michael@0 | 574 | EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively()); |
michael@0 | 575 | // Call 'create' again... should still succeed. |
michael@0 | 576 | EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively()); |
michael@0 | 577 | } |
michael@0 | 578 | |
michael@0 | 579 | TEST_F(DirectoryCreationTest, CreateDirectoriesAndUniqueFilename) { |
michael@0 | 580 | FilePath file_path(FilePath::GenerateUniqueFileName(testdata_path_, |
michael@0 | 581 | FilePath("unique"), "txt")); |
michael@0 | 582 | EXPECT_STREQ(unique_file0_.c_str(), file_path.c_str()); |
michael@0 | 583 | EXPECT_FALSE(file_path.FileOrDirectoryExists()); // file not there |
michael@0 | 584 | |
michael@0 | 585 | testdata_path_.CreateDirectoriesRecursively(); |
michael@0 | 586 | EXPECT_FALSE(file_path.FileOrDirectoryExists()); // file still not there |
michael@0 | 587 | CreateTextFile(file_path.c_str()); |
michael@0 | 588 | EXPECT_TRUE(file_path.FileOrDirectoryExists()); |
michael@0 | 589 | |
michael@0 | 590 | FilePath file_path2(FilePath::GenerateUniqueFileName(testdata_path_, |
michael@0 | 591 | FilePath("unique"), "txt")); |
michael@0 | 592 | EXPECT_STREQ(unique_file1_.c_str(), file_path2.c_str()); |
michael@0 | 593 | EXPECT_FALSE(file_path2.FileOrDirectoryExists()); // file not there |
michael@0 | 594 | CreateTextFile(file_path2.c_str()); |
michael@0 | 595 | EXPECT_TRUE(file_path2.FileOrDirectoryExists()); |
michael@0 | 596 | } |
michael@0 | 597 | |
michael@0 | 598 | TEST_F(DirectoryCreationTest, CreateDirectoriesFail) { |
michael@0 | 599 | // force a failure by putting a file where we will try to create a directory. |
michael@0 | 600 | CreateTextFile(testdata_file_.c_str()); |
michael@0 | 601 | EXPECT_TRUE(testdata_file_.FileOrDirectoryExists()); |
michael@0 | 602 | EXPECT_FALSE(testdata_file_.DirectoryExists()); |
michael@0 | 603 | EXPECT_FALSE(testdata_file_.CreateDirectoriesRecursively()); |
michael@0 | 604 | } |
michael@0 | 605 | |
michael@0 | 606 | TEST(NoDirectoryCreationTest, CreateNoDirectoriesForDefaultXmlFile) { |
michael@0 | 607 | const FilePath test_detail_xml("test_detail.xml"); |
michael@0 | 608 | EXPECT_FALSE(test_detail_xml.CreateDirectoriesRecursively()); |
michael@0 | 609 | } |
michael@0 | 610 | |
michael@0 | 611 | TEST(FilePathTest, DefaultConstructor) { |
michael@0 | 612 | FilePath fp; |
michael@0 | 613 | EXPECT_STREQ("", fp.c_str()); |
michael@0 | 614 | } |
michael@0 | 615 | |
michael@0 | 616 | TEST(FilePathTest, CharAndCopyConstructors) { |
michael@0 | 617 | const FilePath fp("spicy"); |
michael@0 | 618 | EXPECT_STREQ("spicy", fp.c_str()); |
michael@0 | 619 | |
michael@0 | 620 | const FilePath fp_copy(fp); |
michael@0 | 621 | EXPECT_STREQ("spicy", fp_copy.c_str()); |
michael@0 | 622 | } |
michael@0 | 623 | |
michael@0 | 624 | TEST(FilePathTest, StringConstructor) { |
michael@0 | 625 | const FilePath fp(String("cider")); |
michael@0 | 626 | EXPECT_STREQ("cider", fp.c_str()); |
michael@0 | 627 | } |
michael@0 | 628 | |
michael@0 | 629 | TEST(FilePathTest, Set) { |
michael@0 | 630 | const FilePath apple("apple"); |
michael@0 | 631 | FilePath mac("mac"); |
michael@0 | 632 | mac.Set(apple); // Implement Set() since overloading operator= is forbidden. |
michael@0 | 633 | EXPECT_STREQ("apple", mac.c_str()); |
michael@0 | 634 | EXPECT_STREQ("apple", apple.c_str()); |
michael@0 | 635 | } |
michael@0 | 636 | |
michael@0 | 637 | TEST(FilePathTest, ToString) { |
michael@0 | 638 | const FilePath file("drink"); |
michael@0 | 639 | String str(file.ToString()); |
michael@0 | 640 | EXPECT_STREQ("drink", str.c_str()); |
michael@0 | 641 | } |
michael@0 | 642 | |
michael@0 | 643 | TEST(FilePathTest, RemoveExtension) { |
michael@0 | 644 | EXPECT_STREQ("app", FilePath("app.exe").RemoveExtension("exe").c_str()); |
michael@0 | 645 | EXPECT_STREQ("APP", FilePath("APP.EXE").RemoveExtension("exe").c_str()); |
michael@0 | 646 | } |
michael@0 | 647 | |
michael@0 | 648 | TEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) { |
michael@0 | 649 | EXPECT_STREQ("app", FilePath("app").RemoveExtension("exe").c_str()); |
michael@0 | 650 | } |
michael@0 | 651 | |
michael@0 | 652 | TEST(FilePathTest, IsDirectory) { |
michael@0 | 653 | EXPECT_FALSE(FilePath("cola").IsDirectory()); |
michael@0 | 654 | EXPECT_TRUE(FilePath("koala" GTEST_PATH_SEP_).IsDirectory()); |
michael@0 | 655 | #if GTEST_HAS_ALT_PATH_SEP_ |
michael@0 | 656 | EXPECT_TRUE(FilePath("koala/").IsDirectory()); |
michael@0 | 657 | #endif |
michael@0 | 658 | } |
michael@0 | 659 | |
michael@0 | 660 | TEST(FilePathTest, IsAbsolutePath) { |
michael@0 | 661 | EXPECT_FALSE(FilePath("is" GTEST_PATH_SEP_ "relative").IsAbsolutePath()); |
michael@0 | 662 | EXPECT_FALSE(FilePath("").IsAbsolutePath()); |
michael@0 | 663 | #if GTEST_OS_WINDOWS |
michael@0 | 664 | EXPECT_TRUE(FilePath("c:\\" GTEST_PATH_SEP_ "is_not" |
michael@0 | 665 | GTEST_PATH_SEP_ "relative").IsAbsolutePath()); |
michael@0 | 666 | EXPECT_FALSE(FilePath("c:foo" GTEST_PATH_SEP_ "bar").IsAbsolutePath()); |
michael@0 | 667 | EXPECT_TRUE(FilePath("c:/" GTEST_PATH_SEP_ "is_not" |
michael@0 | 668 | GTEST_PATH_SEP_ "relative").IsAbsolutePath()); |
michael@0 | 669 | #else |
michael@0 | 670 | EXPECT_TRUE(FilePath(GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative") |
michael@0 | 671 | .IsAbsolutePath()); |
michael@0 | 672 | #endif // GTEST_OS_WINDOWS |
michael@0 | 673 | } |
michael@0 | 674 | |
michael@0 | 675 | TEST(FilePathTest, IsRootDirectory) { |
michael@0 | 676 | #if GTEST_OS_WINDOWS |
michael@0 | 677 | EXPECT_TRUE(FilePath("a:\\").IsRootDirectory()); |
michael@0 | 678 | EXPECT_TRUE(FilePath("Z:/").IsRootDirectory()); |
michael@0 | 679 | EXPECT_TRUE(FilePath("e://").IsRootDirectory()); |
michael@0 | 680 | EXPECT_FALSE(FilePath("").IsRootDirectory()); |
michael@0 | 681 | EXPECT_FALSE(FilePath("b:").IsRootDirectory()); |
michael@0 | 682 | EXPECT_FALSE(FilePath("b:a").IsRootDirectory()); |
michael@0 | 683 | EXPECT_FALSE(FilePath("8:/").IsRootDirectory()); |
michael@0 | 684 | EXPECT_FALSE(FilePath("c|/").IsRootDirectory()); |
michael@0 | 685 | #else |
michael@0 | 686 | EXPECT_TRUE(FilePath("/").IsRootDirectory()); |
michael@0 | 687 | EXPECT_TRUE(FilePath("//").IsRootDirectory()); |
michael@0 | 688 | EXPECT_FALSE(FilePath("").IsRootDirectory()); |
michael@0 | 689 | EXPECT_FALSE(FilePath("\\").IsRootDirectory()); |
michael@0 | 690 | EXPECT_FALSE(FilePath("/x").IsRootDirectory()); |
michael@0 | 691 | #endif |
michael@0 | 692 | } |
michael@0 | 693 | |
michael@0 | 694 | } // namespace |
michael@0 | 695 | } // namespace internal |
michael@0 | 696 | } // namespace testing |