diff --git a/tests/cell.cpp b/tests/cell.cpp index 100787e37..474b55269 100644 --- a/tests/cell.cpp +++ b/tests/cell.cpp @@ -4,6 +4,7 @@ class CellTest : public :: testing::Test { protected: void SetUp() override { + setlocale(LC_ALL, nullptr); if(getenv("TERM") == nullptr){ GTEST_SKIP(); } diff --git a/tests/egcpool.cpp b/tests/egcpool.cpp index ddb14c274..c8a3085d9 100644 --- a/tests/egcpool.cpp +++ b/tests/egcpool.cpp @@ -5,6 +5,7 @@ class EGCPoolTest : public :: testing::Test { protected: void SetUp() override { + setlocale(LC_ALL, nullptr); } void TearDown() override { @@ -22,10 +23,20 @@ TEST_F(EGCPoolTest, Initialized) { EXPECT_EQ(0, pool_.poolused); } +TEST_F(EGCPoolTest, UTF8EGC) { + const char* wstr = "☢"; + int c; + auto ulen = utf8_gce_len(wstr, &c); + ASSERT_LT(0, ulen); + EXPECT_LT(0, c); +} + TEST_F(EGCPoolTest, AddAndRemove) { const char* wstr = "﷽"; size_t ulen; - ASSERT_EQ(0, egcpool_stash(&pool_, wstr, &ulen)); + int c; // column count + ASSERT_LE(0, egcpool_stash(&pool_, wstr, &ulen, &c)); + ASSERT_LT(0, c); EXPECT_NE(nullptr, pool_.pool); EXPECT_STREQ(pool_.pool, wstr); EXPECT_LT(0, pool_.poolsize); @@ -41,10 +52,14 @@ TEST_F(EGCPoolTest, AddAndRemove) { TEST_F(EGCPoolTest, AddTwiceRemoveFirst) { const char* wstr = "血"; - size_t u1, u2; - int o1 = egcpool_stash(&pool_, wstr, &u1); - int o2 = egcpool_stash(&pool_, wstr, &u2); + size_t u1, u2; // bytes consumed + int c1, c2; // column counts + int o1 = egcpool_stash(&pool_, wstr, &u1, &c1); + int o2 = egcpool_stash(&pool_, wstr, &u2, &c2); + ASSERT_LE(0, o1); ASSERT_LT(o1, o2); + ASSERT_LT(0, c1); + ASSERT_EQ(c1, c2); EXPECT_NE(nullptr, pool_.pool); EXPECT_STREQ(pool_.pool + o1, wstr); EXPECT_STREQ(pool_.pool + o2, wstr); @@ -61,9 +76,12 @@ TEST_F(EGCPoolTest, AddTwiceRemoveFirst) { TEST_F(EGCPoolTest, AddTwiceRemoveSecond) { const char* wstr = "血"; size_t u1, u2; - int o1 = egcpool_stash(&pool_, wstr, &u1); - int o2 = egcpool_stash(&pool_, wstr, &u2); + int c1, c2; // column counts + int o1 = egcpool_stash(&pool_, wstr, &u1, &c1); + int o2 = egcpool_stash(&pool_, wstr, &u2, &c2); ASSERT_LT(o1, o2); + ASSERT_LT(0, c1); + ASSERT_EQ(c1, c2); EXPECT_NE(nullptr, pool_.pool); EXPECT_STREQ(pool_.pool + o1, wstr); EXPECT_STREQ(pool_.pool + o2, wstr); diff --git a/tests/ncplane.cpp b/tests/ncplane.cpp index 9046a495a..b9d34ec50 100644 --- a/tests/ncplane.cpp +++ b/tests/ncplane.cpp @@ -4,6 +4,7 @@ class NcplaneTest : public :: testing::Test { protected: void SetUp() override { + setlocale(LC_ALL, nullptr); if(getenv("TERM") == nullptr){ GTEST_SKIP(); } @@ -13,6 +14,7 @@ class NcplaneTest : public :: testing::Test { ASSERT_NE(nullptr, nc_); n_ = notcurses_stdplane(nc_); ASSERT_NE(nullptr, n_); + ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0)); } void TearDown() override { @@ -104,7 +106,7 @@ TEST_F(NcplaneTest, RejectBadRGB) { TEST_F(NcplaneTest, EmitWchar) { const char cchar[] = "✔"; cell c{}; - cell_load(n_, &c, cchar); + EXPECT_EQ(strlen(cchar), cell_load(n_, &c, cchar)); EXPECT_EQ(strlen(cchar), ncplane_putc(n_, &c)); int x, y; ncplane_cursor_yx(n_, &y, &x); diff --git a/tests/notcurses.cpp b/tests/notcurses.cpp index d6f080c38..9c7d13544 100644 --- a/tests/notcurses.cpp +++ b/tests/notcurses.cpp @@ -6,6 +6,7 @@ class NotcursesTest : public :: testing::Test { protected: void SetUp() override { + setlocale(LC_ALL, nullptr); if(getenv("TERM") == nullptr){ GTEST_SKIP(); }