mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[Support][NFC] Tests for root_name(), root_directory() and root_path()
It's literally just doc comments converted to unittests.
This commit is contained in:
parent
e9f41fac71
commit
8dbf875fd5
@ -204,6 +204,71 @@ TEST(Support, Path) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Support, PathRoot) {
|
||||
ASSERT_EQ(path::root_name("//net/hello", path::Style::posix).str(), "//net");
|
||||
ASSERT_EQ(path::root_name("c:/hello", path::Style::posix).str(), "");
|
||||
ASSERT_EQ(path::root_name("c:/hello", path::Style::windows).str(), "c:");
|
||||
ASSERT_EQ(path::root_name("/hello", path::Style::posix).str(), "");
|
||||
|
||||
ASSERT_EQ(path::root_directory("/goo/hello", path::Style::posix).str(), "/");
|
||||
ASSERT_EQ(path::root_directory("c:/hello", path::Style::windows).str(), "/");
|
||||
ASSERT_EQ(path::root_directory("d/file.txt", path::Style::posix).str(), "");
|
||||
ASSERT_EQ(path::root_directory("d/file.txt", path::Style::windows).str(), "");
|
||||
|
||||
SmallVector<StringRef, 40> paths;
|
||||
paths.push_back("");
|
||||
paths.push_back(".");
|
||||
paths.push_back("..");
|
||||
paths.push_back("foo");
|
||||
paths.push_back("/");
|
||||
paths.push_back("/foo");
|
||||
paths.push_back("foo/");
|
||||
paths.push_back("/foo/");
|
||||
paths.push_back("foo/bar");
|
||||
paths.push_back("/foo/bar");
|
||||
paths.push_back("//net");
|
||||
paths.push_back("//net/");
|
||||
paths.push_back("//net/foo");
|
||||
paths.push_back("///foo///");
|
||||
paths.push_back("///foo///bar");
|
||||
paths.push_back("/.");
|
||||
paths.push_back("./");
|
||||
paths.push_back("/..");
|
||||
paths.push_back("../");
|
||||
paths.push_back("foo/.");
|
||||
paths.push_back("foo/..");
|
||||
paths.push_back("foo/./");
|
||||
paths.push_back("foo/./bar");
|
||||
paths.push_back("foo/..");
|
||||
paths.push_back("foo/../");
|
||||
paths.push_back("foo/../bar");
|
||||
paths.push_back("c:");
|
||||
paths.push_back("c:/");
|
||||
paths.push_back("c:foo");
|
||||
paths.push_back("c:/foo");
|
||||
paths.push_back("c:foo/");
|
||||
paths.push_back("c:/foo/");
|
||||
paths.push_back("c:/foo/bar");
|
||||
paths.push_back("prn:");
|
||||
paths.push_back("c:\\");
|
||||
paths.push_back("c:foo");
|
||||
paths.push_back("c:\\foo");
|
||||
paths.push_back("c:foo\\");
|
||||
paths.push_back("c:\\foo\\");
|
||||
paths.push_back("c:\\foo/");
|
||||
paths.push_back("c:/foo\\bar");
|
||||
|
||||
for (StringRef p : paths) {
|
||||
ASSERT_EQ(
|
||||
path::root_name(p, path::Style::posix).str() + path::root_directory(p, path::Style::posix).str(),
|
||||
path::root_path(p, path::Style::posix).str());
|
||||
|
||||
ASSERT_EQ(
|
||||
path::root_name(p, path::Style::windows).str() + path::root_directory(p, path::Style::windows).str(),
|
||||
path::root_path(p, path::Style::windows).str());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Support, FilenameParent) {
|
||||
EXPECT_EQ("/", path::filename("/"));
|
||||
EXPECT_EQ("", path::parent_path("/"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user