2020-05-22 07:31:03 +00:00
|
|
|
#include "main.h"
|
2020-05-29 23:59:46 +00:00
|
|
|
#include "ncpp/Visual.hh"
|
2020-05-22 07:31:03 +00:00
|
|
|
|
|
|
|
using namespace ncpp;
|
|
|
|
|
|
|
|
TEST_CASE("Ncpp"
|
|
|
|
* doctest::description("Basic C++ wrapper tests")) {
|
|
|
|
|
2020-07-23 05:53:59 +00:00
|
|
|
notcurses_options nopts{};
|
|
|
|
nopts.flags = NCOPTION_SUPPRESS_BANNERS |
|
|
|
|
NCOPTION_INHIBIT_SETLOCALE;
|
2020-07-23 05:56:42 +00:00
|
|
|
nopts.loglevel = NCLOGLEVEL_VERBOSE;
|
2020-07-23 05:53:59 +00:00
|
|
|
|
2020-05-22 07:31:03 +00:00
|
|
|
// we ought be able to construct a NotCurses object with a nullptr FILE
|
|
|
|
// or even just no argument (decays to nullptr).
|
|
|
|
SUBCASE("ConstructNotCurses") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(!NotCurses::is_notcurses_stopped(&nc));
|
2020-05-22 07:31:03 +00:00
|
|
|
CHECK(nc.stop());
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(NotCurses::is_notcurses_stopped(&nc));
|
2020-05-22 07:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("ConstructNotCursesNullFILE") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses ncnull{ nopts, nullptr };
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(!NotCurses::is_notcurses_stopped(&ncnull));
|
2020-05-22 07:31:03 +00:00
|
|
|
CHECK(ncnull.stop());
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(NotCurses::is_notcurses_stopped(&ncnull));
|
2020-05-22 07:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// we ought be able to get a new NotCurses object after stop()ping one.
|
|
|
|
SUBCASE("ConstructNotCursesTwice") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-05-22 07:31:03 +00:00
|
|
|
CHECK(nc.stop());
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(NotCurses::is_notcurses_stopped(&nc));
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses ncnull{ nopts, nullptr };
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(!NotCurses::is_notcurses_stopped(&ncnull));
|
2020-05-22 07:31:03 +00:00
|
|
|
CHECK(ncnull.stop());
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(NotCurses::is_notcurses_stopped(&ncnull));
|
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("StdPlane") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-07-12 05:42:17 +00:00
|
|
|
auto std1 = nc.get_stdplane();
|
|
|
|
CHECK(nullptr != std1);
|
|
|
|
int y, x;
|
|
|
|
auto std2 = nc.get_stdplane(&y, &x);
|
|
|
|
CHECK(nullptr != std2);
|
|
|
|
CHECK(0 < x);
|
|
|
|
CHECK(0 < y);
|
|
|
|
CHECK(nc.stop());
|
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("Debug") { // just test to ensure it doesn't coredump
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-07-12 05:42:17 +00:00
|
|
|
nc.debug(stderr);
|
|
|
|
CHECK(nc.stop());
|
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("GetPaletteSize") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-07-12 05:42:17 +00:00
|
|
|
CHECK(0 < nc.get_palette_size());
|
|
|
|
CHECK(nc.stop());
|
2020-05-22 07:31:03 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 23:59:46 +00:00
|
|
|
SUBCASE("VisualFromFile") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-06-01 08:24:04 +00:00
|
|
|
if(nc.can_open_images()){
|
|
|
|
{
|
2020-08-24 05:23:35 +00:00
|
|
|
Visual v = Visual(find_data("changes.jpg"));
|
2020-06-01 08:24:04 +00:00
|
|
|
}
|
2020-05-29 23:59:46 +00:00
|
|
|
}
|
|
|
|
CHECK(nc.stop());
|
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("VisualFromRGBA") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-05-30 00:14:34 +00:00
|
|
|
uint32_t rgba[] = {
|
|
|
|
0x4080c0ff,
|
|
|
|
0x105090ff,
|
|
|
|
};
|
2020-05-29 23:59:46 +00:00
|
|
|
{
|
2020-05-30 00:14:34 +00:00
|
|
|
Visual v = Visual(rgba, 1, sizeof(rgba), sizeof(rgba) / sizeof(*rgba));
|
|
|
|
// FIXME check geometry
|
|
|
|
}
|
|
|
|
CHECK(nc.stop());
|
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("VisualFromPlane") {
|
2020-07-23 05:53:59 +00:00
|
|
|
NotCurses nc{ nopts };
|
2020-05-30 00:14:34 +00:00
|
|
|
{
|
|
|
|
auto n = nc.get_stdplane();
|
|
|
|
REQUIRE(n);
|
|
|
|
// FIXME load something onto standard plane, load it into visual, erase
|
|
|
|
// plane, render visual, check for equivalence...
|
|
|
|
{
|
2020-06-06 09:11:45 +00:00
|
|
|
Visual v = Visual(*n, NCBLIT_DEFAULT, 0, 0, -1, -1);
|
2020-05-30 00:14:34 +00:00
|
|
|
}
|
2020-05-29 23:59:46 +00:00
|
|
|
}
|
|
|
|
CHECK(nc.stop());
|
|
|
|
}
|
|
|
|
|
2020-05-22 07:31:03 +00:00
|
|
|
}
|