From b8a6d662b14568f2322085a72199f8213b623d16 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Wed, 15 Jun 2016 13:30:03 +0200 Subject: [PATCH] Kandinsky: Add a test for KDRect intersections Change-Id: I98c8ec0d6ed4117e93ec96a05905f5e1eab14d25 --- kandinsky/Makefile | 1 + kandinsky/test/rect.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 kandinsky/test/rect.c 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); +}