[quiz] Turn all assert in quiz_assert

This commit is contained in:
Émilie Feral
2018-08-28 10:40:52 +02:00
parent d3296be915
commit a1bcbe28e6
29 changed files with 261 additions and 261 deletions

View File

@@ -3,24 +3,24 @@
#include <assert.h>
QUIZ_CASE(kandinsky_color_rgb) {
assert(sizeof(KDColor) == 2); // We really want KDColor to be packed
quiz_assert(sizeof(KDColor) == 2); // We really want KDColor to be packed
assert(KDColor::RGB24(0xFF0000) == 0xF800);
assert(KDColor::RGB24(0x00FF00) == 0x07E0);
assert(KDColor::RGB24(0x0000FF) == 0x1F);
quiz_assert(KDColor::RGB24(0xFF0000) == 0xF800);
quiz_assert(KDColor::RGB24(0x00FF00) == 0x07E0);
quiz_assert(KDColor::RGB24(0x0000FF) == 0x1F);
/* R = 0x12 = 0b 0001 0010. 5 most important bits are 00010.
* G = 0x34 = 0b 0011 0100. 6 most important bits are 001101.
* B = 0x56 = 0b 0101 0110. 5 most important bits are 01010.
* KDColor = 0b 00010 001101 01010
* = 0b 0001 0001 1010 1010
* = 0x 1 1 A A */
assert(KDColor::RGB24(0x123456) == 0x11AA);
quiz_assert(KDColor::RGB24(0x123456) == 0x11AA);
}
QUIZ_CASE(kandinsky_color_blend) {
KDColor midGray = KDColor::RGB24(0x7F7F7F);
KDColor res = KDColor::blend(KDColorWhite, KDColorBlack, 0xFF);
assert(res == KDColorWhite);
assert(KDColor::blend(KDColorWhite, KDColorBlack, 0) == KDColorBlack);
assert(KDColor::blend(KDColorWhite, KDColorBlack, 0x7F) == midGray);
quiz_assert(res == KDColorWhite);
quiz_assert(KDColor::blend(KDColorWhite, KDColorBlack, 0) == KDColorBlack);
quiz_assert(KDColor::blend(KDColorWhite, KDColorBlack, 0x7F) == midGray);
}

View File

@@ -5,20 +5,20 @@
QUIZ_CASE(kandinsky_rect_intersect) {
KDRect a(-5,-5, 10, 10);
KDRect b(0, 0, 10, 10);
assert(a.intersects(b));
assert(b.intersects(a));
quiz_assert(a.intersects(b));
quiz_assert(b.intersects(a));
KDRect c = a.intersectedWith(b);
KDRect result(0, 0, 5, 5);
assert(c == result);
quiz_assert(c == result);
c = b.intersectedWith(a);
assert(c == result);
quiz_assert(c == result);
}
QUIZ_CASE(kandinsky_rect_union) {
KDRect a(-5, -5, 10, 10);
KDRect b(0, 0, 10, 10);
KDRect c = a.unionedWith(b);
assert(c == KDRect(-5, -5, 15, 15));
quiz_assert(c == KDRect(-5, -5, 15, 15));
}
QUIZ_CASE(kandinsky_rect_empty_union) {
@@ -27,13 +27,13 @@ QUIZ_CASE(kandinsky_rect_empty_union) {
KDRect c(-2, -1, 0, 1);
KDRect t = a.unionedWith(b);
assert(t == a);
quiz_assert(t == a);
t = b.unionedWith(a);
assert(t == a);
quiz_assert(t == a);
t = a.unionedWith(c);
assert(t == a);
quiz_assert(t == a);
}
QUIZ_CASE(kandinsky_rect_difference) {
@@ -45,35 +45,35 @@ QUIZ_CASE(kandinsky_rect_difference) {
KDRect f(2, -4, 3, 3);
KDRect t = e.differencedWith(a);
assert(t == e);
quiz_assert(t == e);
t = a.differencedWith(e);
assert(t == KDRectZero);
quiz_assert(t == KDRectZero);
t = f.differencedWith(d);
assert(t == f);
quiz_assert(t == f);
t = f.differencedWith(e);
assert(t == f);
quiz_assert(t == f);
t = b.differencedWith(e);
assert(t == b);
quiz_assert(t == b);
t = c.differencedWith(f);
assert(t == KDRect(3, -1, 1, 4));
quiz_assert(t == KDRect(3, -1, 1, 4));
t = c.differencedWith(a);
assert(t == c);
quiz_assert(t == c);
t = c.differencedWith(e);
assert(t == KDRect(3, -2, 1, 1));
quiz_assert(t == KDRect(3, -2, 1, 1));
t = a.differencedWith(b);
assert(t == KDRect(0, 0, 10, 2));
quiz_assert(t == KDRect(0, 0, 10, 2));
t = a.differencedWith(c);
assert(t == a);
quiz_assert(t == a);
t = a.differencedWith(d);
assert(t == KDRect(-1, 0, 8, 2));
quiz_assert(t == KDRect(-1, 0, 8, 2));
}