|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
constexpr int TABWIDTH = 8;
|
|
|
|
|
|
|
|
|
|
TEST_CASE("TaBs") { // refreshing and delicious
|
|
|
|
|
auto nc_ = testing_notcurses();
|
|
|
|
|
if(!nc_){
|
|
|
|
@ -15,10 +17,31 @@ TEST_CASE("TaBs") { // refreshing and delicious
|
|
|
|
|
nopts.cols = 80;
|
|
|
|
|
auto n = ncplane_create(n_, &nopts);
|
|
|
|
|
unsigned y, x;
|
|
|
|
|
CHECK(1 == ncplane_putchar(n, '\t'));
|
|
|
|
|
CHECK(TABWIDTH == ncplane_putchar(n, '\t'));
|
|
|
|
|
ncplane_cursor_yx(n, &y, &x);
|
|
|
|
|
CHECK(y == 0);
|
|
|
|
|
CHECK(x == 8);
|
|
|
|
|
CHECK(x == TABWIDTH);
|
|
|
|
|
for(unsigned i = 0 ; i < x ; ++i){
|
|
|
|
|
char* c = ncplane_at_yx(n, 0, i, nullptr, nullptr);
|
|
|
|
|
REQUIRE(c);
|
|
|
|
|
CHECK(0 == strcmp(c, " "));
|
|
|
|
|
free(c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SUBCASE("PutXoffsetTaBs") {
|
|
|
|
|
struct ncplane_options nopts{};
|
|
|
|
|
nopts.rows = 2;
|
|
|
|
|
nopts.cols = TABWIDTH;
|
|
|
|
|
auto n = ncplane_create(n_, &nopts);
|
|
|
|
|
unsigned y, x;
|
|
|
|
|
for(int i = 0 ; i < TABWIDTH ; ++i){
|
|
|
|
|
CHECK(TABWIDTH - i == ncplane_putchar(n, '\t'));
|
|
|
|
|
ncplane_cursor_yx(n, &y, &x);
|
|
|
|
|
CHECK(y == 0);
|
|
|
|
|
CHECK(x == TABWIDTH - i);
|
|
|
|
|
CHECK(0 == ncplane_cursor_move_yx(n, 0, i + 1));
|
|
|
|
|
}
|
|
|
|
|
for(unsigned i = 0 ; i < x ; ++i){
|
|
|
|
|
char* c = ncplane_at_yx(n, 0, i, nullptr, nullptr);
|
|
|
|
|
REQUIRE(c);
|
|
|
|
@ -30,13 +53,13 @@ TEST_CASE("TaBs") { // refreshing and delicious
|
|
|
|
|
SUBCASE("PutwcTaB") {
|
|
|
|
|
struct ncplane_options nopts{};
|
|
|
|
|
nopts.rows = 2;
|
|
|
|
|
nopts.cols = 80;
|
|
|
|
|
nopts.cols = TABWIDTH;
|
|
|
|
|
auto n = ncplane_create(n_, &nopts);
|
|
|
|
|
unsigned y, x;
|
|
|
|
|
CHECK(1 == ncplane_putwc(n, L'\t'));
|
|
|
|
|
CHECK(TABWIDTH == ncplane_putwc(n, L'\t'));
|
|
|
|
|
ncplane_cursor_yx(n, &y, &x);
|
|
|
|
|
CHECK(y == 0);
|
|
|
|
|
CHECK(x == 8);
|
|
|
|
|
CHECK(x == TABWIDTH);
|
|
|
|
|
for(unsigned i = 0 ; i < x ; ++i){
|
|
|
|
|
char* c = ncplane_at_yx(n, 0, i, nullptr, nullptr);
|
|
|
|
|
REQUIRE(c);
|
|
|
|
@ -48,14 +71,14 @@ TEST_CASE("TaBs") { // refreshing and delicious
|
|
|
|
|
SUBCASE("PutCellTaB") {
|
|
|
|
|
struct ncplane_options nopts{};
|
|
|
|
|
nopts.rows = 2;
|
|
|
|
|
nopts.cols = 80;
|
|
|
|
|
nopts.cols = TABWIDTH;
|
|
|
|
|
auto n = ncplane_create(n_, &nopts);
|
|
|
|
|
nccell c = NCCELL_CHAR_INITIALIZER('\t');
|
|
|
|
|
unsigned y, x;
|
|
|
|
|
CHECK(1 == ncplane_putc(n, &c));
|
|
|
|
|
ncplane_cursor_yx(n, &y, &x);
|
|
|
|
|
CHECK(y == 0);
|
|
|
|
|
CHECK(x == 8);
|
|
|
|
|
CHECK(x == TABWIDTH);
|
|
|
|
|
for(unsigned i = 0 ; i < x ; ++i){
|
|
|
|
|
char* s = ncplane_at_yx(n, 0, i, nullptr, nullptr);
|
|
|
|
|
REQUIRE(s);
|
|
|
|
@ -67,7 +90,7 @@ TEST_CASE("TaBs") { // refreshing and delicious
|
|
|
|
|
SUBCASE("PutMultipleTaBs") {
|
|
|
|
|
struct ncplane_options nopts{};
|
|
|
|
|
nopts.rows = 2;
|
|
|
|
|
nopts.cols = 80;
|
|
|
|
|
nopts.cols = TABWIDTH;
|
|
|
|
|
auto n = ncplane_create(n_, &nopts);
|
|
|
|
|
unsigned y, x;
|
|
|
|
|
CHECK(1 == ncplane_putstr(n, "\t\t"));
|
|
|
|
@ -85,7 +108,7 @@ TEST_CASE("TaBs") { // refreshing and delicious
|
|
|
|
|
SUBCASE("PutRowOfTaBs") {
|
|
|
|
|
struct ncplane_options nopts{};
|
|
|
|
|
nopts.rows = 2;
|
|
|
|
|
nopts.cols = 80;
|
|
|
|
|
nopts.cols = TABWIDTH;
|
|
|
|
|
auto n = ncplane_create(n_, &nopts);
|
|
|
|
|
unsigned y, x;
|
|
|
|
|
CHECK(1 == ncplane_putstr(n, "\t\t\t\t\t\t\t\t\t\t"));
|
|
|
|
|