File: Rect.test.cpp

package info (click to toggle)
libcsfml 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,240 kB
  • sloc: cpp: 7,741; ansic: 2,616; sh: 805; makefile: 16
file content (56 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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}));
        }
    }
}