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

Method standard

test/testpreprocessor.cpp:3087–3133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3085 }
3086
3087 void standard() {
3088
3089 const char code[] = "int a;";
3090 // TODO: this bypasses the standard determined from the settings - the parameter should not be exposed
3091 simplecpp::DUI dui;
3092
3093 {
3094 dui.std = "c89";
3095 std::vector<std::string> files;
3096 TokenList tokenlist{settingsDefault, Standards::Language::CPP};
3097 preprocess(code, files, "test.cpp", tokenlist, dui);
3098 ASSERT(tokenlist.front());
3099 }
3100
3101 {
3102 dui.std = "gnu23";
3103 std::vector<std::string> files;
3104 TokenList tokenlist{settingsDefault, Standards::Language::CPP};
3105 preprocess(code, files, "test.cpp", tokenlist, dui);
3106 ASSERT(tokenlist.front());
3107 }
3108
3109 {
3110 dui.std = "c++98";
3111 std::vector<std::string> files;
3112 TokenList tokenlist{settingsDefault, Standards::Language::CPP};
3113 preprocess(code, files, "test.cpp", tokenlist, dui);
3114 ASSERT(tokenlist.front());
3115 }
3116
3117 {
3118 dui.std = "gnu++26";
3119 std::vector<std::string> files;
3120 TokenList tokenlist{settingsDefault, Standards::Language::CPP};
3121 preprocess(code, files, "test.cpp", tokenlist, dui);
3122 ASSERT(tokenlist.front());
3123 }
3124
3125 {
3126 dui.std = "gnu77";
3127 std::vector<std::string> files;
3128 TokenList tokenlist{settingsDefault, Standards::Language::CPP};
3129 // TODO: can this happen from application code? if yes we need to turn it into a proper error
3130 ASSERT_THROW_EQUALS(preprocess(code, files, "test.cpp", tokenlist, dui), std::runtime_error, "unexpected simplecpp::Output type 9");
3131 ASSERT(!tokenlist.front()); // nothing is tokenized when an unknown standard is provided
3132 }
3133 }
3134
3135 void writeLocations()
3136 {

Callers

nothing calls this directly

Calls 1

frontMethod · 0.80

Tested by

no test coverage detected