kill enforce_utf8(), forcing notcurses_canutf8()

pull/1157/head
nick black 4 years ago committed by Nick Black
parent 4d524f92bc
commit 03bcd1e01b

@ -2,13 +2,14 @@
#include "egcpool.h"
TEST_CASE("Cell") {
if(!enforce_utf8()){
return;
}
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
struct ncplane* n_ = notcurses_stdplane(nc_);
REQUIRE(nullptr != n_);

@ -12,9 +12,15 @@ TEST_CASE("EGCpool") {
CHECK(!pool_.poolused);
}
if(!enforce_utf8()){
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
CHECK(0 == notcurses_stop(nc_));
SUBCASE("UTF8EGC") {
const char* wstr = "";

@ -3,13 +3,14 @@
#include "main.h"
TEST_CASE("Fills") {
if(!enforce_utf8()){
return;
}
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
struct ncplane* n_ = notcurses_stdplane(nc_);
REQUIRE(n_);

@ -189,7 +189,7 @@ TEST_CASE("TextLayout") {
// lay out text where a wide word crosses the boundary
SUBCASE("LayoutCrossBoundaryWide") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
struct ncplane_options nopts = {
.y = 0,
.x = 0,
@ -245,7 +245,7 @@ TEST_CASE("TextLayout") {
// a long word (one requiring a split no matter what) ought not force the
// next line, but instead be printed where it starts
SUBCASE("LayoutTransPlanarWide") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
struct ncplane_options nopts = {
.y = 0,
.x = 0,
@ -428,7 +428,7 @@ TEST_CASE("TextLayout") {
// create a plane of three rows, and exactly fill two with wide chars
SUBCASE("LayoutFillsPlaneWide") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
struct ncplane_options nopts = {
.y = 0,
.x = 0,

@ -28,17 +28,6 @@ auto find_data(const char* datum) -> char* {
return strdup(p.c_str());
}
auto enforce_utf8() -> bool {
char* enc = nl_langinfo(CODESET);
if(!enc){
return false;
}
if(strcmp(enc, "UTF-8")){
return false;
}
return true;
}
static void
handle_opts(const char** argv){
bool inarg = false;

@ -11,7 +11,6 @@
#include "internal.h"
auto find_data(const char* datum) -> char*;
auto enforce_utf8() -> bool;
auto testing_notcurses() -> struct notcurses*;
auto ncreel_validate(const ncreel* n) -> bool;

@ -421,8 +421,17 @@ TEST_CASE("Metric") {
}
SUBCASE("NegativePowersOfTen") {
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
CHECK(0 == notcurses_stop(nc_));
const wchar_t* smallsuffixes;
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
smallsuffixes = L"yzafpnµm";
}else{
smallsuffixes = L"yzafpnum";

@ -18,13 +18,14 @@ void BoxPermutationsRounded(struct notcurses* nc, struct ncplane* n, unsigned ed
}
TEST_CASE("NCPlane") {
if(!enforce_utf8()){
return;
}
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
struct ncplane* n_ = notcurses_stdplane(nc_);
REQUIRE(n_);

@ -3,13 +3,14 @@
#include <iostream>
TEST_CASE("Plot") {
if(!enforce_utf8()){
return;
}
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
auto n_ = notcurses_stdplane(nc_);
REQUIRE(n_);
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));

@ -26,7 +26,8 @@ TEST_CASE("Readers") {
};
auto ncp = ncplane_create(notcurses_stdplane(nc_), &nopts);
uint64_t echannels = CHANNELS_RGB_INITIALIZER(0xff, 0x44, 0xff, 0, 0, 0);
ncplane_set_base(ncp, enforce_utf8() ? strdup("") : strdup("x"), 0, echannels);
ncplane_set_base(ncp, notcurses_canutf8(nc_) ? strdup("") : strdup("x"),
0, echannels);
auto nr = ncreader_create(ncp, &opts);
REQUIRE(nullptr != nr);
CHECK(0 == notcurses_render(nc_));

@ -27,13 +27,14 @@ void RotateCCW(struct notcurses* nc, struct ncplane* n) {
}
TEST_CASE("Rotate") {
if(!enforce_utf8()){
return;
}
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
int dimy, dimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(n_);

@ -272,7 +272,7 @@ TEST_CASE("Visual") {
// write a checkerboard pattern and verify the NCBLIT_2x1 output
SUBCASE("Dualblitter") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
constexpr int DIMY = 10;
constexpr int DIMX = 11; // odd number to get checkerboard effect
auto rgba = new uint32_t[DIMY * DIMX];
@ -312,7 +312,7 @@ TEST_CASE("Visual") {
// write a checkerboard pattern and verify the NCBLIT_2x2 output
SUBCASE("Quadblitter") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
constexpr int DIMY = 10;
constexpr int DIMX = 11; // odd number to get checkerboard effect
auto rgba = new uint32_t[DIMY * DIMX];
@ -352,7 +352,7 @@ TEST_CASE("Visual") {
// close-in verification of each quadblitter output EGC
SUBCASE("QuadblitterEGCs") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
// there are 16 configurations, each mapping four (2x2) pixels
int DIMX = 32;
int DIMY = 2;
@ -426,7 +426,7 @@ TEST_CASE("Visual") {
// quadblitter with all 4 colors equal ought generate space
SUBCASE("Quadblitter4Same") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
const uint32_t pixels[4] = { 0xff605040, 0xff605040, 0xff605040, 0xff605040 };
auto ncv = ncvisual_from_rgba(pixels, 2, 2 * sizeof(*pixels), 2);
REQUIRE(nullptr != ncv);
@ -462,7 +462,7 @@ TEST_CASE("Visual") {
// quadblitter with three pixels equal ought generate three-quarter block
SUBCASE("Quadblitter3Same") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
const uint32_t pixels[4][4] = {
{ 0xffcccccc, 0xff605040, 0xff605040, 0xff605040 },
{ 0xff605040, 0xffcccccc, 0xff605040, 0xff605040 },
@ -505,7 +505,7 @@ TEST_CASE("Visual") {
// quadblitter with two sets of two equal pixels
SUBCASE("Quadblitter2Pairs") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
const uint32_t pixels[6][4] = {
{ 0xffcccccc, 0xffcccccc, 0xff605040, 0xff605040 },
{ 0xffcccccc, 0xff605040, 0xffcccccc, 0xff605040 },
@ -555,7 +555,7 @@ TEST_CASE("Visual") {
// quadblitter with one pair plus two split
SUBCASE("Quadblitter1Pair") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
const uint32_t pixels[6][4] = {
{ 0xffcccccc, 0xff444444, 0xff605040, 0xff605040 },
{ 0xff444444, 0xff605040, 0xffcccccc, 0xff605040 },
@ -605,7 +605,7 @@ TEST_CASE("Visual") {
// quadblitter with one pair plus two split
SUBCASE("QuadblitterAllDifferent") {
if(enforce_utf8()){
if(notcurses_canutf8(nc_)){
const uint32_t pixels[6][4] = {
{ 0xffdddddd, 0xff000000, 0xff111111, 0xff222222 },
{ 0xff000000, 0xff111111, 0xffdddddd, 0xff222222 },

@ -8,11 +8,12 @@ const char SCORPION[] = "\xf0\x9f\xa6\x82"; // U+1F982 SCORPION
const char FROG[] = "\xf0\x9f\x90\xb8"; // U+1F438 FROG FACE
TEST_CASE("Wide") {
if(!enforce_utf8()){
return;
}
auto nc_ = testing_notcurses();
REQUIRE(nullptr != nc_);
if(!notcurses_canutf8(nc_)){
CHECK(0 == notcurses_stop(nc_));
return;
}
struct ncplane* n_ = notcurses_stdplane(nc_);
REQUIRE(n_);

Loading…
Cancel
Save