aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/CompilationDatabaseTest.cpp
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2018-07-17 14:13:05 +0000
committerSimon Marchi <simon.marchi@ericsson.com>2018-07-17 14:13:05 +0000
commit6567c9e5e04258daadc9080ed2a388692a4fcdb7 (patch)
treecc55ad85b0131000efdacb1e8b7be15e038e425a /clang/unittests/Tooling/CompilationDatabaseTest.cpp
parentd95761d9d08340b641225b2cf6d397a06db29137 (diff)
downloadllvm-6567c9e5e04258daadc9080ed2a388692a4fcdb7.zip
llvm-6567c9e5e04258daadc9080ed2a388692a4fcdb7.tar.gz
llvm-6567c9e5e04258daadc9080ed2a388692a4fcdb7.tar.bz2
[Tooling] Add operator== to CompileCommand
Summary: It does the obvious thing of comparing all fields. This will be needed for a clangd patch I have in the pipeline. Subscribers: dblaikie, ilya-biryukov, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D49265 llvm-svn: 337284
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r--clang/unittests/Tooling/CompilationDatabaseTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 42497f7..ffc1d5b 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -736,5 +736,33 @@ TEST_F(InterpolateTest, Case) {
EXPECT_EQ(getCommand("foo/bar/baz/shout.C"), "clang -D FOO/BAR/BAZ/SHOUT.cc");
}
+TEST(CompileCommandTest, EqualityOperator) {
+ CompileCommand CCRef("/foo/bar", "hello.c", {"a", "b"}, "hello.o");
+ CompileCommand CCTest = CCRef;
+
+ EXPECT_TRUE(CCRef == CCTest);
+ EXPECT_FALSE(CCRef != CCTest);
+
+ CCTest = CCRef;
+ CCTest.Directory = "/foo/baz";
+ EXPECT_FALSE(CCRef == CCTest);
+ EXPECT_TRUE(CCRef != CCTest);
+
+ CCTest = CCRef;
+ CCTest.Filename = "bonjour.c";
+ EXPECT_FALSE(CCRef == CCTest);
+ EXPECT_TRUE(CCRef != CCTest);
+
+ CCTest = CCRef;
+ CCTest.CommandLine.push_back("c");
+ EXPECT_FALSE(CCRef == CCTest);
+ EXPECT_TRUE(CCRef != CCTest);
+
+ CCTest = CCRef;
+ CCTest.Output = "bonjour.o";
+ EXPECT_FALSE(CCRef == CCTest);
+ EXPECT_TRUE(CCRef != CCTest);
+}
+
} // end namespace tooling
} // end namespace clang