@@ -2052,6 +2052,44 @@ static void missingHeader4()
20522052 ASSERT_EQUALS (" file0,1,syntax_error,No header in #include\n " , toString (outputList));
20532053}
20542054
2055+ #ifndef _WIN32
2056+ static void missingHeader5 ()
2057+ {
2058+ // this is a directory
2059+ const char code[] = " #include \" /\"\n " ;
2060+ simplecpp::OutputList outputList;
2061+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2062+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /\"\n " , toString (outputList));
2063+ }
2064+
2065+ static void missingHeader6 ()
2066+ {
2067+ // this is a directory
2068+ const char code[] = " #include \" /usr\"\n " ;
2069+ simplecpp::OutputList outputList;
2070+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2071+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /usr\"\n " , toString (outputList));
2072+ }
2073+
2074+ static void missingHeader7 ()
2075+ {
2076+ // this is a directory
2077+ const char code[] = " #include </>\n " ;
2078+ simplecpp::OutputList outputList;
2079+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2080+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </>\n " , toString (outputList));
2081+ }
2082+
2083+ static void missingHeader8 ()
2084+ {
2085+ // this is a directory
2086+ const char code[] = " #include </usr>\n " ;
2087+ simplecpp::OutputList outputList;
2088+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2089+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </usr>\n " , toString (outputList));
2090+ }
2091+ #endif
2092+
20552093static void nestedInclude ()
20562094{
20572095 const char code[] = " #include \" test.h\"\n " ;
@@ -3139,6 +3177,16 @@ static void fuzz_crash()
31393177 }
31403178}
31413179
3180+ static void leak ()
3181+ {
3182+ const char code[] = " #include</\\\\ >\n "
3183+ " #include</\\\\ >\n " ;
3184+ simplecpp::OutputList outputList;
3185+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
3186+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </\\\\ >\n "
3187+ " file0,2,missing_header,Header not found: </\\\\ >\n " , toString (outputList));
3188+ }
3189+
31423190int main (int argc, char **argv)
31433191{
31443192 TEST_CASE (backslash);
@@ -3312,6 +3360,12 @@ int main(int argc, char **argv)
33123360 TEST_CASE (missingHeader2);
33133361 TEST_CASE (missingHeader3);
33143362 TEST_CASE (missingHeader4);
3363+ #ifndef _WIN32
3364+ TEST_CASE (missingHeader5);
3365+ TEST_CASE (missingHeader6);
3366+ TEST_CASE (missingHeader7);
3367+ TEST_CASE (missingHeader8);
3368+ #endif
33153369 TEST_CASE (nestedInclude);
33163370 TEST_CASE (systemInclude);
33173371
@@ -3392,5 +3446,7 @@ int main(int argc, char **argv)
33923446
33933447 TEST_CASE (fuzz_crash);
33943448
3449+ TEST_CASE (leak);
3450+
33953451 return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
33963452}
0 commit comments