groups from class fcf::NTest::Fixture
Property: groups
Type:
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.1
A list of group names to which this fixture applies.
The
When specifying names, you can use the wildcard character
Example: Filtering by Group
Demonstrating how to use the
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <cmath>
// Fixture added by the macro
FCF_TEST_BEFORE_DEFINE ("Math", "Sin", "*", fcf::NTest::FL_GROUP ) {
fcf::NTest::log () << "Running Math/Sin group setup..." << std::endl;
// Create user data for the test
fcf::NTest::state ().data ("math-sin-const", fcf::NTest::SharedPtrAny::make <float>(3.1416));
}
// Fixture handler function added manually
void manualMathCosBeforeFixture(){
fcf::NTest::log () << "Running Math/Cos group setup..." << std::endl;
// Create user data for the test
fcf::NTest::state ().data ("math-cos-const", fcf::NTest::SharedPtrAny::make <float>(3.1416));
}
FCF_TEST_DEFINE ("Math", "Sin", "simple test") {
// Get and check user data created by the fixture
float* sinConstPtr = fcf::NTest::state ().data ("math-sin-const").cast <float>();
FCF_TEST (std::abs(*sinConstPtr - 3.14) < 0.1, *sinConstPtr);
}
FCF_TEST_DEFINE ("Math", "Cos", "simple test") {
// Get and check user data created by the fixture
float* cosConstPtr = fcf::NTest::state ().data ("math-cos-const").cast <float>();
FCF_TEST (std::abs(*cosConstPtr - 3.14) < 0.1, *cosConstPtr);
}
int main(int a_argc, char* a_argv[]) {
// Manually adding a fixture
fcf::NTest::Fixture fixture;
fixture.parts .push_back("Math");
fixture.groups .push_back("Cos");
fixture.tests .push_back("*");
fixture.before = true;
fixture.level = fcf::NTest::FL_GROUP ;
fixture.fixtureFunction = manualMathCosBeforeFixture;
fixture.file = __FILE__;
fixture.line = 12;
fcf::NTest::storage ().appendFixture (fixture);
bool error = false;
fcf::NTest::cmdRun (a_argc, a_argv, fcf::NTest::CRM_RUN , &error);
return error ? 1 : 0;
}
Output:
> Running Math/Cos group setup...
Performing the test: "Math" -> "Cos" -> "simple test" ...
[SUCCESS] Test completed successfully (0.000`001`550 sec)
> Running Math/Sin group setup...
Performing the test: "Math" -> "Sin" -> "simple test" ...
[SUCCESS] Test completed successfully (0.000`000`856 sec)
[SUCCESS] All tests were completed.
Tests: 2 passed, 0 failed, 0 skipped, 2 total
Duration: 0.000`002`406 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.