Files
Upsilon/kandinsky/test/color.cpp
Romain Goyet 5de28e01db Migrate Kandinsky to C++
Change-Id: I2752a8db84ad0bb817119cf6c2993c1622621150
2016-07-21 13:42:32 +02:00

20 lines
627 B
C++

#include <quiz.h>
#include <kandinsky.h>
#include <assert.h>
QUIZ_CASE(kandinsky_color_rgb) {
assert(sizeof(KDColor) == 2); // We really want KDColor to be packed
assert(KDColor(0xFF0000) == 0xF800);
assert(KDColor(0x00FF00) == 0x07E0);
assert(KDColor(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(0x123456) == 0x11AA);
}