Skip to content

Commit

Permalink
unit tests: require utf8 for quadblitter
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jun 14, 2020
1 parent 8ff0d92 commit 64c4a4b
Showing 1 changed file with 64 additions and 62 deletions.
126 changes: 64 additions & 62 deletions tests/visual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,74 +247,76 @@ TEST_CASE("Visual") {

// close-in verification of each quadblitter output EGC
SUBCASE("QuadblitterEGCs") {
// there are 16 configurations, each mapping four (2x2) pixels
int DIMX = 32;
int DIMY = 2;
auto rgba = new uint32_t[DIMY * DIMX];
memset(rgba, 0, sizeof(*rgba) * DIMY * DIMX);
// the top has 4 configurations of 4 each, each being 2 columns
for(int top = 0 ; top < 4 ; ++top){
for(int idx = 0 ; idx < 4 ; ++idx){
const int itop = (top * 4 + idx) * 2; // index of first column
CHECK(0 == ncpixel_set_a(&rgba[itop], 0xff));
CHECK(0 == ncpixel_set_a(&rgba[itop + 1], 0xff));
if(top == 1 || top == 3){
CHECK(0 == ncpixel_set_r(&rgba[itop], 0xff));
}
if(top == 2 || top == 3){
CHECK(0 == ncpixel_set_r(&rgba[itop + 1], 0xff));
if(enforce_utf8()){
// there are 16 configurations, each mapping four (2x2) pixels
int DIMX = 32;
int DIMY = 2;
auto rgba = new uint32_t[DIMY * DIMX];
memset(rgba, 0, sizeof(*rgba) * DIMY * DIMX);
// the top has 4 configurations of 4 each, each being 2 columns
for(int top = 0 ; top < 4 ; ++top){
for(int idx = 0 ; idx < 4 ; ++idx){
const int itop = (top * 4 + idx) * 2; // index of first column
CHECK(0 == ncpixel_set_a(&rgba[itop], 0xff));
CHECK(0 == ncpixel_set_a(&rgba[itop + 1], 0xff));
if(top == 1 || top == 3){
CHECK(0 == ncpixel_set_r(&rgba[itop], 0xff));
}
if(top == 2 || top == 3){
CHECK(0 == ncpixel_set_r(&rgba[itop + 1], 0xff));
}
}
}
}
for(int bot = 0 ; bot < 4 ; ++bot){
for(int idx = 0 ; idx < 4 ; ++idx){
const int ibot = (bot * 4 + idx) * 2 + DIMX;
CHECK(0 == ncpixel_set_a(&rgba[ibot], 0xff));
CHECK(0 == ncpixel_set_a(&rgba[ibot + 1], 0xff));
if(idx == 1 || idx == 3){
CHECK(0 == ncpixel_set_r(&rgba[ibot], 0xff));
}
if(idx == 2 || idx == 3){
CHECK(0 == ncpixel_set_r(&rgba[ibot + 1], 0xff));
for(int bot = 0 ; bot < 4 ; ++bot){
for(int idx = 0 ; idx < 4 ; ++idx){
const int ibot = (bot * 4 + idx) * 2 + DIMX;
CHECK(0 == ncpixel_set_a(&rgba[ibot], 0xff));
CHECK(0 == ncpixel_set_a(&rgba[ibot + 1], 0xff));
if(idx == 1 || idx == 3){
CHECK(0 == ncpixel_set_r(&rgba[ibot], 0xff));
}
if(idx == 2 || idx == 3){
CHECK(0 == ncpixel_set_r(&rgba[ibot + 1], 0xff));
}
}
}
}
auto ncv = ncvisual_from_rgba(rgba, DIMY, DIMX * sizeof(uint32_t), DIMX);
REQUIRE(nullptr != ncv);
struct ncvisual_options vopts{};
vopts.n = n_;
vopts.blitter = NCBLIT_2x2;
vopts.flags = NCVISUAL_OPTION_NODEGRADE;
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
CHECK(0 == notcurses_render(nc_));
for(int y = 0 ; y < DIMY / 2 ; ++y){
for(int x = 0 ; x < DIMX / 2 ; ++x){
uint32_t attrword;
uint64_t channels;
char* egc = notcurses_at_yx(nc_, y, x, &attrword, &channels);
REQUIRE(nullptr != egc);
/* FIXME need to match
[▀] 00000000 00000000
[▜] 00000000 00ff0000
[▛] 00000000 00ff0000
[▀] 00000000 00ff0000
[▟] 00000000 00ff0000
[▋] 00ff0000 00000000
[▚] 00ff0000 00000000
[▙] 00ff0000 00000000
[▙] 00000000 00ff0000
[▚] 00000000 00ff0000
[▋] 00000000 00ff0000
[▟] 00ff0000 00000000
[▀] 00ff0000 00000000
[▛] 00ff0000 00000000
[▜] 00ff0000 00000000
[▀] 00ff0000 00ff0000
*/
free(egc);
auto ncv = ncvisual_from_rgba(rgba, DIMY, DIMX * sizeof(uint32_t), DIMX);
REQUIRE(nullptr != ncv);
struct ncvisual_options vopts{};
vopts.n = n_;
vopts.blitter = NCBLIT_2x2;
vopts.flags = NCVISUAL_OPTION_NODEGRADE;
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
CHECK(0 == notcurses_render(nc_));
for(int y = 0 ; y < DIMY / 2 ; ++y){
for(int x = 0 ; x < DIMX / 2 ; ++x){
uint32_t attrword;
uint64_t channels;
char* egc = notcurses_at_yx(nc_, y, x, &attrword, &channels);
REQUIRE(nullptr != egc);
/* FIXME need to match
[▀] 00000000 00000000
[▜] 00000000 00ff0000
[▛] 00000000 00ff0000
[▀] 00000000 00ff0000
[▟] 00000000 00ff0000
[▋] 00ff0000 00000000
[▚] 00ff0000 00000000
[▙] 00ff0000 00000000
[▙] 00000000 00ff0000
[▚] 00000000 00ff0000
[▋] 00000000 00ff0000
[▟] 00ff0000 00000000
[▀] 00ff0000 00000000
[▛] 00ff0000 00000000
[▜] 00ff0000 00000000
[▀] 00ff0000 00ff0000
*/
free(egc);
}
}
delete[] rgba;
}
delete[] rgba;
}

CHECK(!notcurses_stop(nc_));
Expand Down

0 comments on commit 64c4a4b

Please sign in to comment.