Changeset View
Changeset View
Standalone View
Standalone View
clang/unittests/Tooling/CompilationDatabaseTest.cpp
Show First 20 Lines • Show All 636 Lines • ▼ Show 20 Lines | ASSERT_THAT(Result[0].CommandLine, | ||||
ElementsAre(EndsWith("clang-tool"), "-c", "-DDEF3", "source")); | ElementsAre(EndsWith("clang-tool"), "-c", "-DDEF3", "source")); | ||||
EXPECT_EQ(2, Argc); | EXPECT_EQ(2, Argc); | ||||
} | } | ||||
TEST(ParseFixedCompilationDatabase, HandlesPositionalArgsSyntaxOnly) { | TEST(ParseFixedCompilationDatabase, HandlesPositionalArgsSyntaxOnly) { | ||||
// Adjust the given command line arguments to ensure that any positional | // Adjust the given command line arguments to ensure that any positional | ||||
// arguments in them are stripped. | // arguments in them are stripped. | ||||
const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"}; | const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"}; | ||||
int Argc = llvm::array_lengthof(Argv); | int Argc = std::size(Argv); | ||||
std::string ErrorMessage; | std::string ErrorMessage; | ||||
std::unique_ptr<CompilationDatabase> Database = | std::unique_ptr<CompilationDatabase> Database = | ||||
FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage); | FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage); | ||||
ASSERT_TRUE((bool)Database); | ASSERT_TRUE((bool)Database); | ||||
ASSERT_TRUE(ErrorMessage.empty()); | ASSERT_TRUE(ErrorMessage.empty()); | ||||
std::vector<CompileCommand> Result = Database->getCompileCommands("source"); | std::vector<CompileCommand> Result = Database->getCompileCommands("source"); | ||||
ASSERT_EQ(1ul, Result.size()); | ASSERT_EQ(1ul, Result.size()); | ||||
ASSERT_EQ(".", Result[0].Directory); | ASSERT_EQ(".", Result[0].Directory); | ||||
▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines |