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

Method FromXmlV2

test/testerrorlogger.cpp:479–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477 }
478
479 void FromXmlV2() const {
480 const char xmldata[] = "<?xml version=\"1.0\"?>\n"
481 "<error id=\"errorId\""
482 " severity=\"error\""
483 " cwe=\"123\""
484 " inconclusive=\"true\""
485 " msg=\"Programming error.\""
486 " verbose=\"Verbose error\""
487 " hash=\"456\""
488 ">\n"
489 " <location file=\"bar.cpp\" line=\"8\" column=\"1\"/>\n"
490 " <location origfile=\"proj/foo.cpp\" file=\"foo.cpp\" line=\"5\" column=\"2\"/>\n"
491 "</error>";
492 tinyxml2::XMLDocument doc;
493 ASSERT(doc.Parse(xmldata, sizeof(xmldata)) == tinyxml2::XML_SUCCESS);
494 const auto * const rootnode = doc.FirstChildElement();
495 ASSERT(rootnode);
496 ErrorMessage msg(doc.FirstChildElement());
497 ASSERT_EQUALS("errorId", msg.id);
498 ASSERT_EQUALS_ENUM(Severity::error, msg.severity);
499 ASSERT_EQUALS(123u, msg.cwe.id);
500 ASSERT_EQUALS_ENUM(Certainty::inconclusive, msg.certainty);
501 ASSERT_EQUALS("Programming error.", msg.shortMessage());
502 ASSERT_EQUALS("Verbose error", msg.verboseMessage());
503 ASSERT_EQUALS(456u, msg.hash);
504 ASSERT_EQUALS(2u, msg.callStack.size());
505 ASSERT_EQUALS("proj/foo.cpp", msg.callStack.front().getOrigFile(false));
506 ASSERT_EQUALS("foo.cpp", msg.callStack.front().getfile(false));
507 ASSERT_EQUALS(5, msg.callStack.front().line);
508 ASSERT_EQUALS(2u, msg.callStack.front().column);
509 ASSERT_EQUALS("bar.cpp", msg.callStack.back().getOrigFile(false));
510 ASSERT_EQUALS("bar.cpp", msg.callStack.back().getfile(false));
511 ASSERT_EQUALS(8, msg.callStack.back().line);
512 ASSERT_EQUALS(1u, msg.callStack.back().column);
513 }
514
515 void ToXmlV3() const {
516 std::string header("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<results version=\"3\">\n");

Callers

nothing calls this directly

Calls 6

ParseMethod · 0.80
FirstChildElementMethod · 0.80
frontMethod · 0.80
getfileMethod · 0.80
sizeMethod · 0.45
getOrigFileMethod · 0.45

Tested by

no test coverage detected