overflow() method from fcf::NTest::HistogramBasic class
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.5
Checks if a given value falls outside the current histogram range.
The [min, max]).
This is particularly useful when you want to decide whether to manually resize the histogram or to handle extreme outliers before they trigger an automatic rebuild.
Arguments
- The value to check against the current range.
Result
- Returns true if the value is strictly less than the current minimum or strictly greater than the current maximum, and the histogram has been initialized.
Example: Detecting Out-of-Range Values
Checking if a value will trigger an automatic rebuild of the histogram.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <iostream>
FCF_TEST_DEFINE ("HistogramDemo", "Basic", "OverflowCheck") {
// Initialize histogram with a fixed range [10, 20]
fcf::NTest::HistogramBasic <int> hist(5, 10, 20);
// 1. Check a value within range
bool inRange = !hist.overflow (15) ;
fcf::NTest::log () << "Is 15 in range? " << (inRange ? "Yes" : "No") << std::endl;
// 2. Check a value outside range
bool outOfRange = hist.overflow (25);
fcf::NTest::log () << "Is 25 out of range? " << (outOfRange ? "Yes" : "No") << std::endl;
FCF_TEST (inRange == true);
FCF_TEST (outOfRange == 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" -> "Basic" -> "OverflowCheck" ...
> Is 15 in range? Yes
> Is 25 out of range? Yes
[SUCCESS] Test completed successfully (0.000`023`828 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`023`828 sec
Use
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.