@@ -2053,6 +2053,44 @@ static void missingHeader4()
2053
2053
ASSERT_EQUALS (" file0,1,syntax_error,No header in #include\n " , toString (outputList));
2054
2054
}
2055
2055
2056
+ #ifndef _WIN32
2057
+ static void missingHeader5 ()
2058
+ {
2059
+ // this is a directory
2060
+ const char code[] = " #include \" /\"\n " ;
2061
+ simplecpp::OutputList outputList;
2062
+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2063
+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /\"\n " , toString (outputList));
2064
+ }
2065
+
2066
+ static void missingHeader6 ()
2067
+ {
2068
+ // this is a directory
2069
+ const char code[] = " #include \" /usr\"\n " ;
2070
+ simplecpp::OutputList outputList;
2071
+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2072
+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: \" /usr\"\n " , toString (outputList));
2073
+ }
2074
+
2075
+ static void missingHeader7 ()
2076
+ {
2077
+ // this is a directory
2078
+ const char code[] = " #include </>\n " ;
2079
+ simplecpp::OutputList outputList;
2080
+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2081
+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </>\n " , toString (outputList));
2082
+ }
2083
+
2084
+ static void missingHeader8 ()
2085
+ {
2086
+ // this is a directory
2087
+ const char code[] = " #include </usr>\n " ;
2088
+ simplecpp::OutputList outputList;
2089
+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
2090
+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </usr>\n " , toString (outputList));
2091
+ }
2092
+ #endif
2093
+
2056
2094
static void nestedInclude ()
2057
2095
{
2058
2096
const char code[] = " #include \" test.h\"\n " ;
@@ -3183,6 +3221,16 @@ static void fuzz_crash()
3183
3221
}
3184
3222
}
3185
3223
3224
+ static void leak ()
3225
+ {
3226
+ const char code[] = " #include</\\\\ >\n "
3227
+ " #include</\\\\ >\n " ;
3228
+ simplecpp::OutputList outputList;
3229
+ ASSERT_EQUALS (" " , preprocess (code, &outputList));
3230
+ ASSERT_EQUALS (" file0,1,missing_header,Header not found: </\\\\ >\n "
3231
+ " file0,2,missing_header,Header not found: </\\\\ >\n " , toString (outputList));
3232
+ }
3233
+
3186
3234
int main (int argc, char **argv)
3187
3235
{
3188
3236
TEST_CASE (backslash);
@@ -3356,6 +3404,12 @@ int main(int argc, char **argv)
3356
3404
TEST_CASE (missingHeader2);
3357
3405
TEST_CASE (missingHeader3);
3358
3406
TEST_CASE (missingHeader4);
3407
+ #ifndef _WIN32
3408
+ TEST_CASE (missingHeader5);
3409
+ TEST_CASE (missingHeader6);
3410
+ TEST_CASE (missingHeader7);
3411
+ TEST_CASE (missingHeader8);
3412
+ #endif
3359
3413
TEST_CASE (nestedInclude);
3360
3414
TEST_CASE (systemInclude);
3361
3415
TEST_CASE (circularInclude);
@@ -3437,5 +3491,7 @@ int main(int argc, char **argv)
3437
3491
3438
3492
TEST_CASE (fuzz_crash);
3439
3493
3494
+ TEST_CASE (leak);
3495
+
3440
3496
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
3441
3497
}
0 commit comments