mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-25 21:06:12 +01:00
Add tests for sfRect
This commit is contained in:
1 parent
e7a41e864f
commit
e46663cf38
2 files changed
+63
No files matched your search
@@ -0,0 +1,56 @@
|
||||
#include <CSFML/Graphics/Rect.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Graphics] sfRect")
|
||||
{
|
||||
SECTION("Construction")
|
||||
{
|
||||
SECTION("float")
|
||||
{
|
||||
const sfFloatRect rect{};
|
||||
CHECK(rect.position.x == 0.f);
|
||||
CHECK(rect.position.y == 0.f);
|
||||
CHECK(rect.size.x == 0.f);
|
||||
CHECK(rect.size.y == 0.f);
|
||||
}
|
||||
|
||||
SECTION("int")
|
||||
{
|
||||
const sfFloatRect rect{};
|
||||
CHECK(rect.position.x == 0);
|
||||
CHECK(rect.position.y == 0);
|
||||
CHECK(rect.size.x == 0);
|
||||
CHECK(rect.size.y == 0);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("contains(Vector2)")
|
||||
{
|
||||
SECTION("float")
|
||||
{
|
||||
const sfFloatRect rect{{0, 0}, {10, 10}};
|
||||
CHECK(sfFloatRect_contains(&rect, {0, 0}));
|
||||
CHECK(sfFloatRect_contains(&rect, {9, 0}));
|
||||
CHECK(sfFloatRect_contains(&rect, {0, 9}));
|
||||
CHECK(sfFloatRect_contains(&rect, {9, 9}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {9, 10}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {10, 9}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {10, 10}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {15, 15}));
|
||||
}
|
||||
|
||||
SECTION("int")
|
||||
{
|
||||
const sfIntRect rect{{0, 0}, {10, 10}};
|
||||
CHECK(sfIntRect_contains(&rect, {0, 0}));
|
||||
CHECK(sfIntRect_contains(&rect, {9, 0}));
|
||||
CHECK(sfIntRect_contains(&rect, {0, 9}));
|
||||
CHECK(sfIntRect_contains(&rect, {9, 9}));
|
||||
CHECK(!sfIntRect_contains(&rect, {9, 10}));
|
||||
CHECK(!sfIntRect_contains(&rect, {10, 9}));
|
||||
CHECK(!sfIntRect_contains(&rect, {10, 10}));
|
||||
CHECK(!sfIntRect_contains(&rect, {15, 15}));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user