* introduce doctest over googletest #202 * call dtester in in targets * doctest conversion #202 * channel.cpp -> doctest #202 * egcpool tests -> doctest #202 * input tests to doctester * zaxis -> doctest * drone: always define LANG * libav to doctest #202 * panelreel tests to doctest #202 * spec that a C++17 compiler is now required for doctest #202 * enmetric tests -> doctest #202 * fade tests -> doctest #202 * notcurses test case -> doctest #202 * last conversion to doctest #202 * finish move to doctest #202 * drone: set up make testpull/232/head
parent
d4caefc55d
commit
ce2a390b52
File diff suppressed because it is too large
Load Diff
@ -1,38 +1,20 @@
|
||||
#include "main.h"
|
||||
|
||||
class InputTest : public :: testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
setlocale(LC_ALL, "");
|
||||
TEST_CASE("NotcursesInput") {
|
||||
if(getenv("TERM") == nullptr){
|
||||
GTEST_SKIP();
|
||||
return;
|
||||
}
|
||||
notcurses_options nopts{};
|
||||
nopts.inhibit_alternate_screen = true;
|
||||
nopts.suppress_bannner = true;
|
||||
outfp_ = fopen("/dev/tty", "wb");
|
||||
ASSERT_NE(nullptr, outfp_);
|
||||
nc_ = notcurses_init(&nopts, outfp_);
|
||||
ASSERT_NE(nullptr, nc_);
|
||||
}
|
||||
FILE* outfp_ = fopen("/dev/tty", "wb");
|
||||
REQUIRE(outfp_);
|
||||
struct notcurses* nc_ = notcurses_init(&nopts, outfp_);
|
||||
REQUIRE(nc_);
|
||||
|
||||
void TearDown() override {
|
||||
if(nc_){
|
||||
EXPECT_EQ(0, notcurses_stop(nc_));
|
||||
}
|
||||
if(outfp_){
|
||||
fclose(outfp_);
|
||||
}
|
||||
}
|
||||
|
||||
struct notcurses* nc_{};
|
||||
FILE* outfp_{};
|
||||
};
|
||||
|
||||
TEST_F(InputTest, TestMouseOn){
|
||||
ASSERT_EQ(0, notcurses_mouse_enable(nc_));
|
||||
}
|
||||
REQUIRE(0 == notcurses_mouse_enable(nc_));
|
||||
CHECK(0 == notcurses_mouse_disable(nc_));
|
||||
|
||||
TEST_F(InputTest, TestMouseOff){
|
||||
ASSERT_EQ(0, notcurses_mouse_disable(nc_));
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
CHECK(0 == fclose(outfp_));
|
||||
}
|
||||
|
@ -1,104 +1,92 @@
|
||||
#include <notcurses.h>
|
||||
#include "version.h"
|
||||
#include "main.h"
|
||||
#ifndef DISABLE_FFMPEG
|
||||
#include <libavutil/pixdesc.h>
|
||||
#include <libavutil/avconfig.h>
|
||||
#include <libavcodec/avcodec.h> // ffmpeg doesn't reliably "C"-guard itself
|
||||
#endif
|
||||
|
||||
class LibavTest : public :: testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
setlocale(LC_ALL, "");
|
||||
TEST_CASE("Multimedia") {
|
||||
if(getenv("TERM") == nullptr){
|
||||
GTEST_SKIP();
|
||||
return;
|
||||
}
|
||||
notcurses_options nopts{};
|
||||
nopts.inhibit_alternate_screen = true;
|
||||
nopts.suppress_bannner = true;
|
||||
outfp_ = fopen("/dev/tty", "wb");
|
||||
ASSERT_NE(nullptr, outfp_);
|
||||
nc_ = notcurses_init(&nopts, outfp_);
|
||||
ASSERT_NE(nullptr, nc_);
|
||||
ncp_ = notcurses_stdplane(nc_);
|
||||
ASSERT_NE(nullptr, ncp_);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if(nc_){
|
||||
EXPECT_EQ(0, notcurses_stop(nc_));
|
||||
}
|
||||
if(outfp_){
|
||||
fclose(outfp_);
|
||||
}
|
||||
}
|
||||
|
||||
notcurses* nc_{};
|
||||
ncplane* ncp_{};
|
||||
FILE* outfp_{};
|
||||
};
|
||||
FILE* outfp_ = fopen("/dev/tty", "wb");
|
||||
REQUIRE(outfp_);
|
||||
notcurses* nc_ = notcurses_init(&nopts, outfp_);
|
||||
REQUIRE(nc_);
|
||||
ncplane* ncp_ = notcurses_stdplane(nc_);
|
||||
REQUIRE(ncp_);
|
||||
|
||||
#ifdef DISABLE_FFMPEG
|
||||
TEST_F(LibavTest, LibavDisabled){
|
||||
ASSERT_FALSE(notcurses_canopen(nc_));
|
||||
}
|
||||
SUBCASE("LibavDisabled"){
|
||||
REQUIRE(!notcurses_canopen(nc_));
|
||||
}
|
||||
#else
|
||||
#include <libavutil/pixdesc.h>
|
||||
#include <libavutil/avconfig.h>
|
||||
#include <libavcodec/avcodec.h> // ffmpeg doesn't reliably "C"-guard itself
|
||||
|
||||
TEST_F(LibavTest, LibavEnabled){
|
||||
ASSERT_TRUE(notcurses_canopen(nc_));
|
||||
}
|
||||
SUBCASE("LibavEnabled"){
|
||||
REQUIRE(notcurses_canopen(nc_));
|
||||
}
|
||||
|
||||
TEST_F(LibavTest, LoadImage) {
|
||||
SUBCASE("LoadImage") {
|
||||
int averr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncplane_visual_open(ncp_, "../data/dsscaw-purp.png", &averr);
|
||||
ASSERT_NE(nullptr, ncv);
|
||||
ASSERT_EQ(0, averr);
|
||||
REQUIRE(ncv);
|
||||
REQUIRE(0 == averr);
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
ASSERT_NE(nullptr, frame);
|
||||
ASSERT_EQ(0, averr);
|
||||
EXPECT_EQ(dimy * 2, frame->height);
|
||||
EXPECT_EQ(dimx, frame->width);
|
||||
EXPECT_EQ(0, ncvisual_render(ncv, 0, 0, 0, 0));
|
||||
EXPECT_EQ(0, notcurses_render(nc_));
|
||||
REQUIRE(frame);
|
||||
REQUIRE(0 == averr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 == ncvisual_render(ncv, 0, 0, 0, 0));
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
frame = ncvisual_decode(ncv, &averr);
|
||||
ASSERT_EQ(nullptr, frame);
|
||||
EXPECT_EQ(AVERROR_EOF, averr);
|
||||
REQUIRE_EQ(nullptr, frame);
|
||||
CHECK(AVERROR_EOF == averr);
|
||||
ncvisual_destroy(ncv);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME ought run through full video, not just first frame
|
||||
TEST_F(LibavTest, LoadVideo) {
|
||||
// FIXME ought run through full video, not just first frame
|
||||
SUBCASE("LoadVideo") {
|
||||
int averr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncplane_visual_open(ncp_, "../data/fm6.mkv", &averr);
|
||||
ASSERT_NE(nullptr, ncv);
|
||||
EXPECT_EQ(0, averr);
|
||||
REQUIRE(ncv);
|
||||
CHECK(0 == averr);
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
ASSERT_NE(nullptr, frame);
|
||||
EXPECT_EQ(0, averr);
|
||||
EXPECT_EQ(dimy * 2, frame->height);
|
||||
EXPECT_EQ(dimx, frame->width);
|
||||
EXPECT_EQ(0, ncvisual_render(ncv, 0, 0, 0, 0));
|
||||
EXPECT_EQ(0, notcurses_render(nc_));
|
||||
REQUIRE(frame);
|
||||
CHECK(0 == averr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 == ncvisual_render(ncv, 0, 0, 0, 0));
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
ncvisual_destroy(ncv);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LibavTest, LoadVideoCreatePlane) {
|
||||
SUBCASE("LoadVideoCreatePlane") {
|
||||
int averr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncvisual_open_plane(nc_, "../data/fm6.mkv", &averr, 0, 0, NCSCALE_STRETCH);
|
||||
ASSERT_NE(nullptr, ncv);
|
||||
EXPECT_EQ(0, averr);
|
||||
REQUIRE(ncv);
|
||||
CHECK(0 == averr);
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
ASSERT_NE(nullptr, frame);
|
||||
EXPECT_EQ(0, averr);
|
||||
EXPECT_EQ(dimy * 2, frame->height);
|
||||
EXPECT_EQ(dimx, frame->width);
|
||||
EXPECT_EQ(0, ncvisual_render(ncv, 0, 0, 0, 0));
|
||||
EXPECT_EQ(0, notcurses_render(nc_));
|
||||
REQUIRE_NE(nullptr, frame);
|
||||
CHECK(0 == averr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 == ncvisual_render(ncv, 0, 0, 0, 0));
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
ncvisual_destroy(ncv);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CHECK(!notcurses_stop(nc_));
|
||||
CHECK(!fclose(outfp_));
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,8 @@
|
||||
#ifndef NOTCURSES_TEST_MAIN
|
||||
#define NOTCURSES_TEST_MAIN
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "doctest.h"
|
||||
#include <notcurses.h>
|
||||
#include <curses.h>
|
||||
|
||||
// GTEST_SKIP only came along in GoogleTest 1.9
|
||||
#ifndef GTEST_SKIP
|
||||
#define GTEST_SKIP() return;
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue