@@ -2090,6 +2090,44 @@ static void missingHeader4()
20902090 ASSERT_EQUALS (" file0,1,syntax_error,No header in #include\n " , toString (outputList));
20912091}
20922092
2093+ #ifndef _WIN32
2094+ static void missingHeader5 ()
2095+ {
2096+ // this is a directory
2097+ const char code[] = " #include \" /\"\n " ;
2098+ simplecpp::OutputList outputList;
2099+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2100+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /\"\n " , toString (outputList));
2101+ }
2102+
2103+ static void missingHeader6 ()
2104+ {
2105+ // this is a directory
2106+ const char code[] = " #include \" /usr\"\n " ;
2107+ simplecpp::OutputList outputList;
2108+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2109+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /usr\"\n " , toString (outputList));
2110+ }
2111+
2112+ static void missingHeader7 ()
2113+ {
2114+ // this is a directory
2115+ const char code[] = " #include </>\n " ;
2116+ simplecpp::OutputList outputList;
2117+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2118+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </>\n " , toString (outputList));
2119+ }
2120+
2121+ static void missingHeader8 ()
2122+ {
2123+ // this is a directory
2124+ const char code[] = " #include </usr>\n " ;
2125+ simplecpp::OutputList outputList;
2126+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2127+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </usr>\n " , toString (outputList));
2128+ }
2129+ #endif
2130+
20932131static void nestedInclude ()
20942132{
20952133 const char code[] = " #include \" test.h\"\n " ;
@@ -3260,6 +3298,16 @@ static void fuzz_crash()
32603298 }
32613299}
32623300
3301+ static void leak ()
3302+ {
3303+ const char code[] = " #include</\\\\ >\n "
3304+ " #include</\\\\ >\n " ;
3305+ simplecpp::OutputList outputList;
3306+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
3307+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </\\\\ >\n "
3308+ " file0,2,missing_header,Header not found: </\\\\ >\n " , toString (outputList));
3309+ }
3310+
32633311int main (int argc, char **argv)
32643312{
32653313 TEST_CASE (backslash);
@@ -3433,6 +3481,12 @@ int main(int argc, char **argv)
34333481 TEST_CASE (missingHeader2);
34343482 TEST_CASE (missingHeader3);
34353483 TEST_CASE (missingHeader4);
3484+ #ifndef _WIN32
3485+ TEST_CASE (missingHeader5);
3486+ TEST_CASE (missingHeader6);
3487+ TEST_CASE (missingHeader7);
3488+ TEST_CASE (missingHeader8);
3489+ #endif
34363490 TEST_CASE (nestedInclude);
34373491 TEST_CASE (systemInclude);
34383492 TEST_CASE (circularInclude);
@@ -3516,5 +3570,7 @@ int main(int argc, char **argv)
35163570
35173571 TEST_CASE (fuzz_crash);
35183572
3573+ TEST_CASE (leak);
3574+
35193575 return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
35203576}
0 commit comments