@@ -2063,6 +2063,44 @@ static void missingHeader4()
2063
2063
ASSERT_EQUALS (" file0,1,syntax_error,No header in #include\n " , toString (outputList));
2064
2064
}
2065
2065
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
+
2066
2104
static void nestedInclude ()
2067
2105
{
2068
2106
const char code[] = " #include \" test.h\"\n " ;
@@ -3231,6 +3269,16 @@ static void fuzz_crash()
3231
3269
}
3232
3270
}
3233
3271
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
+
3234
3282
int main (int argc, char **argv)
3235
3283
{
3236
3284
TEST_CASE (backslash);
@@ -3404,6 +3452,12 @@ int main(int argc, char **argv)
3404
3452
TEST_CASE (missingHeader2);
3405
3453
TEST_CASE (missingHeader3);
3406
3454
TEST_CASE (missingHeader4);
3455
+ #ifndef _WIN32
3456
+ TEST_CASE (missingHeader5);
3457
+ TEST_CASE (missingHeader6);
3458
+ TEST_CASE (missingHeader7);
3459
+ TEST_CASE (missingHeader8);
3460
+ #endif
3407
3461
TEST_CASE (nestedInclude);
3408
3462
TEST_CASE (systemInclude);
3409
3463
TEST_CASE (circularInclude);
@@ -3487,5 +3541,7 @@ int main(int argc, char **argv)
3487
3541
3488
3542
TEST_CASE (fuzz_crash);
3489
3543
3544
+ TEST_CASE (leak);
3545
+
3490
3546
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
3491
3547
}
0 commit comments