Skip to content
Snippets Groups Projects
Commit 911a7794 authored by Argyrios Kyrtzidis's avatar Argyrios Kyrtzidis
Browse files

[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
parent ca3751bb
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment