summaryrefslogtreecommitdiff
path: root/unittests/Utility/FileSpecTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Utility/FileSpecTest.cpp')
-rw-r--r--unittests/Utility/FileSpecTest.cpp83
1 files changed, 41 insertions, 42 deletions
diff --git a/unittests/Utility/FileSpecTest.cpp b/unittests/Utility/FileSpecTest.cpp
index a271229b2e03..eae3a09b140d 100644
--- a/unittests/Utility/FileSpecTest.cpp
+++ b/unittests/Utility/FileSpecTest.cpp
@@ -14,92 +14,91 @@
using namespace lldb_private;
TEST(FileSpecTest, FileAndDirectoryComponents) {
- FileSpec fs_posix("/foo/bar", false, FileSpec::Style::posix);
+ FileSpec fs_posix("/foo/bar", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
- FileSpec fs_windows("F:\\bar", false, FileSpec::Style::windows);
+ FileSpec fs_windows("F:\\bar", FileSpec::Style::windows);
EXPECT_STREQ("F:\\bar", fs_windows.GetCString());
// EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetCString()); // It returns
// "F:/"
EXPECT_STREQ("bar", fs_windows.GetFilename().GetCString());
- FileSpec fs_posix_root("/", false, FileSpec::Style::posix);
+ FileSpec fs_posix_root("/", FileSpec::Style::posix);
EXPECT_STREQ("/", fs_posix_root.GetCString());
EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString());
EXPECT_STREQ("/", fs_posix_root.GetFilename().GetCString());
- FileSpec fs_net_drive("//net", false, FileSpec::Style::posix);
+ FileSpec fs_net_drive("//net", FileSpec::Style::posix);
EXPECT_STREQ("//net", fs_net_drive.GetCString());
EXPECT_EQ(nullptr, fs_net_drive.GetDirectory().GetCString());
EXPECT_STREQ("//net", fs_net_drive.GetFilename().GetCString());
- FileSpec fs_net_root("//net/", false, FileSpec::Style::posix);
+ FileSpec fs_net_root("//net/", FileSpec::Style::posix);
EXPECT_STREQ("//net/", fs_net_root.GetCString());
EXPECT_STREQ("//net", fs_net_root.GetDirectory().GetCString());
EXPECT_STREQ("/", fs_net_root.GetFilename().GetCString());
- FileSpec fs_windows_drive("F:", false, FileSpec::Style::windows);
+ FileSpec fs_windows_drive("F:", FileSpec::Style::windows);
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::Style::windows);
+ FileSpec fs_windows_root("F:\\", FileSpec::Style::windows);
EXPECT_STREQ("F:\\", fs_windows_root.GetCString());
EXPECT_STREQ("F:", fs_windows_root.GetDirectory().GetCString());
// EXPECT_STREQ("\\", fs_windows_root.GetFilename().GetCString()); // It
// returns "/"
- FileSpec fs_posix_long("/foo/bar/baz", false, FileSpec::Style::posix);
+ FileSpec fs_posix_long("/foo/bar/baz", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar/baz", fs_posix_long.GetCString());
EXPECT_STREQ("/foo/bar", fs_posix_long.GetDirectory().GetCString());
EXPECT_STREQ("baz", fs_posix_long.GetFilename().GetCString());
- FileSpec fs_windows_long("F:\\bar\\baz", false, FileSpec::Style::windows);
+ FileSpec fs_windows_long("F:\\bar\\baz", FileSpec::Style::windows);
EXPECT_STREQ("F:\\bar\\baz", fs_windows_long.GetCString());
// EXPECT_STREQ("F:\\bar", fs_windows_long.GetDirectory().GetCString()); // It
// returns "F:/bar"
EXPECT_STREQ("baz", fs_windows_long.GetFilename().GetCString());
- FileSpec fs_posix_trailing_slash("/foo/bar/", false, FileSpec::Style::posix);
+ FileSpec fs_posix_trailing_slash("/foo/bar/", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetCString());
EXPECT_STREQ("/foo", fs_posix_trailing_slash.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix_trailing_slash.GetFilename().GetCString());
- FileSpec fs_windows_trailing_slash("F:\\bar\\", false,
- FileSpec::Style::windows);
+ FileSpec fs_windows_trailing_slash("F:\\bar\\", FileSpec::Style::windows);
EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetCString());
EXPECT_STREQ("bar", fs_windows_trailing_slash.GetFilename().GetCString());
}
TEST(FileSpecTest, AppendPathComponent) {
- FileSpec fs_posix("/foo", false, FileSpec::Style::posix);
+ FileSpec fs_posix("/foo", FileSpec::Style::posix);
fs_posix.AppendPathComponent("bar");
EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
- FileSpec fs_posix_2("/foo", false, FileSpec::Style::posix);
+ FileSpec fs_posix_2("/foo", FileSpec::Style::posix);
fs_posix_2.AppendPathComponent("//bar/baz");
EXPECT_STREQ("/foo/bar/baz", fs_posix_2.GetCString());
EXPECT_STREQ("/foo/bar", fs_posix_2.GetDirectory().GetCString());
EXPECT_STREQ("baz", fs_posix_2.GetFilename().GetCString());
- FileSpec fs_windows("F:\\bar", false, FileSpec::Style::windows);
+ FileSpec fs_windows("F:\\bar", FileSpec::Style::windows);
fs_windows.AppendPathComponent("baz");
EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
// EXPECT_STREQ("F:\\bar", fs_windows.GetDirectory().GetCString()); // It
// returns "F:/bar"
EXPECT_STREQ("baz", fs_windows.GetFilename().GetCString());
- FileSpec fs_posix_root("/", false, FileSpec::Style::posix);
+ FileSpec fs_posix_root("/", FileSpec::Style::posix);
fs_posix_root.AppendPathComponent("bar");
EXPECT_STREQ("/bar", fs_posix_root.GetCString());
EXPECT_STREQ("/", fs_posix_root.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix_root.GetFilename().GetCString());
- FileSpec fs_windows_root("F:\\", false, FileSpec::Style::windows);
+ FileSpec fs_windows_root("F:\\", FileSpec::Style::windows);
fs_windows_root.AppendPathComponent("bar");
EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
// EXPECT_STREQ("F:\\", fs_windows_root.GetDirectory().GetCString()); // It
@@ -108,7 +107,7 @@ TEST(FileSpecTest, AppendPathComponent) {
}
TEST(FileSpecTest, CopyByAppendingPathComponent) {
- FileSpec fs = FileSpec("/foo", false, FileSpec::Style::posix)
+ FileSpec fs = FileSpec("/foo", FileSpec::Style::posix)
.CopyByAppendingPathComponent("bar");
EXPECT_STREQ("/foo/bar", fs.GetCString());
EXPECT_STREQ("/foo", fs.GetDirectory().GetCString());
@@ -116,30 +115,30 @@ TEST(FileSpecTest, CopyByAppendingPathComponent) {
}
TEST(FileSpecTest, PrependPathComponent) {
- FileSpec fs_posix("foo", false, FileSpec::Style::posix);
+ FileSpec fs_posix("foo", FileSpec::Style::posix);
fs_posix.PrependPathComponent("/bar");
EXPECT_STREQ("/bar/foo", fs_posix.GetCString());
- FileSpec fs_posix_2("foo/bar", false, FileSpec::Style::posix);
+ FileSpec fs_posix_2("foo/bar", FileSpec::Style::posix);
fs_posix_2.PrependPathComponent("/baz");
EXPECT_STREQ("/baz/foo/bar", fs_posix_2.GetCString());
- FileSpec fs_windows("baz", false, FileSpec::Style::windows);
+ FileSpec fs_windows("baz", FileSpec::Style::windows);
fs_windows.PrependPathComponent("F:\\bar");
EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
- FileSpec fs_posix_root("bar", false, FileSpec::Style::posix);
+ FileSpec fs_posix_root("bar", FileSpec::Style::posix);
fs_posix_root.PrependPathComponent("/");
EXPECT_STREQ("/bar", fs_posix_root.GetCString());
- FileSpec fs_windows_root("bar", false, FileSpec::Style::windows);
+ FileSpec fs_windows_root("bar", FileSpec::Style::windows);
fs_windows_root.PrependPathComponent("F:\\");
EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
}
TEST(FileSpecTest, EqualSeparator) {
- FileSpec backward("C:\\foo\\bar", false, FileSpec::Style::windows);
- FileSpec forward("C:/foo/bar", false, FileSpec::Style::windows);
+ FileSpec backward("C:\\foo\\bar", FileSpec::Style::windows);
+ FileSpec forward("C:/foo/bar", FileSpec::Style::windows);
EXPECT_EQ(forward, backward);
}
@@ -155,8 +154,8 @@ TEST(FileSpecTest, EqualDotsWindows) {
};
for (const auto &test : tests) {
- FileSpec one(test.first, false, FileSpec::Style::windows);
- FileSpec two(test.second, false, FileSpec::Style::windows);
+ FileSpec one(test.first, FileSpec::Style::windows);
+ FileSpec two(test.second, FileSpec::Style::windows);
EXPECT_EQ(one, two);
}
}
@@ -171,8 +170,8 @@ TEST(FileSpecTest, EqualDotsPosix) {
};
for (const auto &test : tests) {
- FileSpec one(test.first, false, FileSpec::Style::posix);
- FileSpec two(test.second, false, FileSpec::Style::posix);
+ FileSpec one(test.first, FileSpec::Style::posix);
+ FileSpec two(test.second, FileSpec::Style::posix);
EXPECT_EQ(one, two);
}
}
@@ -185,8 +184,8 @@ TEST(FileSpecTest, EqualDotsPosixRoot) {
};
for (const auto &test : tests) {
- FileSpec one(test.first, false, FileSpec::Style::posix);
- FileSpec two(test.second, false, FileSpec::Style::posix);
+ FileSpec one(test.first, FileSpec::Style::posix);
+ FileSpec two(test.second, FileSpec::Style::posix);
EXPECT_EQ(one, two);
}
}
@@ -222,7 +221,7 @@ TEST(FileSpecTest, GetNormalizedPath) {
for (auto test : posix_tests) {
SCOPED_TRACE(llvm::Twine("test.first = ") + test.first);
EXPECT_EQ(test.second,
- FileSpec(test.first, false, FileSpec::Style::posix).GetPath());
+ FileSpec(test.first, FileSpec::Style::posix).GetPath());
}
std::pair<const char *, const char *> windows_tests[] = {
@@ -254,7 +253,7 @@ TEST(FileSpecTest, GetNormalizedPath) {
};
for (auto test : windows_tests) {
EXPECT_EQ(test.second,
- FileSpec(test.first, false, FileSpec::Style::windows).GetPath())
+ FileSpec(test.first, FileSpec::Style::windows).GetPath())
<< "Original path: " << test.first;
}
}
@@ -267,17 +266,17 @@ TEST(FileSpecTest, FormatFileSpec) {
EXPECT_EQ("(empty)", llvm::formatv("{0:D}", F).str());
EXPECT_EQ("(empty)", llvm::formatv("{0:F}", F).str());
- F = FileSpec("C:\\foo\\bar.txt", false, win);
+ F = FileSpec("C:\\foo\\bar.txt", win);
EXPECT_EQ("C:\\foo\\bar.txt", llvm::formatv("{0}", F).str());
EXPECT_EQ("C:\\foo\\", llvm::formatv("{0:D}", F).str());
EXPECT_EQ("bar.txt", llvm::formatv("{0:F}", F).str());
- F = FileSpec("foo\\bar.txt", false, win);
+ F = FileSpec("foo\\bar.txt", win);
EXPECT_EQ("foo\\bar.txt", llvm::formatv("{0}", F).str());
EXPECT_EQ("foo\\", llvm::formatv("{0:D}", F).str());
EXPECT_EQ("bar.txt", llvm::formatv("{0:F}", F).str());
- F = FileSpec("foo", false, win);
+ F = FileSpec("foo", win);
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());
@@ -306,7 +305,7 @@ TEST(FileSpecTest, IsRelative) {
"/foo/../.",
};
for (const auto &path: not_relative) {
- FileSpec spec(path, false, FileSpec::Style::posix);
+ FileSpec spec(path, FileSpec::Style::posix);
EXPECT_FALSE(spec.IsRelative());
}
llvm::StringRef is_relative[] = {
@@ -324,13 +323,13 @@ TEST(FileSpecTest, IsRelative) {
"./foo/bar.c"
};
for (const auto &path: is_relative) {
- FileSpec spec(path, false, FileSpec::Style::posix);
+ FileSpec spec(path, FileSpec::Style::posix);
EXPECT_TRUE(spec.IsRelative());
}
}
TEST(FileSpecTest, RemoveLastPathComponent) {
- FileSpec fs_posix("/foo/bar/baz", false, FileSpec::Style::posix);
+ FileSpec fs_posix("/foo/bar/baz", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar/baz", fs_posix.GetCString());
EXPECT_TRUE(fs_posix.RemoveLastPathComponent());
EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
@@ -341,7 +340,7 @@ TEST(FileSpecTest, RemoveLastPathComponent) {
EXPECT_FALSE(fs_posix.RemoveLastPathComponent());
EXPECT_STREQ("/", fs_posix.GetCString());
- FileSpec fs_posix_relative("./foo/bar/baz", false, FileSpec::Style::posix);
+ FileSpec fs_posix_relative("./foo/bar/baz", FileSpec::Style::posix);
EXPECT_STREQ("foo/bar/baz", fs_posix_relative.GetCString());
EXPECT_TRUE(fs_posix_relative.RemoveLastPathComponent());
EXPECT_STREQ("foo/bar", fs_posix_relative.GetCString());
@@ -350,14 +349,14 @@ TEST(FileSpecTest, RemoveLastPathComponent) {
EXPECT_FALSE(fs_posix_relative.RemoveLastPathComponent());
EXPECT_STREQ("foo", fs_posix_relative.GetCString());
- FileSpec fs_posix_relative2("./", false, FileSpec::Style::posix);
+ FileSpec fs_posix_relative2("./", FileSpec::Style::posix);
EXPECT_STREQ(".", fs_posix_relative2.GetCString());
EXPECT_FALSE(fs_posix_relative2.RemoveLastPathComponent());
EXPECT_STREQ(".", fs_posix_relative2.GetCString());
EXPECT_FALSE(fs_posix_relative.RemoveLastPathComponent());
EXPECT_STREQ(".", fs_posix_relative2.GetCString());
- FileSpec fs_windows("C:\\foo\\bar\\baz", false, FileSpec::Style::windows);
+ FileSpec fs_windows("C:\\foo\\bar\\baz", FileSpec::Style::windows);
EXPECT_STREQ("C:\\foo\\bar\\baz", fs_windows.GetCString());
EXPECT_TRUE(fs_windows.RemoveLastPathComponent());
EXPECT_STREQ("C:\\foo\\bar", fs_windows.GetCString());