mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user