diff --git a/test/helpers.cpp b/test/helpers.cpp index 8a9e02ac63f..222fc384784 100644 --- a/test/helpers.cpp +++ b/test/helpers.cpp @@ -115,7 +115,7 @@ ScopedFile::~ScopedFile() { } // TODO: we should be using the actual Preprocessor implementation -std::string PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const std::string &filedata, const std::string &cfg, const std::string &filename, SuppressionList *inlineSuppression) +std::string PreprocessorHelper::getcodeforcfg(const Settings& settings, ErrorLogger& errorlogger, const std::string &filedata, const std::string &cfg, const std::string &filename, SuppressionList *inlineSuppression) { std::map cfgcode = getcode(settings, errorlogger, filedata.c_str(), std::set{cfg}, filename, inlineSuppression); const auto it = cfgcode.find(cfg); @@ -124,9 +124,9 @@ std::string PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& e return it->second; } -std::map PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], const std::string &filename, SuppressionList *inlineSuppression) +std::map PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], const std::string &filename) { - return getcode(settings, errorlogger, code, {}, filename, inlineSuppression); + return getcode(settings, errorlogger, code, {}, filename, nullptr); } std::map PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::set cfgs, const std::string &filename, SuppressionList *inlineSuppression) diff --git a/test/helpers.h b/test/helpers.h index d62696986df..1b803dcb679 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -172,11 +172,12 @@ class PreprocessorHelper * @param filename name of source file * @param inlineSuppression the inline suppressions */ - static std::string getcode(const Settings& settings, ErrorLogger& errorlogger, const std::string &filedata, const std::string &cfg, const std::string &filename, SuppressionList *inlineSuppression = nullptr); - static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr); + static std::string getcodeforcfg(const Settings& settings, ErrorLogger& errorlogger, const std::string &filedata, const std::string &cfg, const std::string &filename, SuppressionList *inlineSuppression = nullptr); + + static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], const std::string &filename = "file.c"); private: - static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::set cfgs, const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr); + static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::set cfgs, const std::string &filename, SuppressionList *inlineSuppression); }; namespace cppcheck { diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 6a23e144620..fd290d75c88 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -380,7 +380,7 @@ class TestPreprocessor : public TestFixture { void error3() { const auto settings = dinit(Settings, $.userDefines = "__cplusplus"); const std::string code("#error hello world!\n"); - (void)PreprocessorHelper::getcode(settings, *this, code, "X", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "X", "test.c"); ASSERT_EQUALS("[test.c:1:0]: (error) #error hello world! [preprocessorErrorDirective]\n", errout_str()); } @@ -390,7 +390,7 @@ class TestPreprocessor : public TestFixture { { const auto settings = dinit(Settings, $.userDefines = "TEST"); const std::string code("#file \"ab.h\"\n#error hello world!\n#endfile"); - (void)PreprocessorHelper::getcode(settings, *this, code, "TEST", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "TEST", "test.c"); ASSERT_EQUALS("[ab.h:1:0]: (error) #error hello world! [preprocessorErrorDirective]\n", errout_str()); } @@ -398,7 +398,7 @@ class TestPreprocessor : public TestFixture { { const auto settings = dinit(Settings, $.userDefines = "TEST"); const std::string code("#file \"ab.h\"\n\n#endfile\n#error aaa"); - (void)PreprocessorHelper::getcode(settings, *this, code, "TEST", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "TEST", "test.c"); ASSERT_EQUALS("[test.c:2:0]: (error) #error aaa [preprocessorErrorDirective]\n", errout_str()); } } @@ -409,7 +409,7 @@ class TestPreprocessor : public TestFixture { $.userDefines = "TEST", $.force = true); const std::string code("#error hello world!\n"); - (void)PreprocessorHelper::getcode(settings, *this, code, "X", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "X", "test.c"); ASSERT_EQUALS("", errout_str()); } @@ -1217,7 +1217,7 @@ class TestPreprocessor : public TestFixture { "#undef z\n" "int z;\n" "z = 0;\n"; - ASSERT_EQUALS("\n\nint z ;\nz = 0 ;", PreprocessorHelper::getcode(settings0, *this, filedata, "", "test.c")); + ASSERT_EQUALS("\n\nint z ;\nz = 0 ;", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata, "", "test.c")); } } @@ -1635,14 +1635,14 @@ class TestPreprocessor : public TestFixture { "#if A\n" "FOO\n" "#endif"; - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } { const char filedata[] = "#define A 1\n" "#if A==1\n" "FOO\n" "#endif"; - ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } } @@ -1652,7 +1652,7 @@ class TestPreprocessor : public TestFixture { "#if (B==A) || (B==C)\n" "FOO\n" "#endif"; - ASSERT_EQUALS("\n\n\nFOO", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("\n\n\nFOO", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } void define_if3() { @@ -1660,7 +1660,7 @@ class TestPreprocessor : public TestFixture { "#if (A==0)\n" "FOO\n" "#endif"; - ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } void define_if4() { @@ -1668,7 +1668,7 @@ class TestPreprocessor : public TestFixture { "#if X==123\n" "FOO\n" "#endif"; - ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } void define_if5() { // #4516 - #define B (A & 0x00f0) @@ -1678,7 +1678,7 @@ class TestPreprocessor : public TestFixture { "#if B==0x0010\n" "FOO\n" "#endif"; - ASSERT_EQUALS("\n\n\nFOO", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("\n\n\nFOO", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } { const char filedata[] = "#define A 0x00f0\n" @@ -1687,14 +1687,14 @@ class TestPreprocessor : public TestFixture { "#if C==0x0010\n" "FOO\n" "#endif"; - ASSERT_EQUALS("\n\n\n\nFOO", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("\n\n\n\nFOO", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } { const char filedata[] = "#define A (1+A)\n" // don't hang for recursive macros "#if A==1\n" "FOO\n" "#endif"; - ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcode(settings0, *this, filedata,"","test.c")); + ASSERT_EQUALS("\n\nFOO", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata,"","test.c")); } } @@ -1710,10 +1710,10 @@ class TestPreprocessor : public TestFixture { "#if B >= 0\n" "456\n" "#endif\n"; - const std::string actualA0 = PreprocessorHelper::getcode(settings0, *this, filedata, "A=0", "test.c"); + const std::string actualA0 = PreprocessorHelper::getcodeforcfg(settings0, *this, filedata, "A=0", "test.c"); ASSERT_EQUALS(true, actualA0.find("123") != std::string::npos); ASSERT_EQUALS(false, actualA0.find("456") != std::string::npos); - const std::string actualA1 = PreprocessorHelper::getcode(settings0, *this, filedata, "A=1", "test.c"); + const std::string actualA1 = PreprocessorHelper::getcodeforcfg(settings0, *this, filedata, "A=1", "test.c"); ASSERT_EQUALS(false, actualA1.find("123") != std::string::npos); ASSERT_EQUALS(true, actualA1.find("456") != std::string::npos); } @@ -1817,8 +1817,8 @@ class TestPreprocessor : public TestFixture { "B me;\n"; // Preprocess => actual result.. - ASSERT_EQUALS("\n\n\n\n\n\n$int me ;", PreprocessorHelper::getcode(settings0, *this, filedata, "", "a.cpp")); - ASSERT_EQUALS("\n\n\n\n\n\n$char me ;", PreprocessorHelper::getcode(settings0, *this, filedata, "A", "a.cpp")); + ASSERT_EQUALS("\n\n\n\n\n\n$int me ;", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata, "", "a.cpp")); + ASSERT_EQUALS("\n\n\n\n\n\n$char me ;", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata, "A", "a.cpp")); } void ifndef_define() { @@ -1841,8 +1841,8 @@ class TestPreprocessor : public TestFixture { "#endif\n"; // Preprocess => actual result.. - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings0, *this, filedata, "", "a.cpp")); - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings0, *this, filedata, "A", "a.cpp")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata, "", "a.cpp")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings0, *this, filedata, "A", "a.cpp")); } void redundant_config() { @@ -1928,7 +1928,7 @@ class TestPreprocessor : public TestFixture { "// cppcheck-suppress missingIncludeSystem\n" "#include \n"); SuppressionList inlineSuppr; - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c", &inlineSuppr); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c", &inlineSuppr); auto suppressions = inlineSuppr.getSuppressions(); ASSERT_EQUALS(2, suppressions.size()); @@ -1988,7 +1988,7 @@ class TestPreprocessor : public TestFixture { const std::string src("#if defined X || Y\n" "Fred & Wilma\n" "#endif\n"); - std::string actual = PreprocessorHelper::getcode(settings0, *this, src, "X=1", "test.c"); + std::string actual = PreprocessorHelper::getcodeforcfg(settings0, *this, src, "X=1", "test.c"); ASSERT_EQUALS("\nFred & Wilma", actual); } @@ -1998,12 +1998,12 @@ class TestPreprocessor : public TestFixture { "Fred & Wilma\n" "#endif\n"); { - std::string actual = PreprocessorHelper::getcode(settings0, *this, src, "X=1", "test.c"); + std::string actual = PreprocessorHelper::getcodeforcfg(settings0, *this, src, "X=1", "test.c"); ASSERT_EQUALS("", actual); } { - std::string actual = PreprocessorHelper::getcode(settings0, *this, src, "X=1;Y=2", "test.c"); + std::string actual = PreprocessorHelper::getcodeforcfg(settings0, *this, src, "X=1;Y=2", "test.c"); ASSERT_EQUALS("\nFred & Wilma", actual); } } @@ -2015,28 +2015,28 @@ class TestPreprocessor : public TestFixture { "#if (X == Y)\n" "Fred & Wilma\n" "#endif\n"; - const std::string actual = PreprocessorHelper::getcode(settings0, *this, code, "TEST", "test.c"); + const std::string actual = PreprocessorHelper::getcodeforcfg(settings0, *this, code, "TEST", "test.c"); ASSERT_EQUALS("\n\n\nFred & Wilma", actual); } void predefine4() { // #3577 const char code[] = "char buf[X];\n"; - const std::string actual = PreprocessorHelper::getcode(settings0, *this, code, "X=123", "test.c"); + const std::string actual = PreprocessorHelper::getcodeforcfg(settings0, *this, code, "X=123", "test.c"); ASSERT_EQUALS("char buf [ $123 ] ;", actual); } void predefine5() { // #3737, #5119 - automatically define __cplusplus // #3737... const char code[] = "#ifdef __cplusplus\n123\n#endif"; - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings0, *this, code, "", "test.c")); - ASSERT_EQUALS("\n123", PreprocessorHelper::getcode(settings0, *this, code, "", "test.cpp")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings0, *this, code, "", "test.c")); + ASSERT_EQUALS("\n123", PreprocessorHelper::getcodeforcfg(settings0, *this, code, "", "test.cpp")); } void predefine6() { // automatically define __STDC_VERSION__ const char code[] = "#ifdef __STDC_VERSION__\n123\n#endif"; - ASSERT_EQUALS("\n123", PreprocessorHelper::getcode(settings0, *this, code, "", "test.c")); - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings0, *this, code, "", "test.cpp")); + ASSERT_EQUALS("\n123", PreprocessorHelper::getcodeforcfg(settings0, *this, code, "", "test.c")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings0, *this, code, "", "test.cpp")); } void strictAnsi() { @@ -2044,22 +2044,22 @@ class TestPreprocessor : public TestFixture { Settings settings; settings.standards.setStd("gnu99"); - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings, *this, code, "", "test.c")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c")); settings.standards.setStd("c99"); - ASSERT_EQUALS("\n123", PreprocessorHelper::getcode(settings, *this, code, "", "test.c")); + ASSERT_EQUALS("\n123", PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c")); settings.standards.setStd("gnu++11"); - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.cpp")); settings.standards.setStd("c++11"); - ASSERT_EQUALS("\n123", PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp")); + ASSERT_EQUALS("\n123", PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.cpp")); } void invalidElIf() { // #2942 - segfault const char code[] = "#elif (){\n"; - const std::string actual = PreprocessorHelper::getcode(settings0, *this, code, "TEST", "test.c"); + const std::string actual = PreprocessorHelper::getcodeforcfg(settings0, *this, code, "TEST", "test.c"); ASSERT_EQUALS("", actual); ASSERT_EQUALS("[test.c:1:0]: (error) #elif without #if [preprocessorErrorDirective]\n", errout_str()); } @@ -2326,7 +2326,7 @@ class TestPreprocessor : public TestFixture { void wrongPathOnErrorDirective() { const auto settings = dinit(Settings, $.userDefines = "foo"); const std::string code("#error hello world!\n"); - (void)PreprocessorHelper::getcode(settings, *this, code, "X", "./././test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "X", "./././test.c"); ASSERT_EQUALS("[test.c:1:0]: (error) #error hello world! [preprocessorErrorDirective]\n", errout_str()); } @@ -2341,7 +2341,7 @@ class TestPreprocessor : public TestFixture { ScopedFile header("header.h", ""); std::string code("#include \"header.h\""); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("", errout_str()); } @@ -2355,7 +2355,7 @@ class TestPreprocessor : public TestFixture { setTemplateFormat("simple"); std::string code("#include \"header.h\""); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: \"header.h\" not found. [missingInclude]\n", errout_str()); } @@ -2371,7 +2371,7 @@ class TestPreprocessor : public TestFixture { ScopedFile header("header.h", "", "inc"); std::string code("#include \"header.h\""); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: \"header.h\" not found. [missingInclude]\n", errout_str()); } @@ -2388,7 +2388,7 @@ class TestPreprocessor : public TestFixture { ScopedFile header("header.h", "", "inc"); std::string code("#include \"inc/header.h\""); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("", errout_str()); } @@ -2405,7 +2405,7 @@ class TestPreprocessor : public TestFixture { ScopedFile header("header.h", "", Path::getCurrentPath()); std::string code("#include \"" + header.path() + "\""); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("", errout_str()); } @@ -2421,7 +2421,7 @@ class TestPreprocessor : public TestFixture { const std::string header = Path::join(Path::getCurrentPath(), "header.h"); std::string code("#include \"" + header + "\""); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: \"" + header + "\" not found. [missingInclude]\n", errout_str()); } @@ -2437,7 +2437,7 @@ class TestPreprocessor : public TestFixture { ScopedFile header("header.h", ""); std::string code("#include "); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); } @@ -2451,7 +2451,7 @@ class TestPreprocessor : public TestFixture { setTemplateFormat("simple"); std::string code("#include "); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); } @@ -2468,7 +2468,7 @@ class TestPreprocessor : public TestFixture { ScopedFile header("header.h", "", "system"); std::string code("#include "); - (void)PreprocessorHelper::getcode(settings0, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings0, *this, code, "", "test.c"); ASSERT_EQUALS("", errout_str()); } @@ -2485,7 +2485,7 @@ class TestPreprocessor : public TestFixture { ScopedFile header("header.h", "", Path::getCurrentPath()); std::string code("#include <" + header.path() + ">"); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("", errout_str()); } @@ -2501,7 +2501,7 @@ class TestPreprocessor : public TestFixture { const std::string header = Path::join(Path::getCurrentPath(), "header.h"); std::string code("#include <" + header + ">"); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: <" + header + "> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); } @@ -2521,7 +2521,7 @@ class TestPreprocessor : public TestFixture { "#include \n" "#include \n" "#include \"header2.h\""); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: \"missing.h\" not found. [missingInclude]\n" "test.c:2:0: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n" @@ -2557,7 +2557,7 @@ class TestPreprocessor : public TestFixture { "#include \"" + missing3 + "\"\n" "#include <" + header6.path() + ">\n" "#include <" + missing4 + ">\n"); - (void)PreprocessorHelper::getcode(settings, *this, code, "", "test.c"); + (void)PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:0: information: Include file: \"missing.h\" not found. [missingInclude]\n" "test.c:2:0: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n" @@ -2572,15 +2572,15 @@ class TestPreprocessor : public TestFixture { Settings settings; settings.standards.setStd("c++11"); - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.cpp")); ASSERT_EQUALS("[test.cpp:1:0]: (error) failed to evaluate #if condition, undefined function-like macro invocation: __has_include( ... ) [preprocessorErrorDirective]\n", errout_str()); settings.standards.setStd("c++17"); - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.cpp")); ASSERT_EQUALS("", errout_str()); settings.standards.setStd("gnu++11"); - ASSERT_EQUALS("", PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp")); + ASSERT_EQUALS("", PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.cpp")); ASSERT_EQUALS("", errout_str()); } @@ -2589,7 +2589,7 @@ class TestPreprocessor : public TestFixture { const char code[] = "void f(long l) {\n" " if (l > INT_MAX) {}\n" "}"; - const std::string actual = PreprocessorHelper::getcode(settings0, *this, code, "", "test.c"); + const std::string actual = PreprocessorHelper::getcodeforcfg(settings0, *this, code, "", "test.c"); ASSERT_EQUALS("void f ( long l ) {\n" "if ( l > $2147483647 ) { }\n" "}", actual); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index af34625ca18..84d94908454 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8702,7 +8702,7 @@ class TestTokenizerCompileLimits : public TestFixture std::vector files; const simplecpp::TokenList tokens1(fin, files, "", &outputList); const std::string filedata = tokens1.stringify(); - const std::string code = PreprocessorHelper::getcode(settingsDefault, *this, filedata, "", "test.c"); + const std::string code = PreprocessorHelper::getcodeforcfg(settingsDefault, *this, filedata, "", "test.c"); ASSERT_THROW_INTERNAL_EQUALS(tokenizeAndStringify(code), AST, "maximum AST depth exceeded"); } diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index 2636ce2db25..34e91c1d977 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -742,7 +742,7 @@ class TestUnusedFunctions : public TestFixture { "};"; const char code[] = R"(#include "test.h")"; ScopedFile header("test.h", inc); - const std::string processed = PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp"); + const std::string processed = PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.cpp"); check(processed); TODO_ASSERT_EQUALS("[test.h:3:6]: (style) The function 'f' is never used. [unusedFunction]\n", "[test.cpp:3:6]: (style) The function 'f' is never used. [unusedFunction]\n", errout_str()); }