mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
ba648dbd74
* widecolor-demo: don't emit spaces * notcurses_init: newline before splash * boxdemo: ncplane_erase() on entry #58 * uniblock-demo: print even wide chars #49
68 lines
1.5 KiB
C++
68 lines
1.5 KiB
C++
#include <string>
|
|
#include <cstdlib>
|
|
#include <notcurses.h>
|
|
#include "main.h"
|
|
|
|
class NotcursesTest : public :: testing::Test {
|
|
protected:
|
|
void SetUp() override {
|
|
setlocale(LC_ALL, nullptr);
|
|
if(getenv("TERM") == nullptr){
|
|
GTEST_SKIP();
|
|
}
|
|
notcurses_options nopts{};
|
|
nopts.outfp = stdin;
|
|
nc_ = notcurses_init(&nopts);
|
|
ASSERT_NE(nullptr, nc_);
|
|
}
|
|
|
|
void TearDown() override {
|
|
if(nc_){
|
|
EXPECT_EQ(0, notcurses_stop(nc_));
|
|
}
|
|
}
|
|
|
|
struct notcurses* nc_{};
|
|
};
|
|
|
|
TEST_F(NotcursesTest, NotcursesVersionString) {
|
|
const char* ver = notcurses_version();
|
|
ASSERT_NE(nullptr, ver);
|
|
ASSERT_LT(0, strlen(ver));
|
|
std::cout << "notcurses version " << ver << std::endl;
|
|
}
|
|
|
|
TEST_F(NotcursesTest, BasicLifetime) {
|
|
}
|
|
|
|
TEST_F(NotcursesTest, TermDimensions) {
|
|
int x, y;
|
|
notcurses_term_dimyx(nc_, &y, &x);
|
|
auto stry = getenv("LINES");
|
|
if(stry){
|
|
auto envy = std::stoi(stry, nullptr);
|
|
EXPECT_EQ(envy, y);
|
|
}
|
|
auto strx = getenv("COLUMNS");
|
|
if(stry){
|
|
auto envx = std::stoi(strx, nullptr);
|
|
EXPECT_EQ(envx, x);
|
|
}
|
|
}
|
|
|
|
TEST_F(NotcursesTest, ResizeSameSize) {
|
|
int x, y;
|
|
notcurses_term_dimyx(nc_, &y, &x);
|
|
EXPECT_EQ(0, notcurses_resize(nc_));
|
|
int newx, newy;
|
|
notcurses_term_dimyx(nc_, &newy, &newx);
|
|
EXPECT_EQ(newx, x);
|
|
EXPECT_EQ(newy, y);
|
|
}
|
|
|
|
// we should at least have WA_BOLD everywhere, i should think?
|
|
TEST_F(NotcursesTest, CursesStyles) {
|
|
unsigned attrs = notcurses_supported_styles(nc_);
|
|
EXPECT_EQ(1, !!(WA_BOLD & attrs));
|
|
}
|