From 6d68a938876f305deb4004ce0139861d8cc45bff Mon Sep 17 00:00:00 2001 From: BLTA Date: Wed, 4 Dec 2024 12:52:20 -0800 Subject: [PATCH] - Added localization definition to food_data.h. - Added the struct to the food.cpp. - Added the declaration to take en-US locale by default and updated doxygen comments for food.h. - Updated test cases to take locale as arguments. - used clang-format to format the files according to style guidelines --- include/faker-cxx/food.h | 57 +++++++++++---- src/modules/food.cpp | 82 +++++++++++++-------- src/modules/food_data.h | 64 +++++++++++++---- tests/modules/food_test.cpp | 138 +++++++++++++++++++++++++----------- 4 files changed, 242 insertions(+), 99 deletions(-) diff --git a/include/faker-cxx/food.h b/include/faker-cxx/food.h index 81e09b56c..1c0397500 100644 --- a/include/faker-cxx/food.h +++ b/include/faker-cxx/food.h @@ -3,160 +3,189 @@ #include #include "faker-cxx/export.h" +#include "faker-cxx/types/locale.h" namespace faker::food { /** * @brief Returns a random alcoholic beverage name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Alcoholic beverage. * * @code * faker::food::alcoholicBeverage() // "champain" * @endcode */ -FAKER_CXX_EXPORT std::string_view alcoholicBeverage(); +FAKER_CXX_EXPORT std::string_view alcoholicBeverage(Locale locale = Locale::en_US); /** * @brief Returns a random grain measurement. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Grain. * * @code * faker::food::grain() // "1 Lt" * @endcode */ -FAKER_CXX_EXPORT std::string_view grain(); +FAKER_CXX_EXPORT std::string_view grain(Locale locale = Locale::en_US); /** * @brief Returns a random milk product's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Milk product. * * @code * faker::food::milkProduct() // "mozzarella" * @endcode */ -FAKER_CXX_EXPORT std::string_view milkProduct(); +FAKER_CXX_EXPORT std::string_view milkProduct(Locale locale = Locale::en_US); /** * @brief Returns a random fruit's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Fruit. * * @code * faker::food::fruit() // "apple" * @endcode */ -FAKER_CXX_EXPORT std::string_view fruit(); +FAKER_CXX_EXPORT std::string_view fruit(Locale locale = Locale::en_US); /** * @brief Returns a random meat's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Meat. * * @code * faker::food::meat() // "antrikot" * @endcode */ -FAKER_CXX_EXPORT std::string_view meat(); +FAKER_CXX_EXPORT std::string_view meat(Locale locale = Locale::en_US); /** * @brief Returns a random seafood's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Seafood. * * @code * faker::food::seafood() // "lobster" * @endcode */ -FAKER_CXX_EXPORT std::string_view seafood(); +FAKER_CXX_EXPORT std::string_view seafood(Locale locale = Locale::en_US); /** * @brief Returns a random vegetable's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Vegetable. * * @code * faker::food::vegetable() // "watermelon" * @endcode */ -FAKER_CXX_EXPORT std::string_view vegetable(); +FAKER_CXX_EXPORT std::string_view vegetable(Locale locale = Locale::en_US); /** * @brief Returns a random oil's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Oil. * * @code * faker::food::oil() // "olive oil" * @endcode */ -FAKER_CXX_EXPORT std::string_view oil(); +FAKER_CXX_EXPORT std::string_view oil(Locale locale = Locale::en_US); /** * @brief Returns a random nut's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Nuts. * * @code * faker::food::nut() // "walnut" * @endcode */ -FAKER_CXX_EXPORT std::string_view nut(); +FAKER_CXX_EXPORT std::string_view nut(Locale locale = Locale::en_US); /** * @brief Returns a random seed's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Seed. * * @code * faker::food::seed() // "mozzarella" * @endcode */ -FAKER_CXX_EXPORT std::string_view seed(); +FAKER_CXX_EXPORT std::string_view seed(Locale locale = Locale::en_US); /** * @brief Returns a random sugar product's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Sugar product. * * @code * faker::food::sugarProduct() // "honey harmony" * @endcode */ -FAKER_CXX_EXPORT std::string_view sugarProduct(); +FAKER_CXX_EXPORT std::string_view sugarProduct(Locale locale = Locale::en_US); /** * @brief Returns a random non-alcoholic beverage's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Non-alcoholic Beverage. * * @code * faker::food::nonalcoholicBeverage() // "water" * @endcode */ -FAKER_CXX_EXPORT std::string_view nonalcoholicBeverage(); +FAKER_CXX_EXPORT std::string_view nonalcoholicBeverage(Locale locale = Locale::en_US); /** * @brief Returns a random dish's name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Dish. * * @code * faker::food::dishName() // "beef wellington" * @endcode */ -FAKER_CXX_EXPORT std::string_view dishName(); +FAKER_CXX_EXPORT std::string_view dishName(Locale locale = Locale::en_US); /** * @brief Returns a random food categories' name. * + * @param locale The locale. Defaults to `Locale::en_US`. + * * @returns Food Category. * * @code * faker::food::foodCategory() // "Dairy" * @endcode */ -FAKER_CXX_EXPORT std::string_view foodCategory(); +FAKER_CXX_EXPORT std::string_view foodCategory(Locale locale = Locale::en_US); } diff --git a/src/modules/food.cpp b/src/modules/food.cpp index 87c3cdd3d..36dc058ba 100644 --- a/src/modules/food.cpp +++ b/src/modules/food.cpp @@ -7,73 +7,99 @@ namespace faker::food { -std::string_view alcoholicBeverage() +namespace { - return helper::randomElement(alcoholicBeverages); +const struct FoodDefinition& getFoodDefinition(Locale locale) +{ + switch (locale) + { + default: + return enUSFoodDefinition; + } +} +} + +std::string_view alcoholicBeverage(Locale locale) +{ + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.alcoholicBeverages); } -std::string_view dishName() +std::string_view dishName(Locale locale) { - return helper::randomElement(dishNames); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.dishNames); } -std::string_view foodCategory() +std::string_view foodCategory(Locale locale) { - return helper::randomElement(foodCategories); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.foodCategories); } -std::string_view fruit() +std::string_view fruit(Locale locale) { - return helper::randomElement(fruits); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.fruits); } -std::string_view grain() +std::string_view grain(Locale locale) { - return helper::randomElement(grains); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.grains); } -std::string_view meat() +std::string_view meat(Locale locale) { - return helper::randomElement(meats); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.meats); } -std::string_view milkProduct() +std::string_view milkProduct(Locale locale) { - return helper::randomElement(milkProducts); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.milkProducts); } -std::string_view nonalcoholicBeverage() +std::string_view nonalcoholicBeverage(Locale locale) { - return helper::randomElement(nonalcoholicBeverages); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.nonalcoholicBeverages); } -std::string_view nut() +std::string_view nut(Locale locale) { - return helper::randomElement(nuts); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.nuts); } -std::string_view oil() +std::string_view oil(Locale locale) { - return helper::randomElement(oils); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.oils); } -std::string_view seafood() +std::string_view seafood(Locale locale) { - return helper::randomElement(seafoods); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.seafoods); } -std::string_view seed() +std::string_view seed(Locale locale) { - return helper::randomElement(seeds); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.seeds); } -std::string_view sugarProduct() +std::string_view sugarProduct(Locale locale) { - return helper::randomElement(sugarProducts); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.sugarProducts); } -std::string_view vegetable() +std::string_view vegetable(Locale locale) { - return helper::randomElement(vegetables); + const auto& foodDefinition = getFoodDefinition(locale); + return helper::randomElement(foodDefinition.vegetables); } } diff --git a/src/modules/food_data.h b/src/modules/food_data.h index 5ba65df65..20d5d99bd 100644 --- a/src/modules/food_data.h +++ b/src/modules/food_data.h @@ -1,11 +1,30 @@ #pragma once #include +#include #include namespace faker::food { -const auto alcoholicBeverages = std::to_array({ +struct FoodDefinition +{ + std::span alcoholicBeverages; + std::span dishNames; + std::span foodCategories; + std::span fruits; + std::span grains; + std::span meats; + std::span milkProducts; + std::span nonalcoholicBeverages; + std::span nuts; + std::span oils; + std::span seafoods; + std::span seeds; + std::span sugarProducts; + std::span vegetables; +}; + +const auto enUSalcoholicBeverages = std::to_array({ "Absinthe", "Baileys Irish Cream", "Beer", @@ -55,7 +74,7 @@ const auto alcoholicBeverages = std::to_array({ "Wine", }); -const auto dishNames = std::to_array({ +const auto enUSdishNames = std::to_array({ "Arepas", "Arroz con Pollo", "Baba Ganoush", @@ -143,7 +162,7 @@ const auto dishNames = std::to_array({ "Vegetarian Paella", }); -const auto foodCategories = std::to_array({ +const auto enUSfoodCategories = std::to_array({ "Beverages", "Condiments", "Dairy", @@ -157,7 +176,7 @@ const auto foodCategories = std::to_array({ "Vegetables", }); -const auto fruits = std::to_array({ +const auto enUSfruits = std::to_array({ "Apple", "Apricot", "Avocado", "Banana", "Blackberry", "Blueberry", "Cantaloupe", "Cherry", "Coconut", "Cranberry", "Date", "Dragon Fruit", "Elderberry", "Fig", "Gooseberry", "Grapefruit", "Grapes", "Guava", "Honeydew", "Jackfruit", "Kiwi", @@ -166,19 +185,19 @@ const auto fruits = std::to_array({ "Plum", "Pomegranate", "Rambutan", "Raspberry", "Starfruit", "Strawberry", }); -const auto grains = std::to_array({ +const auto enUSgrains = std::to_array({ "Amaranth", "Barley", "Buckwheat", "Bulgur", "Chia Seeds", "Corn", "Einkorn", "Emmer", "Farro", "Flaxseeds", "Freekeh", "Job's Tears", "Kamut", "Lentils", "Maize", "Millet", "Oats", "Quinoa", "Rice", "Rye", "Semolina", "Sorghum", "Soy", "Spelt", "Sunflower Seeds", "Teff", "Triticale", "Wheat", }); -const auto meats = std::to_array({ +const auto enUSmeats = std::to_array({ "Beef", "Bison", "Chicken", "Crab", "Duck", "Fish", "Goose", "Haddock", "Ham", "Lamb", "Lobster", "Pork", "Quail", "Salmon", "Sausage", "Shrimp", "Trout", "Tuna", "Turkey", "Veal", "Venison", }); -const auto milkProducts = std::to_array({ +const auto enUSmilkProducts = std::to_array({ "Blue Cheese", "Brie", "Butter", "Camembert", "Cheddar", "Cheese", "Colby", "Condensed Milk", "Cottage Cheese", "Cream", "Cream Cheese", "Evaporated Milk", "Feta", "Goat Cheese", "Gouda", "Gruyère", "Havarti", "Havarti", "Ice Cream", "Mascarpone", "Milk", @@ -186,7 +205,7 @@ const auto milkProducts = std::to_array({ "Sour Cream", "Swiss Cheese", "Whipped Cream", "Yogurt", }); -const auto nonalcoholicBeverages = std::to_array({ +const auto enUSnonalcoholicBeverages = std::to_array({ "Almond Milk", "Apple Juice", "Chai Tea", @@ -220,7 +239,7 @@ const auto nonalcoholicBeverages = std::to_array({ "Water", }); -const auto nuts = std::to_array({ +const auto enUSnuts = std::to_array({ "Almond", "Brazil Nut", "Cashew", @@ -234,19 +253,19 @@ const auto nuts = std::to_array({ "Walnut", }); -const auto oils = std::to_array({ +const auto enUSoils = std::to_array({ "Almond Oil", "Avocado Oil", "Canola Oil", "Chia Seed Oil", "Coconut Oil", "Corn Oil", "Flaxseed Oil", "Grapeseed Oil", "Hazelnut Oil", "Hemp Oil", "Mustard Oil", "Olive Oil", "Palm Oil", "Peanut Oil", "Pumpkin Seed Oil", "Safflower Oil", "Sesame Oil", "Sunflower Oil", "Vegetable Oil", "Walnut Oil", }); -const auto seafoods = std::to_array({ +const auto enUSseafoods = std::to_array({ "Anchovies", "Catfish", "Caviar", "Clams", "Cod", "Crab", "Haddock", "Halibut", "Herring", "Lobster", "Mahi-Mahi", "Mussels", "Octopus", "Oysters", "Pollock", "Salmon", "Sardines", "Scallops", "Sea Bass", "Shrimp", "Snapper", "Sole", "Squid", "Surimi", "Swordfish", "Trout", "Tuna", "Whitefish", }); -const auto seeds = std::to_array({ +const auto enUSseeds = std::to_array({ "Ajwain Seeds", "Alfalfa Seeds", "Anise Seeds", "Caraway Seeds", "Cardamom Seeds", "Celery Seeds", "Chia Seeds", "Coriander Seeds", "Cotton Seeds", "Cumin Seeds", "Dill Seeds", "Fennel Seeds", "Fenugreek Seeds", "Flaxseeds", "Hemp Hearts", @@ -255,7 +274,7 @@ const auto seeds = std::to_array({ "Sesame Seeds", "Sunflower Kernels", "Sunflower Seeds", "Watermelon Seeds", }); -const auto sugarProducts = std::to_array({ +const auto enUSsugarProducts = std::to_array({ "Agave Nectar", "Barley Malt Syrup", "Blackstrap Molasses", @@ -282,7 +301,7 @@ const auto sugarProducts = std::to_array({ "Turbinado Sugar", }); -const auto vegetables = std::to_array({ +const auto enUSvegetables = std::to_array({ "Artichoke", "Asparagus", "Beets", "Bell Pepper", "Broccoli", "Brussels Sprouts", "Cabbage", "Carrot", "Cauliflower", "Celery", "Cucumber", "Eggplant", "Garlic", "Ginger", "Green Beans", "Kale", "Leek", "Lettuce", @@ -290,4 +309,21 @@ const auto vegetables = std::to_array({ "Scallion", "Spinach", "Sweet Potato", "Tomato", "Turnip", "Zucchini", }); +const FoodDefinition enUSFoodDefinition = { + .alcoholicBeverages = enUSalcoholicBeverages, + .dishNames = enUSdishNames, + .foodCategories = enUSfoodCategories, + .fruits = enUSfruits, + .grains = enUSgrains, + .meats = enUSmeats, + .milkProducts = enUSmilkProducts, + .nonalcoholicBeverages = enUSnonalcoholicBeverages, + .nuts = enUSnuts, + .oils = enUSoils, + .seafoods = enUSseafoods, + .seeds = enUSseeds, + .sugarProducts = enUSsugarProducts, + .vegetables = enUSvegetables, +}; + } diff --git a/tests/modules/food_test.cpp b/tests/modules/food_test.cpp index d18307f20..de6e4d006 100644 --- a/tests/modules/food_test.cpp +++ b/tests/modules/food_test.cpp @@ -10,119 +10,171 @@ using namespace ::testing; using namespace faker; using namespace faker::food; -class FoodTest : public Test +namespace +{ + const struct FoodDefinition& getFoodDefinition(Locale locale) + { + switch(locale) + { + default: + return enUSFoodDefinition; + } + } +} + +class FoodTest : public TestWithParam { public: }; -TEST_F(FoodTest, shouldGenerateAlcoholicBeverage) +TEST_P(FoodTest, shouldGenerateAlcoholicBeverage) { - const auto generatedAlcoholicBeverage = alcoholicBeverage(); + const auto locale = GetParam(); + + const auto& foodDefinition = getFoodDefinition(locale); - ASSERT_TRUE(std::ranges::any_of(alcoholicBeverages, + const auto generatedAlcoholicBeverage = alcoholicBeverage(locale); + + ASSERT_TRUE(std::ranges::any_of(foodDefinition.alcoholicBeverages, [generatedAlcoholicBeverage](const std::string_view& alcoholicBeverage) { return generatedAlcoholicBeverage == alcoholicBeverage; })); } -TEST_F(FoodTest, shouldGenerateDishName) +TEST_P(FoodTest, shouldGenerateDishName) { - const auto generatedDishName = dishName(); + const auto locale = GetParam(); + + const auto& foodDefinition = getFoodDefinition(locale); + + const auto generatedDishName = dishName(locale); - ASSERT_TRUE(std::ranges::any_of(dishNames, [generatedDishName](const std::string_view& dishName) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.dishNames, [generatedDishName](const std::string_view& dishName) { return generatedDishName == dishName; })); } -TEST_F(FoodTest, shouldGenerateFoodCategories) +TEST_P(FoodTest, shouldGenerateFoodCategories) { - const auto generatedFoodCategory = foodCategory(); + const auto locale = GetParam(); - ASSERT_TRUE(std::ranges::any_of(foodCategories, [generatedFoodCategory](const std::string_view& foodCategory) + const auto& foodDefinition = getFoodDefinition(locale); + + const auto generatedFoodCategory = foodCategory(locale); + + ASSERT_TRUE(std::ranges::any_of(foodDefinition.foodCategories, [generatedFoodCategory](const std::string_view& foodCategory) { return generatedFoodCategory == foodCategory; })); } -TEST_F(FoodTest, shouldGenerateFruit) +TEST_P(FoodTest, shouldGenerateFruit) { - const auto generatedFruit = fruit(); + const auto locale = GetParam(); + + const auto& foodDefinition = getFoodDefinition(locale); - ASSERT_TRUE(std::ranges::any_of(fruits, [generatedFruit](const std::string_view& fruit) + const auto generatedFruit = fruit(locale); + + ASSERT_TRUE(std::ranges::any_of(foodDefinition.fruits, [generatedFruit](const std::string_view& fruit) { return generatedFruit == fruit; })); } -TEST_F(FoodTest, shouldGenerateMeat) +TEST_P(FoodTest, shouldGenerateMeat) { - const auto generatedMeat = meat(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedMeat = meat(locale); ASSERT_TRUE( - std::ranges::any_of(meats, [generatedMeat](const std::string_view& meat) { return generatedMeat == meat; })); + std::ranges::any_of(foodDefinition.meats, [generatedMeat](const std::string_view& meat) { return generatedMeat == meat; })); } -TEST_F(FoodTest, shouldGenerateMilkProduct) +TEST_P(FoodTest, shouldGenerateMilkProduct) { - const auto generatedMilkProduct = milkProduct(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedMilkProduct = milkProduct(locale); - ASSERT_TRUE(std::ranges::any_of(milkProducts, [generatedMilkProduct](const std::string_view& milkProduct) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.milkProducts, [generatedMilkProduct](const std::string_view& milkProduct) { return generatedMilkProduct == milkProduct; })); } -TEST_F(FoodTest, shouldGenerateNonalcoholicBeverages) +TEST_P(FoodTest, shouldGenerateNonalcoholicBeverages) { - const auto generatedNonalcoholicBeverages = nonalcoholicBeverage(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedNonalcoholicBeverages = nonalcoholicBeverage(locale); - ASSERT_TRUE(std::ranges::any_of(nonalcoholicBeverages, + ASSERT_TRUE(std::ranges::any_of(foodDefinition.nonalcoholicBeverages, [generatedNonalcoholicBeverages](const std::string_view& nonalcoholicBeverage) { return generatedNonalcoholicBeverages == nonalcoholicBeverage; })); } -TEST_F(FoodTest, shouldGenerateNut) +TEST_P(FoodTest, shouldGenerateNut) { - const auto generatedNut = nut(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedNut = nut(locale); - ASSERT_TRUE(std::ranges::any_of(nuts, [generatedNut](const std::string_view& nut) { return generatedNut == nut; })); + ASSERT_TRUE(std::ranges::any_of(foodDefinition.nuts, [generatedNut](const std::string_view& nut) { return generatedNut == nut; })); } -TEST_F(FoodTest, shouldGenerateOil) +TEST_P(FoodTest, shouldGenerateOil) { - const auto generatedOil = oil(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedOil = oil(locale); - ASSERT_TRUE(std::ranges::any_of(oils, [generatedOil](const std::string_view& oil) { return generatedOil == oil; })); + ASSERT_TRUE(std::ranges::any_of(foodDefinition.oils, [generatedOil](const std::string_view& oil) { return generatedOil == oil; })); } -TEST_F(FoodTest, shouldGenerateSeafood) +TEST_P(FoodTest, shouldGenerateSeafood) { - const auto generatedSeafood = seafood(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedSeafood = seafood(locale); - ASSERT_TRUE(std::ranges::any_of(seafoods, [generatedSeafood](const std::string_view& seafood) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.seafoods, [generatedSeafood](const std::string_view& seafood) { return generatedSeafood == seafood; })); } -TEST_F(FoodTest, shouldGenerateSeed) +TEST_P(FoodTest, shouldGenerateSeed) { - const auto generatedSeed = seed(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedSeed = seed(locale); ASSERT_TRUE( - std::ranges::any_of(seeds, [generatedSeed](const std::string_view& seed) { return generatedSeed == seed; })); + std::ranges::any_of(foodDefinition.seeds, [generatedSeed](const std::string_view& seed) { return generatedSeed == seed; })); } -TEST_F(FoodTest, shouldGenerateGrain) +TEST_P(FoodTest, shouldGenerateGrain) { - const auto generatedGrain = grain(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedGrain = grain(locale); - ASSERT_TRUE(std::ranges::any_of(grains, [generatedGrain](const std::string_view& grain) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.grains, [generatedGrain](const std::string_view& grain) { return generatedGrain == grain; })); } -TEST_F(FoodTest, shouldGenerateSugarProduct) +TEST_P(FoodTest, shouldGenerateSugarProduct) { - const auto generatedSugarProduct = sugarProduct(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedSugarProduct = sugarProduct(locale); - ASSERT_TRUE(std::ranges::any_of(sugarProducts, [generatedSugarProduct](const std::string_view& sugarProduct) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.sugarProducts, [generatedSugarProduct](const std::string_view& sugarProduct) { return generatedSugarProduct == sugarProduct; })); } -TEST_F(FoodTest, shouldGenerateVegetable) +TEST_P(FoodTest, shouldGenerateVegetable) { - const auto generatedVegetable = vegetable(); + const auto locale = GetParam(); + const auto& foodDefinition = getFoodDefinition(locale); + const auto generatedVegetable = vegetable(locale); - ASSERT_TRUE(std::ranges::any_of(vegetables, [generatedVegetable](const std::string_view& vegetable) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.vegetables, [generatedVegetable](const std::string_view& vegetable) { return generatedVegetable == vegetable; })); } + +INSTANTIATE_TEST_SUITE_P(TestFoodByLocale, FoodTest, ValuesIn(locales), + [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); +