diff --git a/kandinsky/Makefile b/kandinsky/Makefile index ee9103e40..914b8502c 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -10,6 +10,7 @@ objs += $(addprefix kandinsky/src/,\ ) tests += $(addprefix kandinsky/test/,\ color.c\ + rect.c\ set_pixel.c\ ) diff --git a/kandinsky/test/rect.c b/kandinsky/test/rect.c new file mode 100644 index 000000000..ce4ad9c17 --- /dev/null +++ b/kandinsky/test/rect.c @@ -0,0 +1,26 @@ +#include +#include +#include + +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); +}