Make message comparison operators consistent.

Message and MessageContent less-than and equality operators have been
tweaked to have consistent behaviour, by comparing only content strings
and ignoring message type and language.
This commit is contained in:
Oliver Hamlet
2015-07-12 18:37:41 +01:00
parent de65d4fcf9
commit 897b6ecea8
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -47,14 +47,14 @@ namespace loot {
bool Message::operator < (const Message& rhs) const {
if (!_content.empty() && !rhs.Content().empty())
return boost::ilexicographical_compare(_content.front().Str(), rhs.Content().front().Str());
else if (_content.empty())
else if (_content.empty() && !rhs.Content().empty())
return true;
else
return false;
}
bool Message::operator == (const Message& rhs) const {
return (_type == rhs.Type() && _content == rhs.Content());
return (_content == rhs.Content());
}
bool Message::EvalCondition(loot::Game& game, const unsigned int language) {
+1 -1
View File
@@ -47,7 +47,7 @@ namespace loot {
}
bool MessageContent::operator == (const MessageContent& rhs) const {
return (_language == rhs.Language() && boost::iequals(_str, rhs.Str()));
return (boost::iequals(_str, rhs.Str()));
}
}
@@ -55,7 +55,7 @@ TEST(MessageContent, EqualityOperator) {
mc1 = MessageContent("content", Language::english);
mc2 = MessageContent("Content", Language::french);
EXPECT_FALSE(mc1 == mc2);
EXPECT_TRUE(mc1 == mc2);
}
TEST(MessageContent, LessThanOperator) {