Improve test coverage of sf::Rect
This commit is contained in:
parent
b009151e89
commit
3925139f4d
@ -50,8 +50,6 @@ TEST_CASE("sf::Rect class template - [graphics]")
|
||||
}
|
||||
}
|
||||
|
||||
SUBCASE("Containment")
|
||||
{
|
||||
SUBCASE("contains(Vector2)")
|
||||
{
|
||||
sf::IntRect rectangle({0, 0}, {10, 10});
|
||||
@ -65,9 +63,8 @@ TEST_CASE("sf::Rect class template - [graphics]")
|
||||
CHECK(rectangle.contains(sf::Vector2i(10, 10)) == false);
|
||||
CHECK(rectangle.contains(sf::Vector2i(15, 15)) == false);
|
||||
}
|
||||
}
|
||||
|
||||
SUBCASE("Intersection")
|
||||
SUBCASE("findIntersection()")
|
||||
{
|
||||
const sf::IntRect rectangle({0, 0}, {10, 10});
|
||||
const sf::IntRect intersectingRectangle({5, 5}, {10, 10});
|
||||
@ -84,13 +81,40 @@ TEST_CASE("sf::Rect class template - [graphics]")
|
||||
CHECK_FALSE(rectangle.findIntersection(nonIntersectingRectangle));
|
||||
}
|
||||
|
||||
SUBCASE("Comparison operations")
|
||||
SUBCASE("getPosition()")
|
||||
{
|
||||
sf::IntRect firstRectangle({1, 3}, {2, 5});
|
||||
sf::IntRect secondRectangle({1, 3}, {2, 5});
|
||||
sf::IntRect differentRectangle({3, 1}, {5, 2});
|
||||
CHECK(sf::IntRect({}, {}).getPosition() == sf::Vector2i());
|
||||
CHECK(sf::IntRect({1, 2}, {3, 4}).getPosition() == sf::Vector2i(1, 2));
|
||||
}
|
||||
|
||||
CHECK(firstRectangle == secondRectangle);
|
||||
CHECK(firstRectangle != differentRectangle);
|
||||
SUBCASE("getSize()")
|
||||
{
|
||||
CHECK(sf::IntRect({}, {}).getSize() == sf::Vector2i());
|
||||
CHECK(sf::IntRect({1, 2}, {3, 4}).getSize() == sf::Vector2i(3, 4));
|
||||
}
|
||||
|
||||
SUBCASE("Operators")
|
||||
{
|
||||
SUBCASE("operator==")
|
||||
{
|
||||
CHECK(sf::IntRect() == sf::IntRect());
|
||||
CHECK(sf::IntRect({1, 3}, {2, 5}) == sf::IntRect({1, 3}, {2, 5}));
|
||||
|
||||
CHECK_FALSE(sf::IntRect({1, 0}, {0, 0}) == sf::IntRect({0, 0}, {0, 0}));
|
||||
CHECK_FALSE(sf::IntRect({0, 1}, {0, 0}) == sf::IntRect({0, 0}, {0, 0}));
|
||||
CHECK_FALSE(sf::IntRect({0, 0}, {1, 0}) == sf::IntRect({0, 0}, {0, 0}));
|
||||
CHECK_FALSE(sf::IntRect({0, 0}, {0, 1}) == sf::IntRect({0, 0}, {0, 0}));
|
||||
}
|
||||
|
||||
SUBCASE("operator!=")
|
||||
{
|
||||
CHECK(sf::IntRect({1, 0}, {0, 0}) != sf::IntRect({0, 0}, {0, 0}));
|
||||
CHECK(sf::IntRect({0, 1}, {0, 0}) != sf::IntRect({0, 0}, {0, 0}));
|
||||
CHECK(sf::IntRect({0, 0}, {1, 0}) != sf::IntRect({0, 0}, {0, 0}));
|
||||
CHECK(sf::IntRect({0, 0}, {0, 1}) != sf::IntRect({0, 0}, {0, 0}));
|
||||
|
||||
CHECK_FALSE(sf::IntRect() != sf::IntRect());
|
||||
CHECK_FALSE(sf::IntRect({1, 3}, {2, 5}) != sf::IntRect({1, 3}, {2, 5}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user