Skip to content

Commit edfa641

Browse files
committed
add test
1 parent d1698b3 commit edfa641

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/testimportproject.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class TestImportProject : public TestFixture {
6565
TEST_CASE(importCompileCommands11); // include path order
6666
TEST_CASE(importCompileCommands12); // #13040: "directory" is parent directory, relative include paths
6767
TEST_CASE(importCompileCommands13); // #13333: duplicate file entries
68+
TEST_CASE(importCompileCommands14); // #14156
6869
TEST_CASE(importCompileCommandsArgumentsSection); // Handle arguments section
6970
TEST_CASE(importCompileCommandsNoCommandSection); // gracefully handles malformed json
7071
TEST_CASE(importCompileCommandsDirectoryMissing); // 'directory' field missing
@@ -365,6 +366,29 @@ class TestImportProject : public TestFixture {
365366
ASSERT_EQUALS(1, fs2.fileIndex);
366367
}
367368

369+
void importCompileCommands14() const { // #14156
370+
REDIRECT;
371+
constexpr char json[] =
372+
R"([{
373+
"arguments": [
374+
"/usr/bin/g++",
375+
"-DTFS_LINUX_MODULE_NAME=\"tfs_linux\"",
376+
"-g",
377+
"-c",
378+
"cli/main.cpp"
379+
],
380+
"directory": "/home/daniel/cppcheck",
381+
"file": "/home/daniel/cppcheck/cli/main.cpp",
382+
"output": "/home/daniel/cppcheck/cli/main.o"
383+
}])";
384+
std::istringstream istr(json);
385+
TestImporter importer;
386+
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
387+
ASSERT_EQUALS(1, importer.fileSettings.size());
388+
const FileSettings &fs = importer.fileSettings.front();
389+
ASSERT_EQUALS("TFS_LINUX_MODULE_NAME=\"tfs_linux\"", fs.defines);
390+
}
391+
368392
void importCompileCommandsArgumentsSection() const {
369393
REDIRECT;
370394
constexpr char json[] = "[ { \"directory\": \"/tmp/\","

0 commit comments

Comments
 (0)