diff options
Diffstat (limited to 'lldb/unittests/Host/FileSpecTest.cpp')
-rw-r--r-- | lldb/unittests/Host/FileSpecTest.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lldb/unittests/Host/FileSpecTest.cpp b/lldb/unittests/Host/FileSpecTest.cpp index 461be60ff13..89092c4604d 100644 --- a/lldb/unittests/Host/FileSpecTest.cpp +++ b/lldb/unittests/Host/FileSpecTest.cpp @@ -22,7 +22,7 @@ TEST(FileSpecTest, FileAndDirectoryComponents) FileSpec fs_windows("F:\\bar", false, FileSpec::ePathSyntaxWindows); EXPECT_STREQ("F:\\bar", fs_windows.GetCString()); - EXPECT_STREQ("F:", fs_windows.GetDirectory().GetCString()); + EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetCString()); EXPECT_STREQ("bar", fs_windows.GetFilename().GetCString()); FileSpec fs_posix_root("/", false, FileSpec::ePathSyntaxPosix); @@ -30,10 +30,15 @@ TEST(FileSpecTest, FileAndDirectoryComponents) EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString()); EXPECT_STREQ("/", fs_posix_root.GetFilename().GetCString()); - FileSpec fs_windows_root("F:", false, FileSpec::ePathSyntaxWindows); - EXPECT_STREQ("F:", fs_windows_root.GetCString()); - EXPECT_EQ(nullptr, fs_windows_root.GetDirectory().GetCString()); - EXPECT_STREQ("F:", fs_windows_root.GetFilename().GetCString()); + FileSpec fs_windows_drive("F:", false, FileSpec::ePathSyntaxWindows); + EXPECT_STREQ("F:", fs_windows_drive.GetCString()); + EXPECT_EQ(nullptr, fs_windows_drive.GetDirectory().GetCString()); + EXPECT_STREQ("F:", fs_windows_drive.GetFilename().GetCString()); + + FileSpec fs_windows_root("F:\\", false, FileSpec::ePathSyntaxWindows); + EXPECT_STREQ("F:\\", fs_windows_root.GetCString()); + EXPECT_STREQ("F:", fs_windows_root.GetDirectory().GetCString()); + EXPECT_STREQ("\\", fs_windows_root.GetFilename().GetCString()); FileSpec fs_posix_long("/foo/bar/baz", false, FileSpec::ePathSyntaxPosix); EXPECT_STREQ("/foo/bar/baz", fs_posix_long.GetCString()); @@ -43,7 +48,7 @@ TEST(FileSpecTest, FileAndDirectoryComponents) FileSpec fs_windows_long("F:\\bar\\baz", false, FileSpec::ePathSyntaxWindows); EXPECT_STREQ("F:\\bar\\baz", fs_windows_long.GetCString()); // We get "F:/bar" instead. - // EXPECT_STREQ("F:\\bar", fs_windows_long.GetDirectory().GetCString()); + EXPECT_STREQ("F:\\bar", fs_windows_long.GetDirectory().GetCString()); EXPECT_STREQ("baz", fs_windows_long.GetFilename().GetCString()); FileSpec fs_posix_trailing_slash("/foo/bar/", false, FileSpec::ePathSyntaxPosix); @@ -54,7 +59,7 @@ TEST(FileSpecTest, FileAndDirectoryComponents) FileSpec fs_windows_trailing_slash("F:\\bar\\", false, FileSpec::ePathSyntaxWindows); EXPECT_STREQ("F:\\bar\\.", fs_windows_trailing_slash.GetCString()); // We get "F:/bar" instead. - // EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetDirectory().GetCString()); + EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetDirectory().GetCString()); EXPECT_STREQ(".", fs_windows_trailing_slash.GetFilename().GetCString()); } @@ -66,11 +71,11 @@ TEST(FileSpecTest, AppendPathComponent) EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString()); EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString()); - FileSpec fs_windows("F:", false, FileSpec::ePathSyntaxWindows); - fs_windows.AppendPathComponent("bar"); - EXPECT_STREQ("F:\\bar", fs_windows.GetCString()); - EXPECT_STREQ("F:", fs_windows.GetDirectory().GetCString()); - EXPECT_STREQ("bar", fs_windows.GetFilename().GetCString()); + FileSpec fs_windows("F:\\bar", false, FileSpec::ePathSyntaxWindows); + fs_windows.AppendPathComponent("baz"); + EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString()); + EXPECT_STREQ("F:\\bar", fs_windows.GetDirectory().GetCString()); + EXPECT_STREQ("baz", fs_windows.GetFilename().GetCString()); FileSpec fs_posix_root("/", false, FileSpec::ePathSyntaxPosix); fs_posix_root.AppendPathComponent("bar"); @@ -78,10 +83,10 @@ TEST(FileSpecTest, AppendPathComponent) EXPECT_STREQ("/", fs_posix_root.GetDirectory().GetCString()); EXPECT_STREQ("bar", fs_posix_root.GetFilename().GetCString()); - FileSpec fs_windows_root("F:", false, FileSpec::ePathSyntaxWindows); + FileSpec fs_windows_root("F:\\", false, FileSpec::ePathSyntaxWindows); fs_windows_root.AppendPathComponent("bar"); EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString()); - EXPECT_STREQ("F:", fs_windows_root.GetDirectory().GetCString()); + EXPECT_STREQ("F:\\", fs_windows_root.GetDirectory().GetCString()); EXPECT_STREQ("bar", fs_windows_root.GetFilename().GetCString()); } |