FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

toTable() method from fcf::NTest::HistogramBasic class

std::string toTable() const
std::string toTable(size_t a_size) const
std::string toTable(TItem a_min, TItem a_max, size_t a_size) const
[STATIC] std::string toTable(const std::vector<TCounter>& a_vector, TItem a_min, TItem a_max)

Class: fcf::NTest::HistogramBasic

Package: fcfTest

File: test.hpp

Available from version: 1.2.5

Generates a formatted ASCII table representing the histogram distribution.

The toTable method produces a human-readable ASCII table that visualizes the distribution of data across the histogram bins.

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

TItem a_min
- The minimum boundary for the table range.

TItem a_max
- The maximum boundary for the table range.

size_t a_size
- The number of bins to use in the table.
Result
std::string
- 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