2019-12-14 10:33:34 +00:00
|
|
|
#include <notcurses.h>
|
|
|
|
#include "main.h"
|
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
TEST_CASE("ChannelGetRGB") {
|
2019-12-14 10:33:34 +00:00
|
|
|
const struct t {
|
|
|
|
uint32_t channel;
|
|
|
|
int r, g, b;
|
|
|
|
} test[] = {
|
|
|
|
{ .channel = 0x000000, .r = 0x00, .g = 0x00, .b = 0x00, },
|
|
|
|
{ .channel = 0x808080, .r = 0x80, .g = 0x80, .b = 0x80, },
|
|
|
|
{ .channel = 0x080808, .r = 0x08, .g = 0x08, .b = 0x08, },
|
|
|
|
{ .channel = 0xffffff, .r = 0xff, .g = 0xff, .b = 0xff, },
|
|
|
|
};
|
|
|
|
for(auto i = 0u ; i < sizeof(test) / sizeof(*test) ; ++i){
|
|
|
|
unsigned r, g, b;
|
2019-12-27 22:20:20 +00:00
|
|
|
CHECK(test[i].channel == channel_get_rgb(test[i].channel, &r, &g, &b));
|
|
|
|
CHECK(test[i].r == r);
|
|
|
|
CHECK(test[i].g == g);
|
|
|
|
CHECK(test[i].b == b);
|
2019-12-14 10:33:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
TEST_CASE("ChannelGetAlpha") {
|
2019-12-14 10:33:34 +00:00
|
|
|
const struct t {
|
|
|
|
uint32_t channel;
|
|
|
|
int a;
|
|
|
|
} test[] = {
|
|
|
|
{ .channel = 0x00000000, .a = 0, },
|
|
|
|
{ .channel = 0x10808080, .a = 1, },
|
|
|
|
{ .channel = 0x20080808, .a = 2, },
|
|
|
|
{ .channel = 0xe0080808, .a = 2, },
|
|
|
|
{ .channel = 0x3fffffff, .a = 3, },
|
|
|
|
{ .channel = 0xffffffff, .a = 3, },
|
|
|
|
};
|
|
|
|
for(auto i = 0u ; i < sizeof(test) / sizeof(*test) ; ++i){
|
2019-12-27 22:20:20 +00:00
|
|
|
CHECK(test[i].a == channel_get_alpha(test[i].channel));
|
2019-12-14 10:33:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
TEST_CASE("ChannelGetDefault") {
|
2019-12-14 10:33:34 +00:00
|
|
|
const struct t {
|
|
|
|
uint32_t channel;
|
|
|
|
bool def;
|
|
|
|
} test[] = {
|
|
|
|
{ .channel = 0x00000000, .def = true, },
|
|
|
|
{ .channel = 0x0fffffff, .def = true, },
|
|
|
|
{ .channel = 0xbfffffff, .def = true, },
|
|
|
|
{ .channel = 0x40000000, .def = false, },
|
|
|
|
{ .channel = 0x40080808, .def = false, },
|
|
|
|
{ .channel = 0xffffffff, .def = false, },
|
|
|
|
};
|
|
|
|
for(auto i = 0u ; i < sizeof(test) / sizeof(*test) ; ++i){
|
2019-12-27 22:20:20 +00:00
|
|
|
CHECK(test[i].def == channel_default_p(test[i].channel));
|
2019-12-14 10:33:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
TEST_CASE("ChannelSetDefault") {
|
2019-12-14 10:33:34 +00:00
|
|
|
const uint32_t channels[] = {
|
|
|
|
0x40000000, 0x4fffffff, 0xcfffffff,
|
|
|
|
0x40808080, 0x40080808, 0xffffffff,
|
|
|
|
};
|
|
|
|
for(auto i = 0u ; i < sizeof(channels) / sizeof(*channels) ; ++i){
|
|
|
|
uint32_t channel = channels[i];
|
2019-12-27 22:20:20 +00:00
|
|
|
CHECK(!channel_default_p(channel));
|
2019-12-14 10:33:34 +00:00
|
|
|
channel_set_default(&channel);
|
2019-12-27 22:20:20 +00:00
|
|
|
CHECK(channel_default_p(channel));
|
2019-12-14 10:33:34 +00:00
|
|
|
}
|
|
|
|
}
|