template <typename ...TValuePack> void
appendParamValue(
const std::string& a_partName,
const std::string& a_groupName,
const std::string& a_testName,
const TValuePack& ...a_parameterPack)
template <typename ...TValuePack> void
appendParamValue(
const fcf::NTest::Test& a_a_test,
const TValuePack& ...a_parameterPack)
template <typename ...TValuePack> void
appendParamValue(
const fcf::NTest::TestPath& a_testPath,
const TValuePack& ...a_parameterPack)
Class: fcf::NTest::Storage
Package: fcfTest
File:
test.hpp
(
link_to_the_declaration_in_the_file
,
link_to_the_implementation_in_the_file
)
Available from version: 1.2.4
Adds a values as a parameters to a specific test case by automatically wrapping it in fcf::NTest::SharedPtrAny.
The appendParamValue method is a convenient template wrapper around appendParam.
Instead of manually creating a fcf::NTest::SharedPtrAny object using make, you can pass the value directly. The method will automatically wrap the value in a fcf::NTest::SharedPtrAny container, making the code cleaner and easier to read.
Template arguments
TValuePack
- Type of values being set
Arguments
const std::string& a_partName
- The name of the test part.
const std::string& a_groupName
- The name of the test group.
const std::string& a_testName
- The name of the test function.
const TValuePack&... a_parameterPack
- The values to be wrapped and added as a parameters.
Example: Using appendParamValue for convenience
Demonstrating how appendParamValue simplifies adding parameters of various types.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
FCF_TEST_BEFORE_DEFINE("*", "*", "*", fcf::NTest::FL_GLOBAL) {
// Use the `appendParamValue` method to add test parameters as values a test.
fcf::NTest::storage().appendParamValue("MyLib", "Params", "AppendTest",
42,
53,
71);
}
FCF_TEST_DEFINE("MyLib", "Params", "AppendTest") {
fcf::NTest::SharedPtrAny p = fcf::NTest::state().param();
FCF_TEST(p.is<int>(), "Parameter should be an int");
int* val = p.cast<int>();
fcf::NTest::log() << "Value: " << *val << 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: "MyLib" -> "Params" -> "AppendTest" ...
== Parameter set: 1
> Value: 42
== Parameter set: 2
> Value: 53
== Parameter set: 3
> Value: 71
[SUCCESS] Test completed successfully (0.000`018`606 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`018`606 sec