Added equality operator to Location class.

This commit is contained in:
Oliver Hamlet
2015-07-12 18:39:03 +01:00
parent e538549a2c
commit db31e22f40
3 changed files with 22 additions and 0 deletions
+4
View File
@@ -39,6 +39,10 @@ namespace loot {
return boost::ilexicographical_compare(_url, rhs.URL());
}
bool Location::operator == (const Location& rhs) const {
return boost::iequals(_url, rhs.URL());
}
std::string Location::URL() const {
return _url;
}
+1
View File
@@ -37,6 +37,7 @@ namespace loot {
Location(const std::string& url, const std::vector<std::string>& versions);
bool operator < (const Location& rhs) const;
bool operator == (const Location& rhs) const;
std::string URL() const;
std::vector<std::string> Versions() const;
@@ -48,6 +48,23 @@ TEST(Location, ConstructorsAndDataAccess) {
}), loc.Versions());
}
TEST(Location, EqualityOperator) {
Location loc1, loc2;
EXPECT_TRUE(loc1 == loc2);
loc1 = Location("http://www.example.com");
loc2 = Location("HTTP://WWW.EXAMPLE.COM");
EXPECT_TRUE(loc1 == loc2);
loc1 = Location("http://www.example.com", {"1.0"});
loc2 = Location("http://www.example.com", {"1.1"});
EXPECT_TRUE(loc1 == loc2);
loc1 = Location("http://www.example1.com");
loc2 = Location("http://www.example2.com");
EXPECT_FALSE(loc1 == loc2);
}
TEST(Location, LessThanOperator) {
Location loc1, loc2;
EXPECT_FALSE(loc1 < loc2);