2019-11-17 15:25:40 +00:00
|
|
|
#include <string>
|
|
|
|
#include <cstdlib>
|
2019-11-17 14:53:59 +00:00
|
|
|
#include <notcurses.h>
|
|
|
|
#include "main.h"
|
|
|
|
|
2019-11-19 01:57:33 +00:00
|
|
|
class NotcursesTest : public :: testing::Test {
|
2019-11-19 10:33:38 +00:00
|
|
|
protected:
|
2019-11-19 01:57:33 +00:00
|
|
|
void SetUp() override {
|
2019-11-25 18:36:16 +00:00
|
|
|
setlocale(LC_ALL, nullptr);
|
2019-11-19 01:57:33 +00:00
|
|
|
if(getenv("TERM") == nullptr){
|
|
|
|
GTEST_SKIP();
|
|
|
|
}
|
2019-11-19 14:54:14 +00:00
|
|
|
notcurses_options nopts{};
|
2019-11-27 15:43:03 +00:00
|
|
|
nopts.outfp = stdin;
|
2019-11-19 14:54:14 +00:00
|
|
|
nc_ = notcurses_init(&nopts);
|
2019-11-19 11:44:28 +00:00
|
|
|
ASSERT_NE(nullptr, nc_);
|
2019-11-19 01:57:33 +00:00
|
|
|
}
|
2019-11-19 10:33:38 +00:00
|
|
|
|
2019-11-23 17:28:42 +00:00
|
|
|
void TearDown() override {
|
|
|
|
if(nc_){
|
|
|
|
EXPECT_EQ(0, notcurses_stop(nc_));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 01:46:46 +00:00
|
|
|
struct notcurses* nc_{};
|
2019-11-19 01:57:33 +00:00
|
|
|
};
|
|
|
|
|
2019-11-27 01:46:46 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-11-19 01:57:33 +00:00
|
|
|
TEST_F(NotcursesTest, BasicLifetime) {
|
2019-11-17 15:25:40 +00:00
|
|
|
}
|
|
|
|
|
2019-11-19 01:57:33 +00:00
|
|
|
TEST_F(NotcursesTest, TermDimensions) {
|
2019-11-17 15:25:40 +00:00
|
|
|
int x, y;
|
2019-11-21 13:19:14 +00:00
|
|
|
notcurses_term_dimyx(nc_, &y, &x);
|
2019-11-17 15:25:40 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-11-17 14:53:59 +00:00
|
|
|
}
|
2019-11-21 11:38:21 +00:00
|
|
|
|
|
|
|
TEST_F(NotcursesTest, ResizeSameSize) {
|
|
|
|
int x, y;
|
2019-11-21 13:19:14 +00:00
|
|
|
notcurses_term_dimyx(nc_, &y, &x);
|
2019-11-21 11:38:21 +00:00
|
|
|
EXPECT_EQ(0, notcurses_resize(nc_));
|
|
|
|
int newx, newy;
|
2019-11-21 13:19:14 +00:00
|
|
|
notcurses_term_dimyx(nc_, &newy, &newx);
|
2019-11-21 11:38:21 +00:00
|
|
|
EXPECT_EQ(newx, x);
|
|
|
|
EXPECT_EQ(newy, y);
|
|
|
|
}
|
2019-11-23 15:42:46 +00:00
|
|
|
|
2019-11-25 15:18:25 +00:00
|
|
|
// we should at least have WA_BOLD everywhere, i should think?
|
2019-11-23 15:42:46 +00:00
|
|
|
TEST_F(NotcursesTest, CursesStyles) {
|
|
|
|
unsigned attrs = notcurses_supported_styles(nc_);
|
2019-11-25 15:18:25 +00:00
|
|
|
EXPECT_EQ(1, !!(WA_BOLD & attrs));
|
2019-11-23 15:42:46 +00:00
|
|
|
}
|