Improve test coverage of sf::Rect
This commit is contained in:
parent
b009151e89
commit
3925139f4d
@ -50,24 +50,21 @@ TEST_CASE("sf::Rect class template - [graphics]")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("Containment")
|
SUBCASE("contains(Vector2)")
|
||||||
{
|
{
|
||||||
SUBCASE("contains(Vector2)")
|
sf::IntRect rectangle({0, 0}, {10, 10});
|
||||||
{
|
|
||||||
sf::IntRect rectangle({0, 0}, {10, 10});
|
|
||||||
|
|
||||||
CHECK(rectangle.contains(sf::Vector2i(0, 0)) == true);
|
CHECK(rectangle.contains(sf::Vector2i(0, 0)) == true);
|
||||||
CHECK(rectangle.contains(sf::Vector2i(9, 0)) == true);
|
CHECK(rectangle.contains(sf::Vector2i(9, 0)) == true);
|
||||||
CHECK(rectangle.contains(sf::Vector2i(0, 9)) == true);
|
CHECK(rectangle.contains(sf::Vector2i(0, 9)) == true);
|
||||||
CHECK(rectangle.contains(sf::Vector2i(9, 9)) == true);
|
CHECK(rectangle.contains(sf::Vector2i(9, 9)) == true);
|
||||||
CHECK(rectangle.contains(sf::Vector2i(9, 10)) == false);
|
CHECK(rectangle.contains(sf::Vector2i(9, 10)) == false);
|
||||||
CHECK(rectangle.contains(sf::Vector2i(10, 9)) == false);
|
CHECK(rectangle.contains(sf::Vector2i(10, 9)) == false);
|
||||||
CHECK(rectangle.contains(sf::Vector2i(10, 10)) == false);
|
CHECK(rectangle.contains(sf::Vector2i(10, 10)) == false);
|
||||||
CHECK(rectangle.contains(sf::Vector2i(15, 15)) == false);
|
CHECK(rectangle.contains(sf::Vector2i(15, 15)) == false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("Intersection")
|
SUBCASE("findIntersection()")
|
||||||
{
|
{
|
||||||
const sf::IntRect rectangle({0, 0}, {10, 10});
|
const sf::IntRect rectangle({0, 0}, {10, 10});
|
||||||
const sf::IntRect intersectingRectangle({5, 5}, {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));
|
CHECK_FALSE(rectangle.findIntersection(nonIntersectingRectangle));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("Comparison operations")
|
SUBCASE("getPosition()")
|
||||||
{
|
{
|
||||||
sf::IntRect firstRectangle({1, 3}, {2, 5});
|
CHECK(sf::IntRect({}, {}).getPosition() == sf::Vector2i());
|
||||||
sf::IntRect secondRectangle({1, 3}, {2, 5});
|
CHECK(sf::IntRect({1, 2}, {3, 4}).getPosition() == sf::Vector2i(1, 2));
|
||||||
sf::IntRect differentRectangle({3, 1}, {5, 2});
|
}
|
||||||
|
|
||||||
CHECK(firstRectangle == secondRectangle);
|
SUBCASE("getSize()")
|
||||||
CHECK(firstRectangle != differentRectangle);
|
{
|
||||||
|
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