When instantiate test using INSTANTIATE_TEST_CASE_P according to tuple params Each test have suffix that by default running number from zero
How I can force to have sense suffix ? How to override builtin parameterized test name generator ::testing::PrintToStringParamName ?
My answer is a more complete example, based on BaraBashkaD's answer.
struct Location
{
std::string Name;
double Latitude;
double Longitude;
std::string CountryCode;
std::string AdminOneCode;
std::string LocaleID;
};
class NorthAmericaParamTest : public testing::TestWithParam<Location>
{
public:
struct PrintToStringParamName
{
template <class ParamType>
std::string operator()( const testing::TestParamInfo<ParamType>& info ) const
{
auto location = static_cast<Location>(info.param);
return location.Name;
}
};
};
TEST_P( NorthAmericaParamTest, City )
{
// Setup
// Software Unit Under Test
// Evaluate
// Evaluate
EXPECT_TRUE( true );
}
INSTANTIATE_TEST_CASE_P( UnitedStates, NorthAmericaParamTest, testing::Values
(
Location{ "Alta", -28.5, -42.84, "Alta", "AltaCouloir", "AltaCouloir" },
Location{ "Snow", -32.5, -42.84, "Snow", "SnowCouloir", "SnowCouloir" },
Location{ "Vail", -24.5, -42.84, "Bird", "BirdCouloir", "BirdCouloir" }
), NorthAmericaParamTest::PrintToStringParamName() );
You can return a std::string from the struct, but not a local variable.
Results in unit test runner:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With