mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
BigMult unit test, fix ncmetric bogon #929
This commit is contained in:
parent
f8854f84e8
commit
bc0016b827
@ -374,7 +374,8 @@ summary_table(struct ncdirect* nc, const char* spec){
|
||||
qprefix(results[i].stats.render_ns, GIG, rtimebuf, 0);
|
||||
bprefix(results[i].stats.render_bytes, 1, totalbuf, 0);
|
||||
if(results[i].stats.renders){
|
||||
qprefix((uintmax_t)results[i].stats.renders * GIG * 1000 / results[i].stats.render_ns, 1000, tfpsbuf, 0);
|
||||
qprefix((uintmax_t)results[i].stats.renders * GIG * 1000 / results[i].stats.render_ns,
|
||||
1000, tfpsbuf, 0);
|
||||
}else{
|
||||
qprefix(0, GIG, tfpsbuf, 0);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ const char *ncmetric(uintmax_t val, uintmax_t decimal, char *buf, int omitdec,
|
||||
}
|
||||
int sprintfed;
|
||||
if(dv != mult){ // if consumed == 0, dv must equal mult
|
||||
if(val / dv > 0){
|
||||
if((val / decimal) / dv > 0){
|
||||
++consumed;
|
||||
}else{
|
||||
dv /= mult;
|
||||
|
@ -447,4 +447,15 @@ TEST_CASE("Metric") {
|
||||
CHECK(wcslen(smallsuffixes) * 3 > i);
|
||||
}
|
||||
|
||||
// inspired by #929
|
||||
SUBCASE("BigMult") {
|
||||
char qbuf[IPREFIXSTRLEN + 1];
|
||||
CHECK(nullptr != qprefix(1115614, 1000, qbuf, '\0'));
|
||||
CHECK(0 == strcmp("1.11K", qbuf));
|
||||
CHECK(nullptr != iprefix(372688, 1024, qbuf, '\0'));
|
||||
CHECK(0 == strcmp("363.95", qbuf));
|
||||
CHECK(nullptr != iprefix(372688, 1, qbuf, '\0'));
|
||||
CHECK(0 == strcmp("363.95K", qbuf));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user