summaryrefslogtreecommitdiff
path: root/unittests/Host/FileSpecTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Host/FileSpecTest.cpp')
-rw-r--r--unittests/Host/FileSpecTest.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/unittests/Host/FileSpecTest.cpp b/unittests/Host/FileSpecTest.cpp
index 55a66b3b37eb..cb6877e7b622 100644
--- a/unittests/Host/FileSpecTest.cpp
+++ b/unittests/Host/FileSpecTest.cpp
@@ -9,7 +9,7 @@
#include "gtest/gtest.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
using namespace lldb_private;
@@ -109,6 +109,28 @@ TEST(FileSpecTest, CopyByAppendingPathComponent) {
EXPECT_STREQ("bar", fs.GetFilename().GetCString());
}
+TEST(FileSpecTest, PrependPathComponent) {
+ FileSpec fs_posix("foo", false, FileSpec::ePathSyntaxPosix);
+ fs_posix.PrependPathComponent("/bar");
+ EXPECT_STREQ("/bar/foo", fs_posix.GetCString());
+
+ FileSpec fs_posix_2("foo/bar", false, FileSpec::ePathSyntaxPosix);
+ fs_posix_2.PrependPathComponent("/baz");
+ EXPECT_STREQ("/baz/foo/bar", fs_posix_2.GetCString());
+
+ FileSpec fs_windows("baz", false, FileSpec::ePathSyntaxWindows);
+ fs_windows.PrependPathComponent("F:\\bar");
+ EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
+
+ FileSpec fs_posix_root("bar", false, FileSpec::ePathSyntaxPosix);
+ fs_posix_root.PrependPathComponent("/");
+ EXPECT_STREQ("/bar", fs_posix_root.GetCString());
+
+ FileSpec fs_windows_root("bar", false, FileSpec::ePathSyntaxWindows);
+ fs_windows_root.PrependPathComponent("F:\\");
+ EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
+}
+
static void Compare(const FileSpec &one, const FileSpec &two, bool full_match,
bool remove_backup_dots, bool result) {
EXPECT_EQ(result, FileSpec::Equal(one, two, full_match, remove_backup_dots))
@@ -142,6 +164,7 @@ TEST(FileSpecTest, EqualDotsWindows) {
{R"(C:/bar/baz)", R"(C:\foo\..\bar\baz)"},
{R"(C:\bar)", R"(C:\foo\..\bar)"},
{R"(C:\foo\bar)", R"(C:\foo\.\bar)"},
+ {R"(C:\foo\bar)", R"(C:\foo\bar\.)"},
};
for(const auto &test: tests) {
@@ -165,6 +188,7 @@ TEST(FileSpecTest, EqualDotsPosix) {
{R"(/bar/baz)", R"(/foo/../bar/baz)"},
{R"(/bar)", R"(/foo/../bar)"},
{R"(/foo/bar)", R"(/foo/./bar)"},
+ {R"(/foo/bar)", R"(/foo/bar/.)"},
};
for(const auto &test: tests) {
@@ -283,4 +307,4 @@ TEST(FileSpecTest, FormatFileSpec) {
EXPECT_EQ("foo", llvm::formatv("{0}", F).str());
EXPECT_EQ("foo", llvm::formatv("{0:F}", F).str());
EXPECT_EQ("(empty)", llvm::formatv("{0:D}", F).str());
-} \ No newline at end of file
+}