diff options
author | Abseil Team <absl-team@google.com> | 2022-10-18 15:51:57 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-18 15:52:33 (GMT) |
commit | f372c760264ad5fe672a96994d4a44190201e5c1 (patch) | |
tree | 43ff192c35560000e9d9efe6ff11b4762e5e2edd /googletest/test | |
parent | 26d3ab54422257b65452d5feeb080c015eabf5e8 (diff) | |
download | googletest-f372c760264ad5fe672a96994d4a44190201e5c1.zip googletest-f372c760264ad5fe672a96994d4a44190201e5c1.tar.gz googletest-f372c760264ad5fe672a96994d4a44190201e5c1.tar.bz2 |
Adds Win32 UNC path support to FilePath::IsAbsolutePath() and FilePath::IsRootDirectory() in GoogleTest
Fixes: #3025
PiperOrigin-RevId: 481932601
Change-Id: I90fcb5b3d189aea79a0fd18735bad038b3511270
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/googletest-filepath-test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/googletest/test/googletest-filepath-test.cc b/googletest/test/googletest-filepath-test.cc index fe53f84..1e2cc4a 100644 --- a/googletest/test/googletest-filepath-test.cc +++ b/googletest/test/googletest-filepath-test.cc @@ -421,8 +421,13 @@ TEST(NormalizeTest, MultipleConsecutiveSeparatorsInMidstring) { // "/bar" == //bar" == "///bar" TEST(NormalizeTest, MultipleConsecutiveSeparatorsAtStringStart) { EXPECT_EQ(GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ "bar").string()); +#if GTEST_OS_WINDOWS + EXPECT_EQ(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar", + FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string()); +#else EXPECT_EQ(GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string()); +#endif EXPECT_EQ( GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string()); @@ -621,6 +626,9 @@ TEST(FilePathTest, IsAbsolutePath) { EXPECT_TRUE( FilePath("c:/" GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative") .IsAbsolutePath()); + EXPECT_TRUE(FilePath("d:/Windows").IsAbsolutePath()); + EXPECT_TRUE(FilePath("\\\\Host\\Share").IsAbsolutePath()); + EXPECT_TRUE(FilePath("\\\\Host\\Share\\Folder").IsAbsolutePath()); #else EXPECT_TRUE(FilePath(GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative") .IsAbsolutePath()); @@ -637,6 +645,16 @@ TEST(FilePathTest, IsRootDirectory) { EXPECT_FALSE(FilePath("b:a").IsRootDirectory()); EXPECT_FALSE(FilePath("8:/").IsRootDirectory()); EXPECT_FALSE(FilePath("c|/").IsRootDirectory()); + EXPECT_TRUE(FilePath("c:/").IsRootDirectory()); + EXPECT_FALSE(FilePath("d:/Windows").IsRootDirectory()); + + // This is for backward compatibility, since callers (even in this library) + // have assumed IsRootDirectory() implies a trailing directory separator. + EXPECT_FALSE(FilePath("\\\\Host\\Share").IsRootDirectory()); + + EXPECT_TRUE(FilePath("\\\\Host\\Share\\").IsRootDirectory()); + EXPECT_FALSE(FilePath("\\\\Host\\Share\\.").IsRootDirectory()); + EXPECT_FALSE(FilePath("\\\\Host\\Share\\C$\\").IsRootDirectory()); #else EXPECT_TRUE(FilePath("/").IsRootDirectory()); EXPECT_TRUE(FilePath("//").IsRootDirectory()); |