From 911a7794522f96206fcd315f215cb4c3cffb9e71 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 16 Sep 2015 18:28:42 +0000 Subject: [PATCH] [tooling] Add unit tests for change in r247468. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247832 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Tooling/CompilationDatabaseTest.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unittests/Tooling/CompilationDatabaseTest.cpp b/unittests/Tooling/CompilationDatabaseTest.cpp index 8e1f828428..b7e7a72d23 100644 --- a/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/unittests/Tooling/CompilationDatabaseTest.cpp @@ -98,8 +98,8 @@ TEST(JSONCompilationDatabase, GetAllCompileCommands) { StringRef FileName1("file1"); StringRef Command1("command1"); StringRef Directory2("//net/dir2"); - StringRef FileName2("file1"); - StringRef Command2("command1"); + StringRef FileName2("file2"); + StringRef Command2("command2"); std::vector Commands = getAllCompileCommands( ("[{\"directory\":\"" + Directory1 + "\"," + @@ -111,9 +111,11 @@ TEST(JSONCompilationDatabase, GetAllCompileCommands) { ErrorMessage); EXPECT_EQ(2U, Commands.size()) << ErrorMessage; EXPECT_EQ(Directory1, Commands[0].Directory) << ErrorMessage; + EXPECT_EQ(FileName1, Commands[0].Filename) << ErrorMessage; ASSERT_EQ(1u, Commands[0].CommandLine.size()); EXPECT_EQ(Command1, Commands[0].CommandLine[0]) << ErrorMessage; EXPECT_EQ(Directory2, Commands[1].Directory) << ErrorMessage; + EXPECT_EQ(FileName2, Commands[1].Filename) << ErrorMessage; ASSERT_EQ(1u, Commands[1].CommandLine.size()); EXPECT_EQ(Command2, Commands[1].CommandLine[0]) << ErrorMessage; } @@ -427,14 +429,16 @@ TEST(FixedCompilationDatabase, ReturnsFixedCommandLine) { CommandLine.push_back("one"); CommandLine.push_back("two"); FixedCompilationDatabase Database(".", CommandLine); + StringRef FileName("source"); std::vector Result = - Database.getCompileCommands("source"); + Database.getCompileCommands(FileName); ASSERT_EQ(1ul, Result.size()); std::vector ExpectedCommandLine(1, "clang-tool"); ExpectedCommandLine.insert(ExpectedCommandLine.end(), CommandLine.begin(), CommandLine.end()); ExpectedCommandLine.push_back("source"); EXPECT_EQ(".", Result[0].Directory); + EXPECT_EQ(FileName, Result[0].Filename); EXPECT_EQ(ExpectedCommandLine, Result[0].CommandLine); } -- 2.40.0