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

testFunction from class fcf::NTest::Test

Property: testFunction = nullptr

Type: void (*)( )

Class: fcf::NTest::Test

Package: fcfTest

File: test.hpp

Available from version: 1.2.1

A function pointer to the actual test logic.

The testFunction property is a function pointer that points to the executable code of the test case. This is the core component that the test runner invokes during the execution phase.

When using the FCF_TEST_DEFINE macro, the framework automatically generates a static function and assigns its address to this property, allowing for seamless test registration and execution.

Example: Internal Mechanism of Test Execution

While users typically interact with tests via macros, this example demonstrates the underlying structure of a fcf::NTest::Test object and its testFunction.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> // A standard test function void MyManualTest() { fcf::NTest::log() << "Manual test execution!" << std::endl; } int main(int a_argc, char* a_argv[]) { // Manually creating a Test object fcf::NTest::Test manualTest; manualTest.part = "Manual"; manualTest.group = "Demo"; manualTest.test = "ManualTest"; manualTest.testFunction = &MyManualTest; // Adding it to the global storage fcf::NTest::storage().appendTest(manualTest); bool error = false; fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

Performing the test: "Manual" -> "Demo" -> "ManualTest" ... > Manual test execution! [SUCCESS] Test completed successfully (0.000`005`055 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`005`055 sec