From 5bacce115754426f24750104cf509c278f57089d Mon Sep 17 00:00:00 2001 From: firewave Date: Sat, 17 Feb 2024 01:49:01 +0100 Subject: [PATCH] test.cpp: added test to make sure the leak with empty headers no longer occurs --- test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test.cpp b/test.cpp index 05f1668..2c835be 100644 --- a/test.cpp +++ b/test.cpp @@ -2844,6 +2844,16 @@ static void fuzz_crash() } } +static void leak() +{ + const char code[] = "#include\n" + "#include\n"; + simplecpp::OutputList outputList; + ASSERT_EQUALS("", preprocess(code, &outputList)); + ASSERT_EQUALS("file0,1,missing_header,Header not found: \n" + "file0,2,missing_header,Header not found: \n", toString(outputList)); +} + int main(int argc, char **argv) { TEST_CASE(backslash); @@ -3081,5 +3091,7 @@ int main(int argc, char **argv) TEST_CASE(fuzz_crash); + TEST_CASE(leak); + return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS; }