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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 | #include <planet/ui/box.hpp>
#include <felspar/test.hpp>
namespace {
constexpr planet::affine::extents2d unit{1, 1};
constexpr planet::affine::rectangle2d unitbox{{0, 0}, unit};
constexpr planet::affine::rectangle2d testbox{
{2, 3}, planet::affine::point2d{6, 8}};
auto const gh = felspar::testsuite(
"gravity/horizontal",
[](auto check) {
auto const v = planet::ui::within({}, unitbox, unit);
check(v.left()) == 0;
check(v.top()) == 0;
check(v.right()) == 1;
check(v.bottom()) == 1;
},
[](auto check) {
auto const v = planet::ui::within({}, testbox, unit);
check(v.left()) == 2;
check(v.top()) == 3;
check(v.right()) == 6;
check(v.bottom()) == 8;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::left, testbox, unit);
check(v.left()) == 2;
check(v.top()) == 3;
check(v.right()) == 3;
check(v.bottom()) == 8;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::right, testbox, unit);
check(v.left()) == 5;
check(v.top()) == 3;
check(v.right()) == 6;
check(v.bottom()) == 8;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::right | planet::ui::gravity::left,
testbox, unit);
check(v.left()) == 3.5f;
check(v.top()) == 3;
check(v.right()) == 4.5f;
check(v.bottom()) == 8;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::right | planet::ui::gravity::left,
unitbox, {4, 5});
check(v.left()) == -1.5f;
check(v.top()) == 0;
check(v.right()) == 2.5f;
check(v.bottom()) == 1;
});
auto const gv = felspar::testsuite(
"gravity/vertical",
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::top, testbox, unit);
check(v.left()) == 2;
check(v.top()) == 3;
check(v.right()) == 6;
check(v.bottom()) == 4;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::bottom, testbox, unit);
check(v.left()) == 2;
check(v.top()) == 7;
check(v.right()) == 6;
check(v.bottom()) == 8;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::top | planet::ui::gravity::bottom,
testbox, unit);
check(v.left()) == 2;
check(v.top()) == 5;
check(v.right()) == 6;
check(v.bottom()) == 6;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::top | planet::ui::gravity::bottom,
unitbox, {4, 5});
check(v.left()) == 0;
check(v.top()) == -2;
check(v.right()) == 1;
check(v.bottom()) == 3;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::top | planet::ui::gravity::bottom
| planet::ui::gravity::right
| planet::ui::gravity::left,
testbox, unit);
check(v.left()) == 3.5f;
check(v.top()) == 5;
check(v.right()) == 4.5f;
check(v.bottom()) == 6;
},
[](auto check) {
auto const v = planet::ui::within(
planet::ui::gravity::top | planet::ui::gravity::bottom
| planet::ui::gravity::right
| planet::ui::gravity::left,
unitbox, {4, 5});
check(v.left()) == -1.5f;
check(v.top()) == -2;
check(v.right()) == 2.5f;
check(v.bottom()) == 3;
});
}
|