notcurses/tests/libunistring.cpp

69 lines
1.8 KiB
C++
Raw Normal View History

2020-08-24 19:30:17 +00:00
#include "main.h"
#include "internal.h"
// some simple tests to ensure the libunistring we've compiled/linked against
// behaves as expected.
TEST_CASE("Libunistring") {
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
ncplane* ncp_ = notcurses_stdplane(nc_);
REQUIRE(ncp_);
SUBCASE("WordbreakChars") {
const wchar_t breakers[] = {
2020-08-24 20:06:36 +00:00
// L'\u0009', // horizontal tab
2020-08-24 19:30:17 +00:00
L'\u0020', // space
2020-08-24 20:06:36 +00:00
// L'\u007c', // vertical line
// L'\u00ad', // soft hyphen
// L'\u058a', // armenian hyphen
// L'\u0f0b', // tibetan mark intersyllabic tsheg
// L'\u1361', // ethiopic wordspace
L'\u1680', // ogham space mark
//L'\u17d5', // khmer sign bariyoosan
2020-08-24 19:30:17 +00:00
L'\u2000', // en quad
L'\u2001', // em quad
L'\u2002', // en quad
L'\u2003', // em quad
L'\u2004', // three-per-em space
2020-08-24 20:06:36 +00:00
L'\u2005', // four-per-em space
L'\u2006', // six-per-em space
L'\u2008', // punctuation space
L'\u2009', // thin space
L'\u200a', // hair space
//L'\u2010', // hyphen
//L'\u2027', // hyphenation point
2020-08-24 19:30:17 +00:00
0
}, *b;
for(b = breakers ; *b ; ++b){
2020-08-24 20:06:36 +00:00
if(!iswordbreak(*b)){
fprintf(stderr, "Unexpectedly fails to wordbreak: U+%04x [%lc]\n", *b, *b);
}
2020-08-24 19:30:17 +00:00
CHECK(iswordbreak(*b));
}
2020-08-24 20:06:36 +00:00
CHECK(!islinebreak(L'\u000d'));
2020-08-24 19:30:17 +00:00
}
2020-08-24 20:06:36 +00:00
// \u000d carriage return is *not* a linebreaker
2020-08-24 19:30:17 +00:00
SUBCASE("LinebreakChars") {
const wchar_t breakers[] = {
L'\u000a', // linefeed
L'\u000b', // vertical tab
L'\u000c', // formfeed
0
}, *b;
for(b = breakers ; *b ; ++b){
2020-08-24 20:06:36 +00:00
if(!islinebreak(*b)){
fprintf(stderr, "Unexpectedly fails to linebreak: U+%04x [%lc]\n", *b, *b);
}
2020-08-24 19:30:17 +00:00
CHECK(islinebreak(*b));
}
2020-08-24 20:06:36 +00:00
CHECK(!islinebreak(L'\u000d'));
2020-08-24 19:30:17 +00:00
}
CHECK(0 == notcurses_stop(nc_));
}