mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
cell unit tests: use nccell_width()
This commit is contained in:
parent
55837bcb55
commit
8e0173cce3
1
NEWS.md
1
NEWS.md
@ -22,6 +22,7 @@ rearrangements of Notcurses.
|
||||
For this to work properly, other threads ought also have these signals
|
||||
blocked. `notcurses_getc()` and friends thus no longer drop these signals
|
||||
from the provided `sigset_t`; they are instead added if not present.
|
||||
* Added `nccell_width()` to get the column length of an `nccell`.
|
||||
|
||||
* 2.2.8 (2021-04-18)
|
||||
* All remaining functions prefixed with `cell_` or `cells_` have been
|
||||
|
@ -14,33 +14,30 @@ TEST_CASE("Cell") {
|
||||
REQUIRE(nullptr != n_);
|
||||
|
||||
SUBCASE("EGCs") {
|
||||
int cols, bytes;
|
||||
bytes = utf8_egc_len("é", &cols);
|
||||
CHECK(2 == bytes);
|
||||
CHECK(1 == cols);
|
||||
bytes = utf8_egc_len("\x41\u0301", &cols);
|
||||
CHECK(3 == bytes);
|
||||
CHECK(1 == cols);
|
||||
bytes = utf8_egc_len(" ி", &cols);
|
||||
CHECK(4 == bytes);
|
||||
nccell c = CELL_TRIVIAL_INITIALIZER;
|
||||
CHECK(2 == nccell_load(n_, &c, "é"));
|
||||
CHECK(1 == nccell_width(n_, &c));
|
||||
int cols;
|
||||
CHECK(3 == nccell_load(n_, &c, "\x41\u0301"));
|
||||
CHECK(1 == nccell_width(n_, &c));
|
||||
CHECK(4 == nccell_load(n_, &c, " ி"));
|
||||
cols = nccell_width(n_, &c);
|
||||
#ifdef __linux__
|
||||
CHECK(2 == cols);
|
||||
#else
|
||||
CHECK(1 == cols);
|
||||
#endif
|
||||
bytes = utf8_egc_len(" ि", &cols);
|
||||
CHECK(4 == bytes);
|
||||
CHECK(4 == nccell_load(n_, &c, " ि"));
|
||||
cols = nccell_width(n_, &c);
|
||||
#ifdef __linux__
|
||||
CHECK(2 == cols);
|
||||
#else
|
||||
CHECK(1 == cols);
|
||||
#endif
|
||||
bytes = utf8_egc_len("◌̈", &cols);
|
||||
CHECK(5 == bytes);
|
||||
CHECK(1 == cols);
|
||||
bytes = utf8_egc_len("นี้", &cols);
|
||||
CHECK(9 == bytes);
|
||||
CHECK(1 == cols);
|
||||
CHECK(5 == nccell_load(n_, &c, "◌̈"));
|
||||
CHECK(1 == nccell_width(n_, &c));
|
||||
CHECK(9 == nccell_load(n_, &c, "นี้"));
|
||||
CHECK(1 == nccell_width(n_, &c));
|
||||
}
|
||||
|
||||
SUBCASE("Loadchar") {
|
||||
|
@ -23,14 +23,9 @@ TEST_CASE("EGCpool") {
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
|
||||
SUBCASE("UTF8EGC") {
|
||||
const char* wstr = "☢";
|
||||
int c;
|
||||
auto ulen = utf8_egc_len(wstr, &c);
|
||||
REQUIRE(0 < ulen);
|
||||
int c = ncstrwidth("☢");
|
||||
CHECK(0 < c);
|
||||
wstr = "▓";
|
||||
ulen = utf8_egc_len(wstr, &c);
|
||||
REQUIRE(0 < ulen);
|
||||
c = ncstrwidth("▓");
|
||||
CHECK(0 < c);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user