Skip to content

Commit

Permalink
Add a global variable for spacing output text
Browse files Browse the repository at this point in the history
  • Loading branch information
fwojcik committed Aug 29, 2023
1 parent 3953856 commit 4bd617b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
9 changes: 3 additions & 6 deletions util/Reporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,25 +465,22 @@ bool ReportBitsCollisions( uint64_t nbH, int * collcounts, int minBits, int maxB
}

if (verbose) {
const char * spaces = " ";
int i_maxCollDevExp = (int)round(maxCollDevExp);
spacelen -= printf("Worst is %2i bits: %i/%i ", maxCollDevBits, maxCollDevNb, i_maxCollDevExp);
if (spacelen < 0) {
spacelen = 0;
} else if (spacelen > (int)strlen(spaces)) {
spacelen = strlen(spaces);
}

if (maxCollDev >= 999.95) {
maxCollDev = INFINITY;
}

if (!isfinite(maxCollDev)) {
printf("%.*s(------) ", spacelen, spaces);
printf("%.*s(------) ", spacelen, g_manyspaces);
} else if (maxCollDev < 9.0) {
printf("%.*s(%5.3fx) ", spacelen, spaces, maxCollDev);
printf("%.*s(%5.3fx) ", spacelen, g_manyspaces, maxCollDev);
} else {
printf("%.*s(%#.4gx) ", spacelen, spaces, maxCollDev);
printf("%.*s(%#.4gx) ", spacelen, g_manyspaces, maxCollDev);
}

if (drawDiagram) {
Expand Down
6 changes: 6 additions & 0 deletions util/TestGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@ const char * g_failstr = "*********FAIL*********\n";
uint32_t g_log2pValueCounts[COUNT_MAX_PVALUE + 2];
uint32_t g_testPass, g_testFail;
std::vector<std::pair<const char *, char *>> g_testFailures;

//--------
// A string with 128 spaces, useful for aligning text outputs
const char * g_manyspaces =
" " \
" ";
3 changes: 3 additions & 0 deletions util/TestGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ extern seed_t g_seed;
// What each test suite prints upon failure
extern const char * g_failstr;

// A string with 128 spaces, used for aligning text outputs
extern const char * g_manyspaces;

// By rights, the HAVE_HASHINFO #define shouldn't exist, but C++11
// doesn't allow forward declaration of class enums (enum classes,
// yes, but not class enums) for no good reason, and we definitely
Expand Down

0 comments on commit 4bd617b

Please sign in to comment.