@@ -49,6 +49,7 @@ class TestImportProject : public TestFixture {
4949 TEST_CASE (importCompileCommands4); // only accept certain file types
5050 TEST_CASE (importCompileCommands5); // Windows/CMake/Ninja generated comile_commands.json
5151 TEST_CASE (importCompileCommands6); // Windows/CMake/Ninja generated comile_commands.json with spaces
52+ TEST_CASE (importCompileCommands7);
5253 TEST_CASE (importCompileCommandsArgumentsSection); // Handle arguments section
5354 TEST_CASE (importCompileCommandsNoCommandSection); // gracefully handles malformed json
5455 TEST_CASE (importCppcheckGuiProject);
@@ -103,16 +104,14 @@ class TestImportProject : public TestFixture {
103104 void importCompileCommands1 () const {
104105 const char json[] = R"( [{
105106 "directory": "/tmp",
106- "command": "gcc -DFILESDIR=\"\\\"/home/danielm/cppcheck 2\\\"\" -I\"/home/danielm/cppcheck 2/build/externals/tinyxml \" -DTEST1 -DTEST2=2 -o /tmp/src.o -c /tmp/src.c",
107+ "command": "gcc -DFILESDIR=\"/usr/local/share/Cppcheck \" -DTEST1 -DTEST2=2 -o /tmp/src.o -c /tmp/src.c",
107108 "file": "/tmp/src.c"
108109 }])" ;
109110 std::istringstream istr (json);
110111 TestImporter importer;
111112 importer.importCompileCommands (istr);
112113 ASSERT_EQUALS (1 , importer.fileSettings .size ());
113- // FIXME ASSERT_EQUALS("FILESDIR=\"/home/danielm/cppcheck 2\";TEST1=1;TEST2=2", importer.fileSettings.begin()->defines);
114- ASSERT_EQUALS (1 , importer.fileSettings .begin ()->includePaths .size ());
115- ASSERT_EQUALS (" /home/danielm/cppcheck 2/build/externals/tinyxml/" , importer.fileSettings .begin ()->includePaths .front ());
114+ ASSERT_EQUALS (" FILESDIR=\" /usr/local/share/Cppcheck\" ;TEST1=1;TEST2=2" , importer.fileSettings .begin ()->defines );
116115 }
117116
118117 void importCompileCommands2 () const {
@@ -191,6 +190,22 @@ class TestImportProject : public TestFixture {
191190 ASSERT_EQUALS (" C:/Users/dan/git/test-cppcheck/mylib/second src/" , importer.fileSettings .begin ()->includePaths .front ());
192191 }
193192
193+
194+ void importCompileCommands7 () const {
195+ const char json[] = R"( [{
196+ "directory": "/tmp",
197+ "command": "gcc -DFILESDIR=\"\\\"/home/danielm/cppcheck 2\\\"\" -I\"/home/danielm/cppcheck 2/build/externals/tinyxml\" -DTEST1 -DTEST2=2 -o /tmp/src.o -c /tmp/src.c",
198+ "file": "/tmp/src.c"
199+ }])" ;
200+ std::istringstream istr (json);
201+ TestImporter importer;
202+ importer.importCompileCommands (istr);
203+ ASSERT_EQUALS (1 , importer.fileSettings .size ());
204+ // FIXME ASSERT_EQUALS("FILESDIR=\"/home/danielm/cppcheck 2\";TEST1=1;TEST2=2", importer.fileSettings.begin()->defines);
205+ ASSERT_EQUALS (1 , importer.fileSettings .begin ()->includePaths .size ());
206+ ASSERT_EQUALS (" /home/danielm/cppcheck 2/build/externals/tinyxml/" , importer.fileSettings .begin ()->includePaths .front ());
207+ }
208+
194209 void importCompileCommandsArgumentsSection () const {
195210 const char json[] = " [ { \" directory\" : \" /tmp/\" ,"
196211 " \" arguments\" : [\" gcc\" , \" -c\" , \" src.c\" ],"
0 commit comments