diff --git a/docs/metadata/data_structures/location.rst b/docs/metadata/data_structures/location.rst index 97b66065..65d0b4e4 100644 --- a/docs/metadata/data_structures/location.rst +++ b/docs/metadata/data_structures/location.rst @@ -22,7 +22,7 @@ The scalar form is simply the value of the map form's ``link`` key. Using the sc Equality -------- -Two location data structures are equal if the lowercased values of their ``link`` keys are identical. +Two location data structures are equal if the values of their ``link`` keys are identical. Examples -------- diff --git a/docs/metadata/data_structures/message.rst b/docs/metadata/data_structures/message.rst index 3a9e6a36..712bc5fd 100644 --- a/docs/metadata/data_structures/message.rst +++ b/docs/metadata/data_structures/message.rst @@ -57,12 +57,8 @@ If a message's ``content`` value is a string, the message will use the string as Equality -------- -The equality of two message data structures is determined by comparing the values of their ``content`` keys. As the values of the keys can be different types, a comparison value is selected for each message using the following logic: - -* If a value's type is a localised content list, then the English content string in that list is selected as the comparison value. -* If a value's type is a string, then that string is selected as the comparison value. - -The two message data structures are then equal if their lowercased comparison values are identical. +The equality of two message data structures is determined by comparing the values of their ``content`` keys. If a content key is a string, it is treated as a localised content list +containing a single English-language string. The two message data structures are then equal if their localised content lists are identical. Examples -------- diff --git a/docs/metadata/data_structures/tag.rst b/docs/metadata/data_structures/tag.rst index 56d69896..468f3623 100644 --- a/docs/metadata/data_structures/tag.rst +++ b/docs/metadata/data_structures/tag.rst @@ -22,7 +22,7 @@ The scalar form is simply the value of the map form's ``name`` key. Using the sc Equality -------- -Two tag data structures are equal if the lowercased values of their ``name`` keys are identical. +Two tag data structures are equal if the values of their ``name`` keys are identical. Examples -------- diff --git a/include/loot/metadata/location.h b/include/loot/metadata/location.h index 8e343b2c..7326d61d 100644 --- a/include/loot/metadata/location.h +++ b/include/loot/metadata/location.h @@ -54,15 +54,14 @@ public: /** * A less-than operator implemented with no semantics so that Location objects * can be stored in sets. - * @returns True if this Location's URL is case-insensitively - * lexicographically less than the given Location's URL, false - * otherwise. + * @returns True if this Location's URL string is lexicographically less than + * the given Location's URL string, false otherwise. */ LOOT_API bool operator<(const Location& rhs) const; /** * Check if two Location objects are equal by comparing their URLs. - * @returns True if the URLs are case-insensitively equal, false otherwise. + * @returns True if the URL strings are equal, false otherwise. */ LOOT_API bool operator==(const Location& rhs) const; diff --git a/include/loot/metadata/message.h b/include/loot/metadata/message.h index e27dfa2e..b282ba45 100644 --- a/include/loot/metadata/message.h +++ b/include/loot/metadata/message.h @@ -79,11 +79,8 @@ public: /** * A less-than operator implemented with no semantics so that Message objects * can be stored in sets. - * @returns If both messages have content, returns true if this Message's - * English text is case-insensitively lexicographically less than the - * given Message's English text, and false otherwise. - * Otherwise returns true if this Message has no content, and false - * otherwise. + * @returns Returns true if this Message's content is lexicographically less + * than the given Message's content, and false otherwise. */ LOOT_API bool operator<(const Message& rhs) const; diff --git a/include/loot/metadata/message_content.h b/include/loot/metadata/message_content.h index c9c7e430..238a01b1 100644 --- a/include/loot/metadata/message_content.h +++ b/include/loot/metadata/message_content.h @@ -73,15 +73,14 @@ public: /** * A less-than operator implemented with no semantics so that MessageContent * objects can be stored in sets. - * @returns True if this MessageContent's text is case-insensitively - * lexicographically less than the given MessageContent's text, false - * otherwise. + * @returns True if this MessageContent's text is lexicographically less than + * the given MessageContent's text, false otherwise. */ LOOT_API bool operator<(const MessageContent& rhs) const; /** * Check if two MessageContent objects are equal by comparing their texts. - * @returns True if the texts are case-insensitively equal, false otherwise. + * @returns True if the texts are equal, false otherwise. */ LOOT_API bool operator==(const MessageContent& rhs) const; diff --git a/include/loot/metadata/tag.h b/include/loot/metadata/tag.h index 97001243..f3b9fdc4 100644 --- a/include/loot/metadata/tag.h +++ b/include/loot/metadata/tag.h @@ -62,17 +62,15 @@ public: * can be stored in sets. * @returns True if this Tag is suggested for addition and the other is not. * If both Tags are suggested for addition or both are suggested for - * removal, returns true if this Tag's name is case-insensitively - * lexicographically less than the given Tag's name, false - * otherwise. + * removal, returns true if this Tag's name is lexicographically less + * than the given Tag's name, false otherwise. */ LOOT_API bool operator<(const Tag& rhs) const; /** * Check if two Tag objects are equal. * @returns True if both Tags are suggested for addition or both are suggested - * for removal, and the Tag names are case-insensitively equal, false - * otherwise. + * for removal, and the Tag names are equal, false otherwise. */ LOOT_API bool operator==(const Tag& rhs) const; diff --git a/src/api/metadata/location.cpp b/src/api/metadata/location.cpp index b2410ba3..e2416a90 100644 --- a/src/api/metadata/location.cpp +++ b/src/api/metadata/location.cpp @@ -24,8 +24,6 @@ #include "loot/metadata/location.h" -#include - namespace loot { Location::Location() {} @@ -34,11 +32,11 @@ Location::Location(const std::string& url, const std::string& name) : name_(name) {} bool Location::operator<(const Location& rhs) const { - return boost::ilexicographical_compare(url_, rhs.GetURL()); + return url_ < rhs.url_; } bool Location::operator==(const Location& rhs) const { - return boost::iequals(url_, rhs.GetURL()); + return url_ == rhs.url_; } std::string Location::GetURL() const { return url_; } diff --git a/src/api/metadata/message.cpp b/src/api/metadata/message.cpp index b25ffa4d..0a130068 100644 --- a/src/api/metadata/message.cpp +++ b/src/api/metadata/message.cpp @@ -59,18 +59,11 @@ Message::Message(const MessageType type, } bool Message::operator<(const Message& rhs) const { - if (!content_.empty() && !rhs.GetContent().empty()) - return boost::ilexicographical_compare( - GetContent(MessageContent::defaultLanguage).GetText(), - rhs.GetContent(MessageContent::defaultLanguage).GetText()); - else if (content_.empty() && !rhs.GetContent().empty()) - return true; - else - return false; + return content_ < rhs.GetContent(); } bool Message::operator==(const Message& rhs) const { - return (content_ == rhs.GetContent()); + return content_ == rhs.GetContent(); } MessageType Message::GetType() const { return type_; } diff --git a/src/api/metadata/message_content.cpp b/src/api/metadata/message_content.cpp index 1454dd7b..019e0fd8 100644 --- a/src/api/metadata/message_content.cpp +++ b/src/api/metadata/message_content.cpp @@ -41,11 +41,11 @@ std::string MessageContent::GetText() const { return text_; } std::string MessageContent::GetLanguage() const { return language_; } bool MessageContent::operator<(const MessageContent& rhs) const { - return boost::ilexicographical_compare(text_, rhs.GetText()); + return text_ < rhs.text_; } bool MessageContent::operator==(const MessageContent& rhs) const { - return (boost::iequals(text_, rhs.GetText())); + return text_ == rhs.text_; } MessageContent MessageContent::Choose(const std::vector content, const std::string& language) { diff --git a/src/api/metadata/tag.cpp b/src/api/metadata/tag.cpp index 0a684775..93440a02 100644 --- a/src/api/metadata/tag.cpp +++ b/src/api/metadata/tag.cpp @@ -38,14 +38,14 @@ Tag::Tag(const std::string& tag, bool Tag::operator<(const Tag& rhs) const { if (addTag_ != rhs.IsAddition()) - return (addTag_ && !rhs.IsAddition()); + return addTag_ && !rhs.IsAddition(); else - return boost::ilexicographical_compare(GetName(), rhs.GetName()); + return GetName() < rhs.GetName(); } bool Tag::operator==(const Tag& rhs) const { - return (addTag_ == rhs.IsAddition() && - boost::iequals(GetName(), rhs.GetName())); + return addTag_ == rhs.IsAddition() && + GetName() == rhs.GetName(); } bool Tag::IsAddition() const { return addTag_; } diff --git a/src/tests/api/internals/metadata/location_test.h b/src/tests/api/internals/metadata/location_test.h index 6add8f00..806b1d7c 100644 --- a/src/tests/api/internals/metadata/location_test.h +++ b/src/tests/api/internals/metadata/location_test.h @@ -47,11 +47,16 @@ TEST(Location, stringsConstructorShouldStoreGivenStrings) { EXPECT_EQ("example", location.GetName()); } -TEST(Location, locationsWithCaseInsensitiveEqualUrlsShouldBeEqual) { +TEST(Location, locationsWithCaseSensitiveEqualUrlsShouldBeEqual) { Location location1("http://www.example.com", "example1"); - Location location2("HTTP://WWW.EXAMPLE.COM", "example2"); + Location location2("http://www.example.com", "example2"); EXPECT_TRUE(location1 == location2); + + location1 = Location("http://www.example.com"); + location2 = Location("HTTP://WWW.EXAMPLE.COM"); + + EXPECT_FALSE(location1 == location2); } TEST(Location, locationsWithDifferentUrlsShouldBeUnequal) { @@ -62,13 +67,19 @@ TEST(Location, locationsWithDifferentUrlsShouldBeUnequal) { } TEST(Location, - lessThanOperatorShouldUseCaseInsensitiveLexicographicalUrlComparison) { + lessThanOperatorShouldUseCaseSensitiveLexicographicalUrlComparison) { Location location1("http://www.example.com", "example1"); - Location location2("HTTP://WWW.EXAMPLE.COM", "example2"); + Location location2("http://www.example.com", "example2"); EXPECT_FALSE(location1 < location2); EXPECT_FALSE(location2 < location1); + location1 = Location("http://www.example.com"); + location2 = Location("HTTP://WWW.EXAMPLE.COM"); + + EXPECT_FALSE(location1 < location2); + EXPECT_TRUE(location2 < location1); + location1 = Location("http://www.example1.com"); location2 = Location("http://www.example2.com"); diff --git a/src/tests/api/internals/metadata/message_content_test.h b/src/tests/api/internals/metadata/message_content_test.h index a2ef0cf8..dfce00f5 100644 --- a/src/tests/api/internals/metadata/message_content_test.h +++ b/src/tests/api/internals/metadata/message_content_test.h @@ -51,9 +51,14 @@ TEST(MessageContent, contentConstructorShouldStoreGivenStringAndLanguage) { TEST(MessageContent, contentShouldBeEqualIfStringsAreCaseInsensitivelyEqual) { MessageContent content1("content"); - MessageContent content2("Content", french); + MessageContent content2("content", french); EXPECT_TRUE(content1 == content2); + + content1 = MessageContent("content"); + content2 = MessageContent("Content", french); + + EXPECT_FALSE(content1 == content2); } TEST(MessageContent, @@ -65,13 +70,19 @@ TEST(MessageContent, } TEST(MessageContent, - LessThanOperatorShouldUseCaseInsensitiveLexicographicalComparison) { + lessThanOperatorShouldUseCaseSensitiveLexicographicalComparison) { MessageContent content1("content"); - MessageContent content2("Content", french); + MessageContent content2("content", french); EXPECT_FALSE(content1 < content2); EXPECT_FALSE(content2 < content1); + content1 = MessageContent("content", french); + content2 = MessageContent("Content"); + + EXPECT_FALSE(content1 < content2); + EXPECT_TRUE(content2 < content1); + content1 = MessageContent("content1", french); content2 = MessageContent("content2"); diff --git a/src/tests/api/internals/metadata/tag_test.h b/src/tests/api/internals/metadata/tag_test.h index 3593ed73..97bd7570 100644 --- a/src/tests/api/internals/metadata/tag_test.h +++ b/src/tests/api/internals/metadata/tag_test.h @@ -52,10 +52,15 @@ TEST(Tag, dataConstructorShouldSetFieldsToGivenValues) { TEST(Tag, tagsWithCaseInsensitiveEqualNamesAndEqualAdditionStatesShouldBeEqual) { - Tag tag1("Name", true, "condition1"); + Tag tag1("name", true, "condition1"); Tag tag2("name", true, "condition2"); EXPECT_TRUE(tag1 == tag2); + + tag1 = Tag("name"); + tag2 = Tag("Name"); + + EXPECT_FALSE(tag1 == tag2); } TEST(Tags, tagsWithUnequalNamesShouldNotBeEqual) { @@ -74,13 +79,19 @@ TEST(Tag, tagsWithUnequalAdditionStatesShouldNotBeEqual) { TEST( Tag, - lessThanOperatorShouldCaseInsensitivelyLexicographicallyCompareNameStrings) { - Tag tag1("Name"); + lessThanOperatorShouldCaseSensitivelyLexicographicallyCompareNameStrings) { + Tag tag1("name"); Tag tag2("name"); EXPECT_FALSE(tag1 < tag2); EXPECT_FALSE(tag2 < tag1); + tag1 = Tag("name"); + tag2 = Tag("Name"); + + EXPECT_FALSE(tag1 < tag2); + EXPECT_TRUE(tag2 < tag1); + tag1 = Tag("name1"); tag2 = Tag("name2");