[Lldb-commits] [lldb] bf716eb - [lldb] Add FileSpec::Equal unit tests

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 28 05:43:42 PST 2019


Author: Pavel Labath
Date: 2019-11-28T14:31:52+01:00
New Revision: bf716eb807409adf6490cb1cf595fb51efbd3fe6

URL: https://github.com/llvm/llvm-project/commit/bf716eb807409adf6490cb1cf595fb51efbd3fe6
DIFF: https://github.com/llvm/llvm-project/commit/bf716eb807409adf6490cb1cf595fb51efbd3fe6.diff

LOG: [lldb] Add FileSpec::Equal unit tests

this is in preparation of a refactor of this method.

Added: 
    

Modified: 
    lldb/unittests/Utility/FileSpecTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Utility/FileSpecTest.cpp b/lldb/unittests/Utility/FileSpecTest.cpp
index 4f91d11fdf1e..132c7cb94fad 100644
--- a/lldb/unittests/Utility/FileSpecTest.cpp
+++ b/lldb/unittests/Utility/FileSpecTest.cpp
@@ -379,3 +379,23 @@ TEST(FileSpecTest, RemoveLastPathComponent) {
   EXPECT_FALSE(fs_windows.RemoveLastPathComponent());
   EXPECT_STREQ("C:", fs_windows.GetCString());
 }
+
+TEST(FileSpecTest, Equal) {
+  auto Eq = [](const char *a, const char *b, bool full) {
+    return FileSpec::Equal(PosixSpec(a), PosixSpec(b), full);
+  };
+  EXPECT_TRUE(Eq("/foo/bar", "/foo/bar", true));
+  EXPECT_TRUE(Eq("/foo/bar", "/foo/bar", false));
+
+  EXPECT_FALSE(Eq("/foo/bar", "/foo/baz", true));
+  EXPECT_FALSE(Eq("/foo/bar", "/foo/baz", false));
+
+  EXPECT_FALSE(Eq("/bar/foo", "/baz/foo", true));
+  EXPECT_FALSE(Eq("/bar/foo", "/baz/foo", false));
+
+  EXPECT_FALSE(Eq("/bar/foo", "foo", true));
+  EXPECT_TRUE(Eq("/bar/foo", "foo", false));
+
+  EXPECT_FALSE(Eq("foo", "/bar/foo", true));
+  EXPECT_TRUE(Eq("foo", "/bar/foo", false));
+}


        


More information about the lldb-commits mailing list