Kandinsky: Add a test for KDRect intersections

Change-Id: I98c8ec0d6ed4117e93ec96a05905f5e1eab14d25
This commit is contained in:
Romain Goyet
2016-06-15 13:30:03 +02:00
parent dc34ce10d2
commit b8a6d662b1
2 changed files with 27 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ objs += $(addprefix kandinsky/src/,\
)
tests += $(addprefix kandinsky/test/,\
color.c\
rect.c\
set_pixel.c\
)

26
kandinsky/test/rect.c Normal file
View File

@@ -0,0 +1,26 @@
#include <quiz.h>
#include <kandinsky.h>
#include <assert.h>
QUIZ_CASE(kandinsky_rect_intersect) {
KDRect a = {
.x = -5, .y = -5,
.width = 10, .height = 10
};
KDRect b = {
.x = 0, .y = 0,
.width = 10, .height = 10
};
assert(KDRectIntersect(a,b));
assert(KDRectIntersect(b,a));
KDRect c = KDRectIntersection(a,b);
assert(c.x == 0);
assert(c.y == 0);
assert(c.width == 5);
assert(c.height == 5);
c = KDRectIntersection(b,a);
assert(c.x == 0);
assert(c.y == 0);
assert(c.width == 5);
assert(c.height == 5);
}