Add ExhaustPool unit test #482

pull/490/head
nick black 4 years ago
parent 3ddb1d3166
commit a4e1d68786
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -591,15 +591,17 @@ cell_debug(const egcpool* p, const cell* c){
} }
static inline void static inline void
plane_debug(const ncplane* n){ plane_debug(const ncplane* n, bool details){
int dimy, dimx; int dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx); ncplane_dim_yx(n, &dimy, &dimx);
fprintf(stderr, "p: %p dim: %d/%d poolsize: %d\n", n, dimy, dimx, n->pool.poolsize); fprintf(stderr, "p: %p dim: %d/%d poolsize: %d\n", n, dimy, dimx, n->pool.poolsize);
for(int y = 0 ; y < 1 ; ++y){ if(details){
for(int x = 0 ; x < 10 ; ++x){ for(int y = 0 ; y < 1 ; ++y){
const cell* c = &n->fb[fbcellidx(y, dimx, x)]; for(int x = 0 ; x < 10 ; ++x){
fprintf(stderr, "[%03d/%03d] ", y, x); const cell* c = &n->fb[fbcellidx(y, dimx, x)];
cell_debug(&n->pool, c); fprintf(stderr, "[%03d/%03d] ", y, x);
cell_debug(&n->pool, c);
}
} }
} }
} }

@ -1052,11 +1052,11 @@ uint32_t ncplane_attr(const ncplane* n){
return n->attrword; return n->attrword;
} }
void ncplane_set_fg_default(struct ncplane* n){ void ncplane_set_fg_default(ncplane* n){
channels_set_fg_default(&n->channels); channels_set_fg_default(&n->channels);
} }
void ncplane_set_bg_default(struct ncplane* n){ void ncplane_set_bg_default(ncplane* n){
channels_set_bg_default(&n->channels); channels_set_bg_default(&n->channels);
} }
@ -1128,7 +1128,7 @@ int ncplane_base(ncplane* ncp, cell* c){
return cell_duplicate(ncp, c, &ncp->basecell); return cell_duplicate(ncp, c, &ncp->basecell);
} }
const char* cell_extended_gcluster(const struct ncplane* n, const cell* c){ const char* cell_extended_gcluster(const ncplane* n, const cell* c){
return extended_gcluster(n, c); return extended_gcluster(n, c);
} }
@ -1263,7 +1263,7 @@ int ncplane_putc_yx(ncplane* n, int y, int x, const cell* c){
return cols; return cols;
} }
int ncplane_putegc_yx(struct ncplane* n, int y, int x, const char* gclust, int* sbytes){ int ncplane_putegc_yx(ncplane* n, int y, int x, const char* gclust, int* sbytes){
cell c = CELL_TRIVIAL_INITIALIZER; cell c = CELL_TRIVIAL_INITIALIZER;
int primed = cell_prime(n, &c, gclust, n->attrword, n->channels); int primed = cell_prime(n, &c, gclust, n->attrword, n->channels);
if(sbytes){ if(sbytes){

@ -205,6 +205,31 @@ TEST_CASE("EGCpool") {
CHECK(candidates.size() / 13 > no); CHECK(candidates.size() / 13 > no);
} }
// ensure that a hard error comes up when we fill the EGCpool
SUBCASE("ExhaustPool") {
wchar_t wcs = 0x4e00;
uint64_t total = 0;
while(true){
char mb[MB_CUR_MAX + 1];
auto r = wctomb(mb, wcs);
CHECK(0 < r);
REQUIRE(sizeof(mb) >= r);
mb[r] = '\0';
int loc = egcpool_stash(&pool_, mb, r);
if(loc < 0){
break;
}
REQUIRE(loc == total);
total += r + 1;
CHECK(egcpool_check_validity(&pool_, loc));
CHECK((1u << 25) > loc);
if(++wcs == 0x9fa5){
wcs = 0x4e00;
}
}
CHECK((1u << 25) <= total);
}
// common cleanup // common cleanup
egcpool_dump(&pool_); egcpool_dump(&pool_);

@ -180,8 +180,8 @@ TEST_CASE("Scrolling") {
SUBCASE("XYPostScroll") { SUBCASE("XYPostScroll") {
const char* out = "0123456789012345678901234567890123456789"; const char* out = "0123456789012345678901234567890123456789";
const char* onext = "ABCDEFGHIJ"; const char* onext = "ABCDEFGHIJ";
const char* next2 = "KLMNOPQRST"; //const char* next2 = "KLMNOPQRST";
const char* next3 = "UVWXYZ"; //const char* next3 = "UVWXYZ";
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
struct ncplane* n = ncplane_new(nc_, 2, 20, 1, 1, nullptr); struct ncplane* n = ncplane_new(nc_, 2, 20, 1, 1, nullptr);
REQUIRE(n); REQUIRE(n);

Loading…
Cancel
Save