toTable() method from fcf::NTest::HistogramBasic class
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.5
Generates a formatted ASCII table representing the histogram distribution.
The
The table includes columns for the bin index, the range of values covered by the bin (e.g., [min : max]), and the count of items in that bin.
Arguments
- The minimum boundary for the table range.
- The maximum boundary for the table range.
- The number of bins to use in the table.
Result
- A string containing the ASCII table.
Example: Generating an ASCII Table
Demonstrating how to generate a formatted table for the current histogram data.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <iostream>
FCF_TEST_DEFINE ("HistogramDemo", "Table", "GenerateTable") {
fcf::NTest::HistogramBasic <int> hist(5, 0, 50);
hist.append (5);
hist.append (15);
hist.append (25);
hist.append (35);
hist.append (45);
// 1. Generate table using current histogram settings
std::string table = hist.toTable ();
fcf::NTest::log () << table << std::endl;
FCF_TEST (true);
}
int main(int a_argc, char* a_argv[]) {
bool error = false;
fcf::NTest::cmdRun (a_argc, a_argv, fcf::NTest::CRM_RUN , &error);
return error ? 1 : 0;
}
Output:
Performing the test: "HistogramDemo" -> "Table" -> "GenerateTable" ...
> ╔═══╦═══════════╦═══════╗
> ║ # ║ values ║ count ║
> ╠═══╬═══════════╬═══════╣
> ║ 1 ║ [ 0 : 9] ║ 1 ║
> ║ 2 ║ [10 : 19] ║ 1 ║
> ║ 3 ║ [20 : 29] ║ 1 ║
> ║ 4 ║ [30 : 39] ║ 1 ║
> ║ 5 ║ [40 : 50] ║ 1 ║
> ╚═══╩═══════════╩═══════╝
>
[SUCCESS] Test completed successfully (0.000`053`319 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`053`319 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.