enable from class fcf::NTest::Friendly
Type:
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.5
Flag that controls whether numeric values are displayed in a human-readable format.
The
When this property is set:
- If
true (default): Numeric values (such asfcf::NTest::TimeDuration ) are formatted in a "friendly" human-readable way, using backticks (`) as separators for different precision levels (e.g.,1.234`567`890). - If
false : Numeric values are displayed in their standard, high-precision format (e.g.,1.234567890).
Example: Toggling Human-Readable Output
Demonstrating how to use the
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <iostream>
FCF_TEST_DEFINE ("Formatting", "Utility", "FriendlyEnableTest"){
// Create a duration object with a specific value
fcf::NTest::TimeDuration duration(1234567890);
// 1. Create a Friendly object and set enable to true
fcf::NTest::Friendly friendlyTrue;
friendlyTrue.enable = true;
fcf::NTest::log () << "Friendly mode (true): " << friendlyTrue << duration << std::endl;
// 2. Create a Friendly object and set enable to false
fcf::NTest::Friendly friendlyFalse;
friendlyFalse.enable = false;
fcf::NTest::log () << "Raw mode (false): " << friendlyFalse << duration << std::endl;
}
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: "Formatting" -> "Utility" -> "FriendlyEnableTest" ...
> Friendly mode (true): 1.234`567`890
> Raw mode (false): 1.234567890
[SUCCESS] Test completed successfully (0.000`001`234 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`001`234 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.