mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Kandinsky: KDRectUnion
Change-Id: Ib328275ab3a6fc6da9bc472dffe37c9948c727d5
This commit is contained in:
@@ -24,3 +24,59 @@ QUIZ_CASE(kandinsky_rect_intersect) {
|
||||
assert(c.width == 5);
|
||||
assert(c.height == 5);
|
||||
}
|
||||
|
||||
QUIZ_CASE(kandinsky_rect_union) {
|
||||
KDRect a = {
|
||||
.x = -5, .y = -5,
|
||||
.width = 10, .height = 10
|
||||
};
|
||||
KDRect b = {
|
||||
.x = 0, .y = 0,
|
||||
.width = 10, .height = 10
|
||||
};
|
||||
|
||||
KDRect c = KDRectUnion(a,b);
|
||||
assert(c.x == -5);
|
||||
assert(c.y == -5);
|
||||
assert(c.width == 15);
|
||||
assert(c.height == 15);
|
||||
|
||||
c = KDRectUnion(a,b);
|
||||
assert(c.x == -5);
|
||||
assert(c.y == -5);
|
||||
assert(c.width == 15);
|
||||
assert(c.height == 15);
|
||||
}
|
||||
|
||||
QUIZ_CASE(kandinsky_rect_empty_union) {
|
||||
KDRect a = {
|
||||
.x = 1, .y = 2,
|
||||
.width = 3, .height = 4
|
||||
};
|
||||
KDRect b = {
|
||||
.x = 5, .y = 6,
|
||||
.width = 0, .height = 0
|
||||
};
|
||||
KDRect c = {
|
||||
.x = -2, .y = -1,
|
||||
.width = 0, .height = 1
|
||||
};
|
||||
|
||||
KDRect t = KDRectUnion(a,b);
|
||||
assert(t.x == a.x);
|
||||
assert(t.y == a.y);
|
||||
assert(t.width == a.width);
|
||||
assert(t.height == a.height);
|
||||
|
||||
t = KDRectUnion(b,a);
|
||||
assert(t.x == a.x);
|
||||
assert(t.y == a.y);
|
||||
assert(t.width == a.width);
|
||||
assert(t.height == a.height);
|
||||
|
||||
t = KDRectUnion(a,c);
|
||||
assert(t.x == a.x);
|
||||
assert(t.y == c.y);
|
||||
assert(t.width == a.width);
|
||||
assert(t.height == 7);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user