Skip to content

Commit

Permalink
Add Rect::resize method
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Jul 5, 2020
1 parent 94dfd71 commit f76dbbd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ class Rect final {
*/
constexpr void set_height(T height) noexcept { m_size.height = height; }

/**
* @brief Changes the size of the rectangle.
*
* @param size the new size of the rectangle.
*
* @since 4.2.0
*/
constexpr void resize(TArea<T> size) noexcept
{
m_size.width = size.width;
m_size.height = size.height;
};

/**
* @brief Sets all of the components of the rectangle.
*
Expand Down
20 changes: 20 additions & 0 deletions test/unittests/rect_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ TEST_CASE("IRect::set_height", "[Rect]")
CHECK(height == rect.height());
}

TEST_CASE("IRect::resize", "[Rect]")
{
IRect rect;

const IArea size{8596, 9235};
rect.resize(size);

CHECK(rect.size() == size);
}

TEST_CASE("IRect::set", "[Rect]")
{
IRect rect;
Expand Down Expand Up @@ -474,6 +484,16 @@ TEST_CASE("FRect::set_height", "[FRect]")
CHECK(rect.height() == height);
}

TEST_CASE("FRect::resize", "[FRect]")
{
FRect rect;

const FArea size{859.6f, 773.4f};
rect.resize(size);

CHECK(rect.size() == size);
}

TEST_CASE("FRect::set", "[FRect]")
{
FRect rect;
Expand Down

0 comments on commit f76dbbd

Please sign in to comment.