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

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

size_t counter() const

Class: fcf::NTest::HistogramBasic

Package: fcfTest

File: test.hpp

Available from version: 1.2.5

Returns the total number of items appended to the histogram.

The counter method provides the cumulative count of all data points added to the histogram via the append method.

Result
size_t
- The total count of items added.

Example: Getting the total count

Simple example of retrieving the total number of elements.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> FCF_TEST_DEFINE("HistogramDemo", "Counter", "GetCounter") { fcf::NTest::HistogramBasic<int> hist; hist.append(1); hist.append(2, 10); hist.append(3, 5); size_t total = hist.counter(); fcf::NTest::log() << "Total items: " << total << std::endl; FCF_TEST(total == 16); } 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" -> "Counter" -> "GetCounter" ... > Total items: 16 [SUCCESS] Test completed successfully (0.000`028`728 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`028`728 sec