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

Method ruleFileSingle

test/testcmdlineparser.cpp:2751–2773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2749 }
2750
2751 void ruleFileSingle() {
2752 REDIRECT;
2753 ScopedFile file("rule.xml",
2754 "<rule>\n"
2755 "<tokenlist>define</tokenlist>\n"
2756 "<pattern>.+</pattern>\n"
2757 "<message>\n"
2758 "<severity>error</severity>\n"
2759 "<id>ruleId</id>\n"
2760 "<summary>ruleSummary</summary>\n"
2761 "</message>\n"
2762 "</rule>\n");
2763 const char * const argv[] = {"cppcheck", "--rule-file=rule.xml", "file.cpp"};
2764 ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parseFromArgs(argv));
2765 ASSERT_EQUALS(1, settings->rules.size());
2766 auto it = settings->rules.cbegin();
2767 ASSERT_EQUALS_ENUM(Regex::Engine::Pcre, it->regex->engine());
2768 ASSERT_EQUALS("define", it->tokenlist);
2769 ASSERT_EQUALS(".+", it->pattern);
2770 ASSERT_EQUALS_ENUM(Severity::error, it->severity);
2771 ASSERT_EQUALS("ruleId", it->id);
2772 ASSERT_EQUALS("ruleSummary", it->summary);
2773 }
2774
2775 void ruleFileEmpty() {
2776 REDIRECT;

Callers

nothing calls this directly

Calls 2

engineMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected