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")) {
|
|
|
|
|
|
|
|
// we ought be able to construct a NotCurses object with a nullptr FILE
|
|
|
|
// or even just no argument (decays to nullptr).
|
|
|
|
SUBCASE("ConstructNotCurses") {
|
|
|
|
NotCurses nc;
|
|
|
|
CHECK(nc.stop());
|
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("ConstructNotCursesNullFILE") {
|
|
|
|
NotCurses ncnull(nullptr);
|
|
|
|
CHECK(ncnull.stop());
|
|
|
|
}
|
|
|
|
|
|
|
|
// we ought be able to get a new NotCurses object after stop()ping one.
|
|
|
|
SUBCASE("ConstructNotCursesTwice") {
|
|
|
|
NotCurses nc;
|
|
|
|
CHECK(nc.stop());
|
|
|
|
NotCurses ncnull(nullptr);
|
|
|
|
CHECK(ncnull.stop());
|
|
|
|
}
|
|
|
|
|
2020-05-29 23:59:46 +00:00
|
|
|
SUBCASE("VisualFromFile") {
|
|
|
|
NotCurses nc;
|
2020-06-01 08:24:04 +00:00
|
|
|
if(nc.can_open_images()){
|
|
|
|
nc_err_e err;
|
|
|
|
{
|
|
|
|
Visual v = Visual(find_data("changes.jpg"), &err);
|
|
|
|
CHECK(NCERR_SUCCESS == err);
|
|
|
|
}
|
2020-05-29 23:59:46 +00:00
|
|
|
}
|
|
|
|
CHECK(nc.stop());
|
|
|
|
}
|
|
|
|
|
|
|
|
SUBCASE("VisualFromRGBA") {
|
|
|
|
NotCurses nc;
|
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") {
|
|
|
|
NotCurses nc;
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|