ErrorLogger: Refactoring/fixing the serializer/deserializer for inconclusive messages
This commit is contained in:
parent
f9c97c7b56
commit
0beef13794
|
@ -70,7 +70,11 @@ std::string ErrorLogger::ErrorMessage::serialize() const
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << _id.length() << " " << _id;
|
oss << _id.length() << " " << _id;
|
||||||
oss << Severity::toString(_severity).length() << " " << Severity::toString(_severity);
|
oss << Severity::toString(_severity).length() << " " << Severity::toString(_severity);
|
||||||
oss << (_inconclusive ? "12 inconclusive" : "");
|
if (_inconclusive)
|
||||||
|
{
|
||||||
|
const std::string inconclusive("inconclusive");
|
||||||
|
oss << inconclusive.length() << " " << inconclusive;
|
||||||
|
}
|
||||||
oss << _shortMessage.length() << " " << _shortMessage;
|
oss << _shortMessage.length() << " " << _shortMessage;
|
||||||
oss << _verboseMessage.length() << " " << _verboseMessage;
|
oss << _verboseMessage.length() << " " << _verboseMessage;
|
||||||
oss << _callStack.size() << " ";
|
oss << _callStack.size() << " ";
|
||||||
|
@ -108,7 +112,7 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
|
||||||
if (temp == "inconclusive")
|
if (temp == "inconclusive")
|
||||||
{
|
{
|
||||||
_inconclusive = true;
|
_inconclusive = true;
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
results.push_back(temp);
|
results.push_back(temp);
|
||||||
|
|
|
@ -43,6 +43,9 @@ private:
|
||||||
|
|
||||||
// Inconclusive results in xml reports..
|
// Inconclusive results in xml reports..
|
||||||
TEST_CASE(InconclusiveXml);
|
TEST_CASE(InconclusiveXml);
|
||||||
|
|
||||||
|
// Serialize / Deserialize inconclusive message
|
||||||
|
TEST_CASE(SerializeInconclusiveMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLocationDefaults()
|
void FileLocationDefaults()
|
||||||
|
@ -184,5 +187,26 @@ private:
|
||||||
// TODO: how should inconclusive messages be saved when the xml version is 2?
|
// TODO: how should inconclusive messages be saved when the xml version is 2?
|
||||||
ASSERT_EQUALS("", msg.toXML(false, 2));
|
ASSERT_EQUALS("", msg.toXML(false, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SerializeInconclusiveMessage()
|
||||||
|
{
|
||||||
|
// Inconclusive error message
|
||||||
|
std::list<ErrorLogger::ErrorMessage::FileLocation> locs;
|
||||||
|
ErrorMessage msg(locs, Severity::error, "Programming error", "errorId", true);
|
||||||
|
ASSERT_EQUALS("7 errorId"
|
||||||
|
"5 error"
|
||||||
|
"12 inconclusive"
|
||||||
|
"17 Programming error"
|
||||||
|
"17 Programming error"
|
||||||
|
"0 ", msg.serialize());
|
||||||
|
|
||||||
|
ErrorMessage msg2;
|
||||||
|
msg2.deserialize(msg.serialize());
|
||||||
|
ASSERT_EQUALS("errorId", msg2._id);
|
||||||
|
ASSERT_EQUALS(Severity::error, msg2._severity);
|
||||||
|
ASSERT_EQUALS(true, msg2._inconclusive);
|
||||||
|
ASSERT_EQUALS("Programming error", msg2.shortMessage());
|
||||||
|
ASSERT_EQUALS("Programming error", msg2.verboseMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
REGISTER_TEST(TestErrorLogger)
|
REGISTER_TEST(TestErrorLogger)
|
||||||
|
|
Loading…
Reference in New Issue