@@ -2090,6 +2090,44 @@ static void missingHeader4()
2090
2090
ASSERT_EQUALS (" file0,1,syntax_error,No header in #include\n " , toString (outputList));
2091
2091
}
2092
2092
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
+
2093
2131
static void nestedInclude ()
2094
2132
{
2095
2133
const char code[] = " #include \" test.h\"\n " ;
@@ -3260,6 +3298,16 @@ static void fuzz_crash()
3260
3298
}
3261
3299
}
3262
3300
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
+
3263
3311
int main (int argc, char **argv)
3264
3312
{
3265
3313
TEST_CASE (backslash);
@@ -3433,6 +3481,12 @@ int main(int argc, char **argv)
3433
3481
TEST_CASE (missingHeader2);
3434
3482
TEST_CASE (missingHeader3);
3435
3483
TEST_CASE (missingHeader4);
3484
+ #ifndef _WIN32
3485
+ TEST_CASE (missingHeader5);
3486
+ TEST_CASE (missingHeader6);
3487
+ TEST_CASE (missingHeader7);
3488
+ TEST_CASE (missingHeader8);
3489
+ #endif
3436
3490
TEST_CASE (nestedInclude);
3437
3491
TEST_CASE (systemInclude);
3438
3492
TEST_CASE (circularInclude);
@@ -3516,5 +3570,7 @@ int main(int argc, char **argv)
3516
3570
3517
3571
TEST_CASE (fuzz_crash);
3518
3572
3573
+ TEST_CASE (leak);
3574
+
3519
3575
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
3520
3576
}
0 commit comments