-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add operator+ and operator+= to Rect<T> (#875)
Co-authored-by: Lars Skiba <[email protected]>
- Loading branch information
1 parent
7f41c18
commit 6a346b4
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <gtest/gtest.h> | ||
#include "clipper2/clipper.core.h" | ||
|
||
using namespace Clipper2Lib; | ||
|
||
TEST(Clipper2Tests, TestRectOpPlus) | ||
{ | ||
{ | ||
Rect64 lhs = Rect64::InvalidRect(); | ||
Rect64 rhs(-1, -1, 10, 10); | ||
{ | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(rhs, sum); | ||
} | ||
{ | ||
std::swap(lhs, rhs); | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(lhs, sum); | ||
} | ||
} | ||
{ | ||
Rect64 lhs = Rect64::InvalidRect(); | ||
Rect64 rhs(1, 1, 10, 10); | ||
{ | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(rhs, sum); | ||
} | ||
{ | ||
std::swap(lhs, rhs); | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(lhs, sum); | ||
} | ||
} | ||
{ | ||
Rect64 lhs(0, 0, 1, 1); | ||
Rect64 rhs(-1, -1, 0, 0); | ||
Rect64 expected(-1, -1, 1, 1); | ||
{ | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(expected, sum); | ||
} | ||
{ | ||
std::swap(lhs, rhs); | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(expected, sum); | ||
} | ||
} | ||
{ | ||
Rect64 lhs(-10, -10, -1, -1); | ||
Rect64 rhs(1, 1, 10, 10); | ||
Rect64 expected(-10, -10, 10, 10); | ||
{ | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(expected, sum); | ||
} | ||
{ | ||
std::swap(lhs, rhs); | ||
Rect64 sum = lhs + rhs; | ||
EXPECT_EQ(expected, sum); | ||
} | ||
} | ||
} |