If we just run this test, then we will not see any message. However, if we run the test by transferring the login mode to "dbg" (Debug), we will see our message.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
// Tested structure
struct User {
int frontPos;
void go() { ++frontPos; }
void back() { --frontPos; }
};
// Our main test
FCF_TEST_DECLARE("Engine", "User", "Motion"){
User user = {0};
// By default, the log output will not be executed
// It is necessary to set the level of logging, debug or higher.
fcf::NTest::dbg() << " The user started moving" << std::endl;
user.go();
fcf::NTest::dbg() << " The user went back" << std::endl;
user.back();
FCF_TEST(user.frontPos == 0, user.frontPos);
}
int main(int a_argc, char* a_argv[]) {
bool error;
// We run all tests declared in the application
fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error);
return error ? 1 : 0;
}
Running (Start by default. Level logging is log):
LAUNCH $: ./example
Output:
Performing the test: "Engine" -> "User" -> "Motion" ...
[SUCCESS] Test completed successfully (0.000`002`743 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`002`743 sec
Running (We start with the logging mode debug):
LAUNCH $: ./example --test-log-level dbg
Output:
Performing the test: "Engine" -> "User" -> "Motion" ...
> The user started moving
> The user went back
[SUCCESS] Test completed successfully (0.000`008`661 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`008`661 sec