diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/unittests/Host/FileSpecTest.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2 |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/unittests/Host/FileSpecTest.cpp')
-rw-r--r-- | lldb/unittests/Host/FileSpecTest.cpp | 200 |
1 files changed, 105 insertions, 95 deletions
diff --git a/lldb/unittests/Host/FileSpecTest.cpp b/lldb/unittests/Host/FileSpecTest.cpp index 522f4bc..765dd9e 100644 --- a/lldb/unittests/Host/FileSpecTest.cpp +++ b/lldb/unittests/Host/FileSpecTest.cpp @@ -13,105 +13,115 @@ using namespace lldb_private; -TEST(FileSpecTest, FileAndDirectoryComponents) -{ - FileSpec fs_posix("/foo/bar", false, FileSpec::ePathSyntaxPosix); - 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::ePathSyntaxWindows); - 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::ePathSyntaxPosix); - EXPECT_STREQ("/", fs_posix_root.GetCString()); - EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString()); - EXPECT_STREQ("/", fs_posix_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()); // It returns "/" - - FileSpec fs_posix_long("/foo/bar/baz", false, FileSpec::ePathSyntaxPosix); - 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::ePathSyntaxWindows); - 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::ePathSyntaxPosix); - EXPECT_STREQ("/foo/bar/.", fs_posix_trailing_slash.GetCString()); - EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetDirectory().GetCString()); - EXPECT_STREQ(".", fs_posix_trailing_slash.GetFilename().GetCString()); - - FileSpec fs_windows_trailing_slash("F:\\bar\\", false, FileSpec::ePathSyntaxWindows); - EXPECT_STREQ("F:\\bar\\.", fs_windows_trailing_slash.GetCString()); - // EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetDirectory().GetCString()); // It returns "F:/bar" - EXPECT_STREQ(".", fs_windows_trailing_slash.GetFilename().GetCString()); +TEST(FileSpecTest, FileAndDirectoryComponents) { + FileSpec fs_posix("/foo/bar", false, FileSpec::ePathSyntaxPosix); + 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::ePathSyntaxWindows); + 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::ePathSyntaxPosix); + EXPECT_STREQ("/", fs_posix_root.GetCString()); + EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString()); + EXPECT_STREQ("/", fs_posix_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()); // It + // returns "/" + + FileSpec fs_posix_long("/foo/bar/baz", false, FileSpec::ePathSyntaxPosix); + 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::ePathSyntaxWindows); + 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::ePathSyntaxPosix); + EXPECT_STREQ("/foo/bar/.", fs_posix_trailing_slash.GetCString()); + EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetDirectory().GetCString()); + EXPECT_STREQ(".", fs_posix_trailing_slash.GetFilename().GetCString()); + + FileSpec fs_windows_trailing_slash("F:\\bar\\", false, + FileSpec::ePathSyntaxWindows); + EXPECT_STREQ("F:\\bar\\.", fs_windows_trailing_slash.GetCString()); + // EXPECT_STREQ("F:\\bar", + // fs_windows_trailing_slash.GetDirectory().GetCString()); // It returns + // "F:/bar" + EXPECT_STREQ(".", fs_windows_trailing_slash.GetFilename().GetCString()); } -TEST(FileSpecTest, AppendPathComponent) -{ - FileSpec fs_posix("/foo", false, FileSpec::ePathSyntaxPosix); - 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::ePathSyntaxPosix); - 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::ePathSyntaxWindows); - 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::ePathSyntaxPosix); - 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::ePathSyntaxWindows); - fs_windows_root.AppendPathComponent("bar"); - EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString()); - // EXPECT_STREQ("F:\\", fs_windows_root.GetDirectory().GetCString()); // It returns "F:/" - EXPECT_STREQ("bar", fs_windows_root.GetFilename().GetCString()); +TEST(FileSpecTest, AppendPathComponent) { + FileSpec fs_posix("/foo", false, FileSpec::ePathSyntaxPosix); + 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::ePathSyntaxPosix); + 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::ePathSyntaxWindows); + 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::ePathSyntaxPosix); + 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::ePathSyntaxWindows); + fs_windows_root.AppendPathComponent("bar"); + EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString()); + // EXPECT_STREQ("F:\\", fs_windows_root.GetDirectory().GetCString()); // It + // returns "F:/" + EXPECT_STREQ("bar", fs_windows_root.GetFilename().GetCString()); } -TEST(FileSpecTest, CopyByAppendingPathComponent) -{ - FileSpec fs = FileSpec("/foo", false, FileSpec::ePathSyntaxPosix).CopyByAppendingPathComponent("bar"); - EXPECT_STREQ("/foo/bar", fs.GetCString()); - EXPECT_STREQ("/foo", fs.GetDirectory().GetCString()); - EXPECT_STREQ("bar", fs.GetFilename().GetCString()); +TEST(FileSpecTest, CopyByAppendingPathComponent) { + FileSpec fs = FileSpec("/foo", false, FileSpec::ePathSyntaxPosix) + .CopyByAppendingPathComponent("bar"); + EXPECT_STREQ("/foo/bar", fs.GetCString()); + EXPECT_STREQ("/foo", fs.GetDirectory().GetCString()); + EXPECT_STREQ("bar", fs.GetFilename().GetCString()); } -TEST(FileSpecTest, Equal) -{ - FileSpec backward("C:\\foo\\bar", false, FileSpec::ePathSyntaxWindows); - FileSpec forward("C:/foo/bar", false, FileSpec::ePathSyntaxWindows); - EXPECT_EQ(forward, backward); - - const bool full_match = true; - const bool remove_backup_dots = true; - EXPECT_TRUE(FileSpec::Equal(forward, backward, full_match, remove_backup_dots)); - EXPECT_TRUE(FileSpec::Equal(forward, backward, full_match, !remove_backup_dots)); - EXPECT_TRUE(FileSpec::Equal(forward, backward, !full_match, remove_backup_dots)); - EXPECT_TRUE(FileSpec::Equal(forward, backward, !full_match, !remove_backup_dots)); +TEST(FileSpecTest, Equal) { + FileSpec backward("C:\\foo\\bar", false, FileSpec::ePathSyntaxWindows); + FileSpec forward("C:/foo/bar", false, FileSpec::ePathSyntaxWindows); + EXPECT_EQ(forward, backward); + + const bool full_match = true; + const bool remove_backup_dots = true; + EXPECT_TRUE( + FileSpec::Equal(forward, backward, full_match, remove_backup_dots)); + EXPECT_TRUE( + FileSpec::Equal(forward, backward, full_match, !remove_backup_dots)); + EXPECT_TRUE( + FileSpec::Equal(forward, backward, !full_match, remove_backup_dots)); + EXPECT_TRUE( + FileSpec::Equal(forward, backward, !full_match, !remove_backup_dots)); } |