From 5a8ccc5e5d131b579530fe8af5ace7b098c7bdf7 Mon Sep 17 00:00:00 2001 From: Michal Cieslar Date: Thu, 5 Dec 2024 21:30:01 +0100 Subject: [PATCH] chore: reformat code --- src/modules/image.cpp | 2 +- src/modules/person.cpp | 5 +-- tests/modules/animal_test.cpp | 33 +++++++++++--------- tests/modules/company_test.cpp | 39 ++++++++++++++--------- tests/modules/esport_test.cpp | 10 +++--- tests/modules/food_test.cpp | 38 +++++++++++++---------- tests/modules/image_test.cpp | 2 +- tests/modules/internet_test.cpp | 55 +++++++++++++++++++++------------ tests/modules/medicine_test.cpp | 23 +++++++------- tests/modules/movie_test.cpp | 5 ++- tests/modules/music_test.cpp | 15 +++++---- tests/modules/person_test.cpp | 1 - tests/modules/science_test.cpp | 3 +- tests/modules/sport_test.cpp | 22 +++++++------ tests/modules/string_test.cpp | 1 - 15 files changed, 143 insertions(+), 111 deletions(-) diff --git a/src/modules/image.cpp b/src/modules/image.cpp index e6359a99e..d50278636 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -66,7 +66,7 @@ std::string urlPicsumPhotos(unsigned width, unsigned height, const std::optional params += common::format("blur={}", blur.value()); } - + if (!params.empty()) { url = common::format("{}?{}", url, params); diff --git a/src/modules/person.cpp b/src/modules/person.cpp index 418b928c6..07cc505b1 100644 --- a/src/modules/person.cpp +++ b/src/modules/person.cpp @@ -237,8 +237,9 @@ std::string fullName(Locale locale, std::optional sex) weightedElements.reserve(peopleNames.nameFormats.size()); std::transform(peopleNames.nameFormats.begin(), peopleNames.nameFormats.end(), std::back_inserter(weightedElements), - [](const NameFormat& nameFormat) - { return helper::WeightedElement{nameFormat.weight, nameFormat.format}; }); + [](const NameFormat& nameFormat) { + return helper::WeightedElement{nameFormat.weight, nameFormat.format}; + }); const auto nameFormat = static_cast(helper::weightedRandomElement(weightedElements)); diff --git a/tests/modules/animal_test.cpp b/tests/modules/animal_test.cpp index f63179df2..2ca4d9ad2 100644 --- a/tests/modules/animal_test.cpp +++ b/tests/modules/animal_test.cpp @@ -14,7 +14,7 @@ namespace { const struct AnimalDefinition& getAnimalDefinition(Locale locale) { - switch(locale) + switch (locale) { default: return enUSAnimalDefinition; @@ -35,8 +35,8 @@ TEST_P(AnimalTest, shouldGenerateBear) const auto generatedBear = bear(locale); - ASSERT_TRUE( - std::ranges::any_of(animalDefinition.bears, [generatedBear](const std::string_view& bear) { return bear == generatedBear; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.bears, + [generatedBear](const std::string_view& bear) { return bear == generatedBear; })); } TEST_P(AnimalTest, shouldGenerateBird) @@ -47,8 +47,8 @@ TEST_P(AnimalTest, shouldGenerateBird) const auto generatedBird = bird(locale); - ASSERT_TRUE( - std::ranges::any_of(animalDefinition.birds, [generatedBird](const std::string_view& bird) { return bird == generatedBird; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.birds, + [generatedBird](const std::string_view& bird) { return bird == generatedBird; })); } TEST_P(AnimalTest, shouldGenerateCat) @@ -59,7 +59,8 @@ TEST_P(AnimalTest, shouldGenerateCat) const auto generatedCat = cat(locale); - ASSERT_TRUE(std::ranges::any_of(animalDefinition.cats, [generatedCat](const std::string_view& cat) { return cat == generatedCat; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.cats, + [generatedCat](const std::string_view& cat) { return cat == generatedCat; })); } TEST_P(AnimalTest, shouldGenerateCetacean) @@ -82,7 +83,8 @@ TEST_P(AnimalTest, shouldGenerateCow) const auto generatedCow = cow(locale); - ASSERT_TRUE(std::ranges::any_of(animalDefinition.cows, [generatedCow](const std::string_view& cow) { return cow == generatedCow; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.cows, + [generatedCow](const std::string_view& cow) { return cow == generatedCow; })); } TEST_P(AnimalTest, shouldGenerateCrocodile) @@ -105,7 +107,8 @@ TEST_P(AnimalTest, shouldGenerateDog) const auto generatedDog = dog(locale); - ASSERT_TRUE(std::ranges::any_of(animalDefinition.dogs, [generatedDog](const std::string_view& dog) { return dog == generatedDog; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.dogs, + [generatedDog](const std::string_view& dog) { return dog == generatedDog; })); } TEST_P(AnimalTest, shouldGenerateFish) @@ -116,8 +119,8 @@ TEST_P(AnimalTest, shouldGenerateFish) const auto generatedFish = fish(locale); - ASSERT_TRUE( - std::ranges::any_of(animalDefinition.fishes, [generatedFish](const std::string_view& fish) { return fish == generatedFish; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.fishes, + [generatedFish](const std::string_view& fish) { return fish == generatedFish; })); } TEST_P(AnimalTest, shouldGenerateHorse) @@ -152,8 +155,8 @@ TEST_P(AnimalTest, shouldGenerateLion) const auto generatedLion = lion(locale); - ASSERT_TRUE( - std::ranges::any_of(animalDefinition.lions, [generatedLion](const std::string_view& lion) { return lion == generatedLion; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.lions, + [generatedLion](const std::string_view& lion) { return lion == generatedLion; })); } TEST_P(AnimalTest, shouldGenerateRabbit) @@ -200,9 +203,9 @@ TEST_P(AnimalTest, shouldGenerateType) const auto generatedType = type(locale); - ASSERT_TRUE( - std::ranges::any_of(animalDefinition.types, [generatedType](const std::string_view& type) { return type == generatedType; })); + ASSERT_TRUE(std::ranges::any_of(animalDefinition.types, + [generatedType](const std::string_view& type) { return type == generatedType; })); } INSTANTIATE_TEST_SUITE_P(TestAnimalByLocale, AnimalTest, ValuesIn(locales), - [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); \ No newline at end of file + [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); diff --git a/tests/modules/company_test.cpp b/tests/modules/company_test.cpp index 2df90d405..a53acccfe 100644 --- a/tests/modules/company_test.cpp +++ b/tests/modules/company_test.cpp @@ -15,15 +15,16 @@ using namespace faker::company; namespace { - const struct CompanyDefinition& getCompanyDefinition(Locale locale) +const struct CompanyDefinition& getCompanyDefinition(Locale locale) +{ + switch (locale) { - switch(locale) - { - default: - return enUSCompanyDefinition; - } + default: + return enUSCompanyDefinition; } } +} + class CompanyTest : public TestWithParam { public: @@ -35,7 +36,8 @@ TEST_P(CompanyTest, shouldGenerateCompanyName) const auto& companyDefintion = getCompanyDefinition(locale); const auto generatedCompanyName = companyName(std::nullopt, locale); const auto generatedCompanyFirstLastNames = companyName(CompanyNameFormat::FirstNameLastNameSuffix, locale); - const auto generatedCompanyFirstLastNamesJobArea = companyName(CompanyNameFormat::FirstNameLastNameJobAreaSuffix, locale); + const auto generatedCompanyFirstLastNamesJobArea = + companyName(CompanyNameFormat::FirstNameLastNameJobAreaSuffix, locale); const auto companyNameElements = common::split(generatedCompanyName, " "); const auto companyNameElements1 = common::split(generatedCompanyFirstLastNames, " "); @@ -58,7 +60,8 @@ TEST_P(CompanyTest, shouldGenerateCompanyName) ASSERT_TRUE(std::ranges::any_of(person::englishLastNames, [generatedLastName](const std::string_view& lastName) { return lastName == generatedLastName; })); - ASSERT_TRUE(std::ranges::any_of(companyDefintion.companySuffixes, [lastElement](const std::string_view& companySuffix) + ASSERT_TRUE(std::ranges::any_of(companyDefintion.companySuffixes, + [lastElement](const std::string_view& companySuffix) { return companySuffix == lastElement; })); } @@ -73,7 +76,8 @@ TEST_P(CompanyTest, shouldGenerateCompanyName) { return firstName == generatedFirstName; })); ASSERT_TRUE(std::ranges::any_of(person::englishLastNames, [generatedLastName](const std::string_view& lastName) { return lastName == generatedLastName; })); - ASSERT_TRUE(std::ranges::any_of(companyDefintion.companySuffixes, [lastElement](const std::string_view& companySuffix) + ASSERT_TRUE(std::ranges::any_of(companyDefintion.companySuffixes, + [lastElement](const std::string_view& companySuffix) { return companySuffix == lastElement; })); } @@ -91,7 +95,8 @@ TEST_P(CompanyTest, shouldGenerateCompanyName) { return lastName == generatedLastName; })); ASSERT_TRUE(std::ranges::any_of(person::jobAreas, [generatedJobArea](const std::string_view& jobArea) { return jobArea == generatedJobArea; })); - ASSERT_TRUE(std::ranges::any_of(companyDefintion.companySuffixes, [lastElement](const std::string_view& companySuffix) + ASSERT_TRUE(std::ranges::any_of(companyDefintion.companySuffixes, + [lastElement](const std::string_view& companySuffix) { return companySuffix == lastElement; })); } } @@ -102,7 +107,8 @@ TEST_P(CompanyTest, shouldGenerateCompanyType) const auto& companyDefintion = getCompanyDefinition(locale); const auto generatedCompanyType = type(locale); - ASSERT_TRUE(std::ranges::any_of(companyDefintion.companyTypes, [generatedCompanyType](const std::string_view& companyType) + ASSERT_TRUE(std::ranges::any_of(companyDefintion.companyTypes, + [generatedCompanyType](const std::string_view& companyType) { return companyType == generatedCompanyType; })); } @@ -125,7 +131,8 @@ TEST_P(CompanyTest, shouldGenerateBuzzPhrase) ASSERT_TRUE(std::ranges::any_of(companyDefintion.buzzVerbs, [generatedBuzzPhrase](const std::string_view& buzzVerb) { return generatedBuzzPhrase.find(buzzVerb) != std::string::npos; })); - ASSERT_TRUE(std::ranges::any_of(companyDefintion.buzzAdjectives, [generatedBuzzPhrase](const std::string_view& buzzAdjective) + ASSERT_TRUE(std::ranges::any_of(companyDefintion.buzzAdjectives, + [generatedBuzzPhrase](const std::string_view& buzzAdjective) { return generatedBuzzPhrase.find(buzzAdjective) != std::string::npos; })); ASSERT_TRUE(std::ranges::any_of(companyDefintion.buzzNouns, [generatedBuzzPhrase](const std::string_view& buzzNoun) { return generatedBuzzPhrase.find(buzzNoun) != std::string::npos; })); @@ -147,7 +154,8 @@ TEST_P(CompanyTest, shouldGenerateBuzzAdjective) const auto& companyDefintion = getCompanyDefinition(locale); const auto generatedBuzzAdjective = buzzAdjective(locale); - ASSERT_TRUE(std::ranges::any_of(companyDefintion.buzzAdjectives, [generatedBuzzAdjective](const std::string_view& buzzAdjective) + ASSERT_TRUE(std::ranges::any_of(companyDefintion.buzzAdjectives, + [generatedBuzzAdjective](const std::string_view& buzzAdjective) { return buzzAdjective == generatedBuzzAdjective; })); } @@ -174,7 +182,8 @@ TEST_P(CompanyTest, shouldGenerateCatchPhrase) ASSERT_TRUE(std::ranges::any_of(companyDefintion.catchPhraseDescriptors, [generatedCatchPhrase](const std::string_view& catchPhraseDescriptor) { return generatedCatchPhrase.find(catchPhraseDescriptor) != std::string::npos; })); - ASSERT_TRUE(std::ranges::any_of(companyDefintion.catchPhraseNouns, [generatedCatchPhrase](const std::string_view& catchPhraseNoun) + ASSERT_TRUE(std::ranges::any_of(companyDefintion.catchPhraseNouns, + [generatedCatchPhrase](const std::string_view& catchPhraseNoun) { return generatedCatchPhrase.find(catchPhraseNoun) != std::string::npos; })); } @@ -213,4 +222,4 @@ TEST_P(CompanyTest, shouldGenerateCatchPhraseNoun) } INSTANTIATE_TEST_SUITE_P(TestCompanyByLocale, CompanyTest, ValuesIn(locales), - [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); \ No newline at end of file + [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); diff --git a/tests/modules/esport_test.cpp b/tests/modules/esport_test.cpp index f8c662ede..014d7fcf9 100644 --- a/tests/modules/esport_test.cpp +++ b/tests/modules/esport_test.cpp @@ -30,7 +30,7 @@ class EsportTest : public TestWithParam TEST_P(EsportTest, shouldGeneratePlayer) { const auto locale = GetParam(); - + const auto& esportDefinition = getEsportDefinition(locale); const auto generatedPlayer = player(locale); @@ -47,8 +47,8 @@ TEST_P(EsportTest, shouldGenerateTeam) const auto generatedTeam = team(locale); - ASSERT_TRUE( - std::ranges::any_of(esportDefinition.teams, [generatedTeam](const std::string_view& team) { return generatedTeam == team; })); + ASSERT_TRUE(std::ranges::any_of(esportDefinition.teams, + [generatedTeam](const std::string_view& team) { return generatedTeam == team; })); } TEST_P(EsportTest, shouldGenerateLeague) @@ -83,8 +83,8 @@ TEST_P(EsportTest, shouldGenerateGame) const auto generatedGame = game(locale); - ASSERT_TRUE( - std::ranges::any_of(esportDefinition.games, [generatedGame](const std::string_view& game) { return generatedGame == game; })); + ASSERT_TRUE(std::ranges::any_of(esportDefinition.games, + [generatedGame](const std::string_view& game) { return generatedGame == game; })); } INSTANTIATE_TEST_SUITE_P(TestEsportByLocale, EsportTest, ValuesIn(locales), diff --git a/tests/modules/food_test.cpp b/tests/modules/food_test.cpp index de6e4d006..5cf954379 100644 --- a/tests/modules/food_test.cpp +++ b/tests/modules/food_test.cpp @@ -10,17 +10,17 @@ using namespace ::testing; using namespace faker; using namespace faker::food; -namespace +namespace { - const struct FoodDefinition& getFoodDefinition(Locale locale) +const struct FoodDefinition& getFoodDefinition(Locale locale) +{ + switch (locale) { - switch(locale) - { - default: - return enUSFoodDefinition; - } + default: + return enUSFoodDefinition; } } +} class FoodTest : public TestWithParam { @@ -60,7 +60,8 @@ TEST_P(FoodTest, shouldGenerateFoodCategories) const auto generatedFoodCategory = foodCategory(locale); - ASSERT_TRUE(std::ranges::any_of(foodDefinition.foodCategories, [generatedFoodCategory](const std::string_view& foodCategory) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.foodCategories, + [generatedFoodCategory](const std::string_view& foodCategory) { return generatedFoodCategory == foodCategory; })); } @@ -82,8 +83,8 @@ TEST_P(FoodTest, shouldGenerateMeat) const auto& foodDefinition = getFoodDefinition(locale); const auto generatedMeat = meat(locale); - ASSERT_TRUE( - std::ranges::any_of(foodDefinition.meats, [generatedMeat](const std::string_view& meat) { return generatedMeat == meat; })); + ASSERT_TRUE(std::ranges::any_of(foodDefinition.meats, + [generatedMeat](const std::string_view& meat) { return generatedMeat == meat; })); } TEST_P(FoodTest, shouldGenerateMilkProduct) @@ -92,7 +93,8 @@ TEST_P(FoodTest, shouldGenerateMilkProduct) const auto& foodDefinition = getFoodDefinition(locale); const auto generatedMilkProduct = milkProduct(locale); - ASSERT_TRUE(std::ranges::any_of(foodDefinition.milkProducts, [generatedMilkProduct](const std::string_view& milkProduct) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.milkProducts, + [generatedMilkProduct](const std::string_view& milkProduct) { return generatedMilkProduct == milkProduct; })); } @@ -113,7 +115,8 @@ TEST_P(FoodTest, shouldGenerateNut) const auto& foodDefinition = getFoodDefinition(locale); const auto generatedNut = nut(locale); - ASSERT_TRUE(std::ranges::any_of(foodDefinition.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_P(FoodTest, shouldGenerateOil) @@ -122,7 +125,8 @@ TEST_P(FoodTest, shouldGenerateOil) const auto& foodDefinition = getFoodDefinition(locale); const auto generatedOil = oil(locale); - ASSERT_TRUE(std::ranges::any_of(foodDefinition.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_P(FoodTest, shouldGenerateSeafood) @@ -141,8 +145,8 @@ TEST_P(FoodTest, shouldGenerateSeed) const auto& foodDefinition = getFoodDefinition(locale); const auto generatedSeed = seed(locale); - ASSERT_TRUE( - std::ranges::any_of(foodDefinition.seeds, [generatedSeed](const std::string_view& seed) { return generatedSeed == seed; })); + ASSERT_TRUE(std::ranges::any_of(foodDefinition.seeds, + [generatedSeed](const std::string_view& seed) { return generatedSeed == seed; })); } TEST_P(FoodTest, shouldGenerateGrain) @@ -161,7 +165,8 @@ TEST_P(FoodTest, shouldGenerateSugarProduct) const auto& foodDefinition = getFoodDefinition(locale); const auto generatedSugarProduct = sugarProduct(locale); - ASSERT_TRUE(std::ranges::any_of(foodDefinition.sugarProducts, [generatedSugarProduct](const std::string_view& sugarProduct) + ASSERT_TRUE(std::ranges::any_of(foodDefinition.sugarProducts, + [generatedSugarProduct](const std::string_view& sugarProduct) { return generatedSugarProduct == sugarProduct; })); } @@ -177,4 +182,3 @@ TEST_P(FoodTest, shouldGenerateVegetable) INSTANTIATE_TEST_SUITE_P(TestFoodByLocale, FoodTest, ValuesIn(locales), [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); - diff --git a/tests/modules/image_test.cpp b/tests/modules/image_test.cpp index 244252615..704c72d70 100644 --- a/tests/modules/image_test.cpp +++ b/tests/modules/image_test.cpp @@ -22,7 +22,7 @@ TEST_F(ImageTest, shouldGenerateRandomImageUrl) for (int i = 0; i < 10; ++i) { const auto generatedImageUrl = imageUrl(); - + ASSERT_TRUE(generatedImageUrl.find("loremflickr") != std::string::npos || generatedImageUrl.find("picsum") != std::string::npos); } diff --git a/tests/modules/internet_test.cpp b/tests/modules/internet_test.cpp index dec127f7f..f11ce7765 100644 --- a/tests/modules/internet_test.cpp +++ b/tests/modules/internet_test.cpp @@ -1,13 +1,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include "gtest/gtest.h" @@ -61,8 +61,8 @@ const struct InternetDefinition& getInternetDefinition(Locale locale) { switch (locale) { - default: - return enUSInternetDefinition; + default: + return enUSInternetDefinition; } } } @@ -202,7 +202,8 @@ TEST_P(InternetTest, shouldGenerateEmail) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE( std::ranges::any_of(firstNames, [generatedUsername](const std::string_view& firstName) @@ -229,7 +230,8 @@ TEST_P(InternetTest, shouldGenerateEmailWithFirstName) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE(generatedUsername.find(common::toLower(firstName)) != std::string::npos); ASSERT_TRUE( @@ -258,7 +260,8 @@ TEST_P(InternetTest, shouldGenerateEmailWithLastName) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE( std::ranges::any_of(firstNames, [generatedUsername](const std::string_view& firstName) @@ -285,7 +288,8 @@ TEST_P(InternetTest, shouldGenerateEmailWithFullName) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE(generatedUsername.find(common::toLower(firstName)) != std::string::npos); ASSERT_TRUE(generatedUsername.find(common::toLower(lastName)) != std::string::npos); @@ -336,7 +340,8 @@ TEST_P(InternetTest, shouldGenerateExampleEmail) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE( std::ranges::any_of(firstNames, [generatedUsername](const std::string_view& firstName) @@ -364,7 +369,8 @@ TEST_P(InternetTest, shouldGenerateExampleEmailWithFirstName) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE(generatedUsername.find(common::toLower(firstName)) != std::string::npos); ASSERT_TRUE( @@ -393,7 +399,8 @@ TEST_P(InternetTest, shouldGenerateExampleEmailWithLastName) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE( std::ranges::any_of(firstNames, [generatedUsername](const std::string_view& firstName) @@ -420,7 +427,8 @@ TEST_P(InternetTest, shouldGenerateExampleEmailWithFullName) const auto& generatedUsername = emailParts[0]; const auto& generatedEmailHost = emailParts[1]; - ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, [generatedEmailHost](const std::string_view& emailHost) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.emailExampleHosts, + [generatedEmailHost](const std::string_view& emailHost) { return generatedEmailHost == emailHost; })); ASSERT_TRUE(generatedUsername.find(common::toLower(firstName)) != std::string::npos); ASSERT_TRUE(generatedUsername.find(common::toLower(lastName)) != std::string::npos); @@ -596,7 +604,8 @@ TEST_P(InternetTest, shouldGenerateHttpRequestHeader) const auto generatedHttpRequestHeader = httpRequestHeader(locale); - ASSERT_TRUE(std::ranges::any_of(internetDefinition.httpRequestHeaders, [generatedHttpRequestHeader](const std::string_view& httpHeader) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.httpRequestHeaders, + [generatedHttpRequestHeader](const std::string_view& httpHeader) { return generatedHttpRequestHeader == httpHeader; })); } @@ -618,7 +627,8 @@ TEST_P(InternetTest, shouldGenerateHttpMediaType) const auto generatedHttpMediaType = httpMediaType(locale); - ASSERT_TRUE(std::ranges::any_of(internetDefinition.httpMediaTypes, [generatedHttpMediaType](const std::string_view& httpMediaType) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.httpMediaTypes, + [generatedHttpMediaType](const std::string_view& httpMediaType) { return generatedHttpMediaType == httpMediaType; })); } @@ -759,12 +769,13 @@ TEST_F(InternetTest, MacDefaultSeparatorOverwrite) TEST_P(InternetTest, shouldGenerateDomainSuffix) { const auto locale = GetParam(); - + const auto& internetDefinition = getInternetDefinition(locale); const auto generatedDomainSuffix = domainSuffix(locale); - ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, [generatedDomainSuffix](const std::string_view& domainSuffix) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, + [generatedDomainSuffix](const std::string_view& domainSuffix) { return generatedDomainSuffix == domainSuffix; })); } @@ -788,7 +799,8 @@ TEST_P(InternetTest, shouldGenerateDomainName) const auto& generatedDomainSuffix = generatedDomainNameParts[1]; assertDomainWord(generatedDomainWord); - ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, [generatedDomainSuffix](const std::string_view& domainSuffix) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, + [generatedDomainSuffix](const std::string_view& domainSuffix) { return generatedDomainSuffix == domainSuffix; })); } @@ -812,7 +824,8 @@ TEST_P(InternetTest, shouldGenerateHttpsUrl) const auto& generatedDomainSuffix = generatedDomainNameParts[1]; assertDomainWord(generatedDomainWord); - ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, [generatedDomainSuffix](const std::string_view& domainSuffix) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, + [generatedDomainSuffix](const std::string_view& domainSuffix) { return generatedDomainSuffix == domainSuffix; })); ASSERT_EQ(generatedProtocol, "https"); } @@ -836,7 +849,8 @@ TEST_P(InternetTest, shouldGenerateHttpUrl) const auto& generatedDomainSuffix = generatedDomainNameParts[1]; assertDomainWord(generatedDomainWord); - ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, [generatedDomainSuffix](const std::string_view& domainSuffix) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.domainSuffixes, + [generatedDomainSuffix](const std::string_view& domainSuffix) { return generatedDomainSuffix == domainSuffix; })); ASSERT_EQ(generatedProtocol, "http"); } @@ -896,9 +910,10 @@ TEST_P(InternetTest, shouldGenerateJWTAlgorithm) const auto generatedJWTAlgorythm = getJWTAlgorithm(locale); - ASSERT_TRUE(std::ranges::any_of(internetDefinition.jwtAlgorithms, [generatedJWTAlgorythm](const std::string_view& JWTAlgorythm) + ASSERT_TRUE(std::ranges::any_of(internetDefinition.jwtAlgorithms, + [generatedJWTAlgorythm](const std::string_view& JWTAlgorythm) { return generatedJWTAlgorythm == JWTAlgorythm; })); } INSTANTIATE_TEST_SUITE_P(TestInternetByLocale, InternetTest, ValuesIn(locales), - [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); \ No newline at end of file + [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); diff --git a/tests/modules/medicine_test.cpp b/tests/modules/medicine_test.cpp index bd033d12d..26ab67969 100644 --- a/tests/modules/medicine_test.cpp +++ b/tests/modules/medicine_test.cpp @@ -5,8 +5,8 @@ #include "gtest/gtest.h" -#include "medicine_data.h" #include "locale.h" +#include "medicine_data.h" using namespace ::testing; using namespace faker; @@ -27,47 +27,48 @@ const struct MedicineDefinition& getMedicineMapDefinition(Locale locale) } } } + class MedicineTestLocale : public TestWithParam { public: }; - TEST_P(MedicineTestLocale, shouldGenerateMedicalConditionLocale) { auto extra = GetParam(); auto generatedMedicalCondition = condition(extra); auto medicalDefinition = getMedicineMapDefinition(extra); - ASSERT_TRUE(std::ranges::any_of(medicalDefinition.medicalConditions, [generatedMedicalCondition](const std::string_view& medicalCondition) + ASSERT_TRUE(std::ranges::any_of(medicalDefinition.medicalConditions, + [generatedMedicalCondition](const std::string_view& medicalCondition) { return medicalCondition == generatedMedicalCondition; })); } - TEST_P(MedicineTestLocale, shouldGenerateMedicalTestLocale) { - auto extra = GetParam(); + auto extra = GetParam(); const auto generatedMedicalTest = medicalTest(extra); auto medicalDefinition = getMedicineMapDefinition(extra); - ASSERT_TRUE(std::ranges::any_of(medicalDefinition.medicalTests, [generatedMedicalTest](const std::string_view& medicalTest) + ASSERT_TRUE(std::ranges::any_of(medicalDefinition.medicalTests, + [generatedMedicalTest](const std::string_view& medicalTest) { return medicalTest == generatedMedicalTest; })); } TEST_P(MedicineTestLocale, shouldGenerateSpecialtyLocale) { - auto extra = GetParam(); + auto extra = GetParam(); const auto generatedSpecialty = specialty(extra); - + auto medicalDefinition = getMedicineMapDefinition(extra); - ASSERT_TRUE(std::ranges::any_of(medicalDefinition.specialties, [generatedSpecialty](const std::string_view& specialty) + ASSERT_TRUE(std::ranges::any_of(medicalDefinition.specialties, + [generatedSpecialty](const std::string_view& specialty) { return specialty == generatedSpecialty; })); } - INSTANTIATE_TEST_SUITE_P(testMedicineByLocale, MedicineTestLocale, ValuesIn(locales), - [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); \ No newline at end of file + [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); diff --git a/tests/modules/movie_test.cpp b/tests/modules/movie_test.cpp index 73b28dfcf..7e4a165a3 100644 --- a/tests/modules/movie_test.cpp +++ b/tests/modules/movie_test.cpp @@ -16,8 +16,8 @@ const struct MovieDefinition& getMovie(Locale locale) { switch (locale) { - default: - return enUSmoviesDefinitions; + default: + return enUSmoviesDefinitions; } } } @@ -101,4 +101,3 @@ TEST_P(MovieTest, shouldGenerateActressLocale) INSTANTIATE_TEST_SUITE_P(TestMovieByLocale, MovieTest, ValuesIn(locales), [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); - diff --git a/tests/modules/music_test.cpp b/tests/modules/music_test.cpp index 4dd8f7803..5fec32a87 100644 --- a/tests/modules/music_test.cpp +++ b/tests/modules/music_test.cpp @@ -12,16 +12,15 @@ using namespace faker::music; namespace { - const struct MusicDefinition& getMusicDefinition(Locale locale) +const struct MusicDefinition& getMusicDefinition(Locale locale) +{ + switch (locale) { - switch(locale) - { - default: - return enUSMusicDefinition; - } + default: + return enUSMusicDefinition; } } - +} class MusicTest : public TestWithParam { @@ -59,4 +58,4 @@ TEST_P(MusicTest, shouldGenerateSongName) } INSTANTIATE_TEST_SUITE_P(TestMusicByLocale, MusicTest, ValuesIn(locales), - [](const TestParamInfo& paramInfo){return toString(paramInfo.param);}); + [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); diff --git a/tests/modules/person_test.cpp b/tests/modules/person_test.cpp index 12b60b1b2..094cbe753 100644 --- a/tests/modules/person_test.cpp +++ b/tests/modules/person_test.cpp @@ -697,7 +697,6 @@ bool checkTokenFormat(const std::string& bio) return true; } - if (std::regex_match(bio, matches, seventhRegex)) { // In this case the bio is in the format {noun} {bio_supporter}, {bio_part} so check that the value is diff --git a/tests/modules/science_test.cpp b/tests/modules/science_test.cpp index 90d86684e..ef94612f1 100644 --- a/tests/modules/science_test.cpp +++ b/tests/modules/science_test.cpp @@ -45,7 +45,8 @@ TEST_P(ScienceTest, shouldGenerateChemElement) const auto generatedChemElement = chemicalElement(locale); - ASSERT_TRUE(std::ranges::any_of(scienceDefinition.chemicalElements, [generatedChemElement](const ChemicalElement& chemElement) + ASSERT_TRUE(std::ranges::any_of(scienceDefinition.chemicalElements, + [generatedChemElement](const ChemicalElement& chemElement) { return chemicalElementsAreEqual(generatedChemElement, chemElement); })); } diff --git a/tests/modules/sport_test.cpp b/tests/modules/sport_test.cpp index 1939c3818..396f63394 100644 --- a/tests/modules/sport_test.cpp +++ b/tests/modules/sport_test.cpp @@ -4,14 +4,13 @@ #include "gtest/gtest.h" #include "faker-cxx/sport.h" -#include "sport_data.h" #include "locale.h" +#include "sport_data.h" using namespace ::testing; using namespace faker; using namespace faker::sport; - namespace { @@ -38,11 +37,11 @@ TEST_P(SportTestLocale, shouldGenerateSportLocale) auto extra = GetParam(); auto sportDefinition = getSportMapDefinition(extra); const auto generatedSport = faker::sport::sportName(extra); - ASSERT_TRUE(std::ranges::any_of(sportDefinition.sportNames, [generatedSport](const std::string_view& sport) { return sport == generatedSport; })); } + TEST_P(SportTestLocale, shouldGenerateFemaleAthleteLocale) { auto extra = GetParam(); @@ -50,27 +49,30 @@ TEST_P(SportTestLocale, shouldGenerateFemaleAthleteLocale) const auto generatedFemaleAthlete = femaleAthlete(extra); - ASSERT_TRUE(std::ranges::any_of(sportDefinition.femaleAthletes, [generatedFemaleAthlete](const std::string_view& femaleAthlete) + ASSERT_TRUE(std::ranges::any_of(sportDefinition.femaleAthletes, + [generatedFemaleAthlete](const std::string_view& femaleAthlete) { return femaleAthlete == generatedFemaleAthlete; })); } + TEST_P(SportTestLocale, shouldGenerateMaleAthleteLocale) -{ +{ auto extra = GetParam(); auto sportDefinition = getSportMapDefinition(extra); const auto generatedMaleAthlete = maleAthlete(extra); - ASSERT_TRUE(std::ranges::any_of(sportDefinition.maleAthletes, [generatedMaleAthlete](const std::string_view& maleAthlete) + ASSERT_TRUE(std::ranges::any_of(sportDefinition.maleAthletes, + [generatedMaleAthlete](const std::string_view& maleAthlete) { return maleAthlete == generatedMaleAthlete; })); } - TEST_P(SportTestLocale, shouldGenerateSoccerTeamLocale) { auto extra = GetParam(); auto sportDefinition = getSportMapDefinition(extra); const auto generatedSoccerTeam = soccerTeam(extra); - ASSERT_TRUE(std::ranges::any_of(sportDefinition.soccerTeams, [generatedSoccerTeam](const std::string_view& soccerTeam) + ASSERT_TRUE(std::ranges::any_of(sportDefinition.soccerTeams, + [generatedSoccerTeam](const std::string_view& soccerTeam) { return soccerTeam == generatedSoccerTeam; })); } @@ -80,10 +82,10 @@ TEST_P(SportTestLocale, shouldGenerateSportEventLocale) auto sportDefinition = getSportMapDefinition(extra); const auto generatedSportEvent = sportEvent(extra); - ASSERT_TRUE(std::ranges::any_of(sportDefinition.sportEvents, [generatedSportEvent](const std::string_view& sportEvent) + ASSERT_TRUE(std::ranges::any_of(sportDefinition.sportEvents, + [generatedSportEvent](const std::string_view& sportEvent) { return sportEvent == generatedSportEvent; })); } - INSTANTIATE_TEST_SUITE_P(testSportByLocale, SportTestLocale, ValuesIn(locales), [](const TestParamInfo& paramInfo) { return toString(paramInfo.param); }); diff --git a/tests/modules/string_test.cpp b/tests/modules/string_test.cpp index 27e9aee10..9c2057ee5 100644 --- a/tests/modules/string_test.cpp +++ b/tests/modules/string_test.cpp @@ -59,7 +59,6 @@ TEST_F(StringTest, shouldGenerateUuid4) ASSERT_EQ(generatedUuid[23], '-'); } - TEST_F(StringTest, shouldGenerateUuid4Default) { const auto generatedUuid = uuid();