Skip to content

Commit 6b660e9

Browse files
committed
Add GeoRectangle operators ==, != implementation
These operators were declared, but not implemented Relates-To: MINOR Signed-off-by: Mykola Malik <[email protected]>
1 parent 65757ff commit 6b660e9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

olp-cpp-sdk-core/src/geo/coordinates/GeoRectangle.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ bool GeoRectangle::Overlaps(const GeoRectangle& rectangle) const {
120120
return !(west >= rectangle_east || rectangle_west >= east);
121121
}
122122

123+
bool GeoRectangle::operator==(const GeoRectangle& other) const {
124+
return south_west_ == other.south_west_ &&
125+
north_east_ == other.north_east_;
126+
}
127+
128+
bool GeoRectangle::operator!=(const GeoRectangle& other) const {
129+
return !(*this == other);
130+
}
131+
123132
GeoRectangle GeoRectangle::BooleanUnion(const GeoRectangle& other) const {
124133
if (IsEmpty()) {
125134
return other;

olp-cpp-sdk-core/tests/geo/coordinates/GeoRectangleTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ TEST(GeoRectangleTest, Containment) {
8787
GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(0.05, 0.15))));
8888
}
8989

90+
TEST(GeoRectangleTest, OperatorEqual) {
91+
EXPECT_TRUE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)) ==
92+
GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)));
93+
EXPECT_FALSE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)) ==
94+
GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 2)));
95+
EXPECT_FALSE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)) ==
96+
GeoRectangle(GeoCoordinates(1, 0), GeoCoordinates(1, 1)));
97+
}
98+
99+
TEST(GeoRectangleTest, OperatorNotEqual) {
100+
EXPECT_FALSE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)) !=
101+
GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)));
102+
EXPECT_TRUE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)) !=
103+
GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 2)));
104+
EXPECT_TRUE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)) !=
105+
GeoRectangle(GeoCoordinates(1, 0), GeoCoordinates(1, 1)));
106+
}
107+
90108
TEST(GeoRectangleTest, BooleanUnion) {
91109
// Non-connected
92110
{

0 commit comments

Comments
 (0)