diff --git a/unittests/Tooling/CompilationDatabaseTest.cpp b/unittests/Tooling/CompilationDatabaseTest.cpp index 8e1f8284283dd648683adf294326d28db35dc543..b7e7a72d23531c7dcd87d2f25a36b3143fde343a 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<CompileCommand> 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<CompileCommand> Result = - Database.getCompileCommands("source"); + Database.getCompileCommands(FileName); ASSERT_EQ(1ul, Result.size()); std::vector<std::string> 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); }