From 9b9b9c99f53ccb84a3f489be6b6ff4d86013c8dd Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 3 Feb 2011 09:44:23 +0200 Subject: [PATCH] Add test for XML format version 2. --- test/testerrorlogger.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/testerrorlogger.cpp b/test/testerrorlogger.cpp index fd10cba36..e716602a5 100644 --- a/test/testerrorlogger.cpp +++ b/test/testerrorlogger.cpp @@ -17,6 +17,7 @@ */ #include +#include "cppcheck.h" #include "testsuite.h" #include "errorlogger.h" @@ -38,6 +39,7 @@ private: TEST_CASE(CustomFormat2); TEST_CASE(ToXml); TEST_CASE(ToVerboseXml); + TEST_CASE(ToXmlV2); } void FileLocationDefaults() @@ -140,5 +142,25 @@ private: ASSERT_EQUALS("", ErrorLogger::ErrorMessage::getXMLFooter(1)); ASSERT_EQUALS("", msg.toXML(true,1)); } + + void ToXmlV2() + { + ErrorLogger::ErrorMessage::FileLocation loc; + loc.setfile("foo.cpp"); + loc.line = 5; + std::list locs; + locs.push_back(loc); + ErrorMessage msg(locs, Severity::error, "Programming error.\nVerbose error", "errorId"); + std::string header("\n\n"); + header += " \n "; + ASSERT_EQUALS(header, ErrorLogger::ErrorMessage::getXMLHeader(2)); + ASSERT_EQUALS(" \n", ErrorLogger::ErrorMessage::getXMLFooter(2)); + std::string message(" \n"; + message += " \n "; + ASSERT_EQUALS(message, msg.toXML(false,2)); + } }; REGISTER_TEST(TestErrorLogger)