Demonstrates how a fcf::NTest::Test object is structured and how its comparison operators work, which is essential for understanding how the framework handles test sorting and selection.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
// A dummy test function to use as a pointer
void my_test_function() {
// Test logic would go here
}
FCF_TEST_DEFINE("Manual", "Demo", "TestObjectCreation") {
// 1. Manually constructing a Test object
// The parameters are: part, partOrder, group, groupOrder, test, testOrder, testFunction
fcf::NTest::Test test1 = {"Math", 1, "Arithmetic", 1, "Addition", 1, my_test_function};
// 2. Creating another test object with different priority
fcf::NTest::Test test2 = {"Math", 2, "Arithmetic", 1, "Subtraction", 1, my_test_function};
// 3. Demonstrating the comparison operator used by the framework for sorting
// test1 should come before test2 because its partOrder (1) is less than test2's partOrder (2)
if (test1 < test2) {
fcf::NTest::log() << "Test 1 comes before Test 2 due to partOrder" << std::endl;
}
// 4. Verifying equality
fcf::NTest::Test test1_copy = test1;
FCF_TEST(test1 == test1_copy, "Test objects should be equal");
// 5. Accessing metadata
fcf::NTest::log() << "Executing test: " << test1.test << 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: "Manual" -> "Demo" -> "TestObjectCreation" ...
> Test 1 comes before Test 2 due to partOrder
> Executing test: Addition
[SUCCESS] Test completed successfully (0.000`009`820 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`009`820 sec