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

enable from class fcf::NTest::Friendly

Property: enable = true

Type: bool

Class: fcf::NTest::Friendly

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 enable property is a boolean flag within the fcf::NTest::Friendly structure. It acts as a toggle for the stream's formatting behavior when interacting with numeric types that support the fcf::NTest::Friendly manipulator.

When this property is set:

  • If true (default): Numeric values (such as fcf::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 fcf::NTest::Friendly::enable property to switch between human-readable and raw numeric formats in an output stream.

#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