Skip to content

Commit

Permalink
chore: reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal committed Dec 5, 2024
1 parent 0469b04 commit 5a8ccc5
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 111 deletions.
2 changes: 1 addition & 1 deletion src/modules/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/modules/person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ std::string fullName(Locale locale, std::optional<Sex> sex)
weightedElements.reserve(peopleNames.nameFormats.size());

std::transform(peopleNames.nameFormats.begin(), peopleNames.nameFormats.end(), std::back_inserter(weightedElements),
[](const NameFormat& nameFormat)
{ return helper::WeightedElement<std::string_view>{nameFormat.weight, nameFormat.format}; });
[](const NameFormat& nameFormat) {
return helper::WeightedElement<std::string_view>{nameFormat.weight, nameFormat.format};
});

const auto nameFormat = static_cast<std::string>(helper::weightedRandomElement<std::string_view>(weightedElements));

Expand Down
33 changes: 18 additions & 15 deletions tests/modules/animal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace
{
const struct AnimalDefinition& getAnimalDefinition(Locale locale)
{
switch(locale)
switch (locale)
{
default:
return enUSAnimalDefinition;
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<Locale>& paramInfo) { return toString(paramInfo.param); });
[](const TestParamInfo<Locale>& paramInfo) { return toString(paramInfo.param); });
39 changes: 24 additions & 15 deletions tests/modules/company_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Locale>
{
public:
Expand All @@ -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, " ");
Expand All @@ -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; }));
}

Expand All @@ -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; }));
}

Expand All @@ -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; }));
}
}
Expand All @@ -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; }));
}

Expand All @@ -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; }));
Expand All @@ -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; }));
}

Expand All @@ -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; }));
}

Expand Down Expand Up @@ -213,4 +222,4 @@ TEST_P(CompanyTest, shouldGenerateCatchPhraseNoun)
}

INSTANTIATE_TEST_SUITE_P(TestCompanyByLocale, CompanyTest, ValuesIn(locales),
[](const TestParamInfo<Locale>& paramInfo) { return toString(paramInfo.param); });
[](const TestParamInfo<Locale>& paramInfo) { return toString(paramInfo.param); });
10 changes: 5 additions & 5 deletions tests/modules/esport_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EsportTest : public TestWithParam<Locale>
TEST_P(EsportTest, shouldGeneratePlayer)
{
const auto locale = GetParam();

const auto& esportDefinition = getEsportDefinition(locale);

const auto generatedPlayer = player(locale);
Expand All @@ -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)
Expand Down Expand Up @@ -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),
Expand Down
38 changes: 21 additions & 17 deletions tests/modules/food_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Locale>
{
Expand Down Expand Up @@ -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; }));
}

Expand All @@ -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)
Expand All @@ -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; }));
}

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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; }));
}

Expand All @@ -177,4 +182,3 @@ TEST_P(FoodTest, shouldGenerateVegetable)

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

2 changes: 1 addition & 1 deletion tests/modules/image_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 5a8ccc5

Please sign in to comment.