diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-07-17 14:13:05 +0000 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-07-17 14:13:05 +0000 |
commit | 5e12144b17b760c132a1afad02c0949c77354b7a (patch) | |
tree | 2c6522166e96ffc99509a7f1051923adefa0a4fd /unittests | |
parent | 30ed46c73401d62e0654092e227e5675fbc339d6 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337284 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Tooling/CompilationDatabaseTest.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/unittests/Tooling/CompilationDatabaseTest.cpp b/unittests/Tooling/CompilationDatabaseTest.cpp index 42497f7069..ffc1d5b3a4 100644 --- a/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/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 |