mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-09 19:10:48 +00:00
ce2a390b52
* introduce doctest over googletest #202 * call dtester in in targets * doctest conversion #202 * channel.cpp -> doctest #202 * egcpool tests -> doctest #202 * input tests to doctester * zaxis -> doctest * drone: always define LANG * libav to doctest #202 * panelreel tests to doctest #202 * spec that a C++17 compiler is now required for doctest #202 * enmetric tests -> doctest #202 * fade tests -> doctest #202 * notcurses test case -> doctest #202 * last conversion to doctest #202 * finish move to doctest #202 * drone: set up make test
76 lines
1.5 KiB
C++
76 lines
1.5 KiB
C++
#include <string>
|
|
#include <cstdlib>
|
|
#include <clocale>
|
|
#include "internal.h"
|
|
#include "main.h"
|
|
|
|
TEST_CASE("RGBtoANSIWhite") {
|
|
unsigned r, g, b;
|
|
for(r = 250 ; r < 256 ; ++r){
|
|
g = b = r;
|
|
CHECK(15 == rgb_quantize_256(r, g, b));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("RGBtoANSIBlack") {
|
|
unsigned r, g, b;
|
|
for(r = 0 ; r < 10 ; ++r){
|
|
g = b = r;
|
|
CHECK(0 == rgb_quantize_256(r, g, b));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("RGBtoANSIGrey") {
|
|
unsigned r, g, b;
|
|
for(r = 10 ; r < 244 ; ++r){
|
|
g = b = r;
|
|
CHECK(231 + (r * 5) / 49 == rgb_quantize_256(r, g, b));
|
|
}
|
|
}
|
|
|
|
// Pure reds are either 0 (black), or 16 plus 36 * [0..5].
|
|
TEST_CASE("RGBtoANSIRed") {
|
|
unsigned r, g, b;
|
|
g = b = 0x0;
|
|
for(r = 0 ; r < 256 ; ++r){
|
|
int c256 = rgb_quantize_256(r, g, b);
|
|
if(r < 8){
|
|
CHECK(0 == c256);
|
|
}else{
|
|
CHECK(15 < c256);
|
|
CHECK(16 == c256 % 36);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Pure greens are either 0 (black), or 16 plus 6 * [0..5].
|
|
TEST_CASE("RGBtoANSIGreen") {
|
|
unsigned r, g, b;
|
|
r = b = 0x0;
|
|
for(g = 0 ; g < 256 ; ++g){
|
|
int c256 = rgb_quantize_256(r, g, b);
|
|
CHECK(48 > c256);
|
|
if(g < 8){
|
|
CHECK(0 == c256);
|
|
}else{
|
|
CHECK(15 < c256);
|
|
CHECK(4 == c256 % 6);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Pure blues are either 0 (black), or one of the first 6 colors [16..22].
|
|
TEST_CASE("RGBtoANSIBlue") {
|
|
unsigned r, g, b;
|
|
r = g = 0x0;
|
|
for(b = 0 ; b < 256 ; ++b){
|
|
int c256 = rgb_quantize_256(r, g, b);
|
|
CHECK(22 > c256);
|
|
if(b < 8){
|
|
CHECK(0 == c256);
|
|
}else{
|
|
CHECK(15 < c256);
|
|
}
|
|
}
|
|
}
|