Skip to content

Commit

Permalink
test: parameterized test added
Browse files Browse the repository at this point in the history
* added parameterized test to weather module

Signed-off-by: Guru Mehar Rachaputi <[email protected]>
  • Loading branch information
00thirdeye00 committed Sep 27, 2024
1 parent 5a81638 commit 91e8726
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/modules/weather_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,24 @@ const auto& getWeatherDefinition(Locale locale)
}
}

class WeatherTest : public Test
class WeatherTest : public TestWithParam<Locale>
{
public:
};

TEST_F(WeatherTest, shouldGenerateWeatherDescription)
{
const auto& weatherDefinition = getWeatherDefinition(Locale::en_US);

const std::string_view generatedWeatherDescription = weatherDescription(Locale::en_US);
const auto locale = GetParam();

const auto& weatherDefinition = getWeatherDefinition(locale);

const std::string_view generatedWeatherDescription = weatherDescription(locale);

ASSERT_TRUE(std::ranges::any_of(weatherDefinition,
[generatedWeatherDescription](const std::string_view& weatherDescription)
{ return weatherDescription == generatedWeatherDescription; }));
}

INSTANTIATE_TEST_SUITE_P(TestWeatherByLocale, WeatherTest, ValuesIn(locales),
[](const TestParamInfo<Locale>& paramInfo) { return toString(paramInfo.param); });

0 comments on commit 91e8726

Please sign in to comment.