mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
Visual C++ constructor test #538
This commit is contained in:
parent
0331ae4c4c
commit
6a9bbad91e
@ -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*
|
||||||
|
@ -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
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
|
Loading…
Reference in New Issue
Block a user