Visual C++ constructor test #538

This commit is contained in:
nick black 2020-05-29 19:59:46 -04:00
parent 0331ae4c4c
commit 6a9bbad91e
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
4 changed files with 25 additions and 2 deletions

View File

@ -2421,7 +2421,7 @@ API struct ncplane* nctablet_ncplane(struct nctablet* t);
// uprefix: character to print following suffix ('i' for kibibytes basically). // uprefix: character to print following suffix ('i' for kibibytes basically).
// only printed if suffix is actually printed (input >= mult). // only printed if suffix is actually printed (input >= mult).
API const char* ncmetric(uintmax_t val, uintmax_t decimal, char* buf, API const char* ncmetric(uintmax_t val, uintmax_t decimal, char* buf,
int omitdec, unsigned mult, int uprefix); int omitdec, uintmax_t mult, int uprefix);
// Mega, kilo, gigafoo. Use PREFIXSTRLEN + 1. // Mega, kilo, gigafoo. Use PREFIXSTRLEN + 1.
static inline const char* static inline const char*

View File

@ -5,7 +5,7 @@
#include "notcurses/notcurses.h" #include "notcurses/notcurses.h"
const char *ncmetric(uintmax_t val, uintmax_t decimal, char *buf, int omitdec, const char *ncmetric(uintmax_t val, uintmax_t decimal, char *buf, int omitdec,
unsigned mult, int uprefix){ uintmax_t mult, int uprefix){
// these two must have the same number of elements // these two must have the same number of elements
const wchar_t prefixes[] = L"KMGTPEZY"; // 10^21-1 encompasses 2^64-1 const wchar_t prefixes[] = L"KMGTPEZY"; // 10^21-1 encompasses 2^64-1
const wchar_t subprefixes[] = L"mµnpfazy"; // 10^24-1 const wchar_t subprefixes[] = L"mµnpfazy"; // 10^24-1

View File

@ -1,4 +1,5 @@
#include "main.h" #include "main.h"
#include "ncpp/Visual.hh"
using namespace ncpp; using namespace ncpp;
@ -25,4 +26,25 @@ TEST_CASE("Ncpp"
CHECK(ncnull.stop()); CHECK(ncnull.stop());
} }
SUBCASE("VisualFromFile") {
NotCurses nc;
nc_err_e err;
{
Visual v = Visual(find_data("changes.jpg"), &err);
CHECK(NCERR_SUCCESS == err);
}
CHECK(nc.stop());
}
/*
SUBCASE("VisualFromRGBA") {
NotCurses nc;
{
Visual v = Visual.from_rgba("\x40\x80\xc0\xff", 1, 4, 1);
CHECK(NCERR_SUCCESS == err);
}
CHECK(nc.stop());
}
*/
} }

View File

@ -89,6 +89,7 @@ TEST_CASE("Metric") {
// FIXME these will change based on the size of intmax_t and uintmax_t // FIXME these will change based on the size of intmax_t and uintmax_t
ncmetric(INTMAX_MAX - 1, 1, buf, 0, 1024, 'i'); ncmetric(INTMAX_MAX - 1, 1, buf, 0, 1024, 'i');
sprintf(gold, "%.2fEi", ((double)(INTMAX_MAX - (1ull << 53))) / (1ull << 60)); sprintf(gold, "%.2fEi", ((double)(INTMAX_MAX - (1ull << 53))) / (1ull << 60));
fprintf(stderr, "%d gold: %s buf: %s value: %ju\n", __LINE__, gold, buf, INTMAX_MAX - 1);
CHECK(!strcmp(gold, buf)); CHECK(!strcmp(gold, buf));
REQUIRE(ncmetric(INTMAX_MAX + 1ull, 1, buf, 0, 1024, 'i')); REQUIRE(ncmetric(INTMAX_MAX + 1ull, 1, buf, 0, 1024, 'i'));
sprintf(gold, "%.2fEi", ((double)(INTMAX_MAX + 1ull)) / (1ull << 60)); sprintf(gold, "%.2fEi", ((double)(INTMAX_MAX + 1ull)) / (1ull << 60));