MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / hasInclude

Method hasInclude

test/testpreprocessor.cpp:3045–3060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3043 }
3044
3045 void hasInclude() {
3046 const char code[] = "#if __has_include(<directory/non-existent-header.h>)\n123\n#endif";
3047 Settings settings;
3048
3049 settings.standards.setStd("c++11");
3050 ASSERT_EQUALS("", getcodeforcfg(settings, *this, code, "", "test.cpp"));
3051 ASSERT_EQUALS("[test.cpp:1:2]: (error) failed to evaluate #if condition, undefined function-like macro invocation: __has_include( ... ) [syntaxError]\n", errout_str()); // TODO: use individual ID
3052
3053 settings.standards.setStd("c++17");
3054 ASSERT_EQUALS("", getcodeforcfg(settings, *this, code, "", "test.cpp"));
3055 ASSERT_EQUALS("", errout_str());
3056
3057 settings.standards.setStd("gnu++11");
3058 ASSERT_EQUALS("", getcodeforcfg(settings, *this, code, "", "test.cpp"));
3059 ASSERT_EQUALS("", errout_str());
3060 }
3061
3062 void limitsDefines() {
3063 // #11928 / #10045

Callers

nothing calls this directly

Calls 1

setStdMethod · 0.45

Tested by

no test coverage detected