From fa994a37b315339840442a17c7b8a29464cdc7d1 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 42552a39..75e73ee6 100644 --- a/test.cpp +++ b/test.cpp @@ -2752,6 +2752,16 @@ static void token() ASSERT_TOKEN("+22", false, true, false); } +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); @@ -2984,5 +2994,7 @@ int main(int argc, char **argv) TEST_CASE(token); + TEST_CASE(leak); + return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS; }