@@ -2063,6 +2063,44 @@ static void missingHeader4()
20632063 ASSERT_EQUALS (" file0,1,syntax_error,No header in #include\n " , toString (outputList));
20642064}
20652065
2066+ #ifndef _WIN32
2067+ static void missingHeader5 ()
2068+ {
2069+ // this is a directory
2070+ const char code[] = " #include \" /\"\n " ;
2071+ simplecpp::OutputList outputList;
2072+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2073+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /\"\n " , toString (outputList));
2074+ }
2075+
2076+ static void missingHeader6 ()
2077+ {
2078+ // this is a directory
2079+ const char code[] = " #include \" /usr\"\n " ;
2080+ simplecpp::OutputList outputList;
2081+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2082+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /usr\"\n " , toString (outputList));
2083+ }
2084+
2085+ static void missingHeader7 ()
2086+ {
2087+ // this is a directory
2088+ const char code[] = " #include </>\n " ;
2089+ simplecpp::OutputList outputList;
2090+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2091+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </>\n " , toString (outputList));
2092+ }
2093+
2094+ static void missingHeader8 ()
2095+ {
2096+ // this is a directory
2097+ const char code[] = " #include </usr>\n " ;
2098+ simplecpp::OutputList outputList;
2099+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2100+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </usr>\n " , toString (outputList));
2101+ }
2102+ #endif
2103+
20662104static void nestedInclude ()
20672105{
20682106 const char code[] = " #include \" test.h\"\n " ;
@@ -3231,6 +3269,16 @@ static void fuzz_crash()
32313269 }
32323270}
32333271
3272+ static void leak ()
3273+ {
3274+ const char code[] = " #include</\\\\ >\n "
3275+ " #include</\\\\ >\n " ;
3276+ simplecpp::OutputList outputList;
3277+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
3278+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </\\\\ >\n "
3279+ " file0,2,missing_header,Header not found: </\\\\ >\n " , toString (outputList));
3280+ }
3281+
32343282int main (int argc, char **argv)
32353283{
32363284 TEST_CASE (backslash);
@@ -3404,6 +3452,12 @@ int main(int argc, char **argv)
34043452 TEST_CASE (missingHeader2);
34053453 TEST_CASE (missingHeader3);
34063454 TEST_CASE (missingHeader4);
3455+ #ifndef _WIN32
3456+ TEST_CASE (missingHeader5);
3457+ TEST_CASE (missingHeader6);
3458+ TEST_CASE (missingHeader7);
3459+ TEST_CASE (missingHeader8);
3460+ #endif
34073461 TEST_CASE (nestedInclude);
34083462 TEST_CASE (systemInclude);
34093463 TEST_CASE (circularInclude);
@@ -3487,5 +3541,7 @@ int main(int argc, char **argv)
34873541
34883542 TEST_CASE (fuzz_crash);
34893543
3544+ TEST_CASE (leak);
3545+
34903546 return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
34913547}
0 commit comments