Kandinsky: KDRectUnion

Change-Id: Ib328275ab3a6fc6da9bc472dffe37c9948c727d5
This commit is contained in:
Romain Goyet
2016-06-20 15:02:57 +02:00
parent 389b74f049
commit dbebe4aa8a
3 changed files with 107 additions and 0 deletions

View File

@@ -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);
}