Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup header files #1011

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: reformat code
  • Loading branch information
cieslarmichal committed Dec 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5a8ccc5e5d131b579530fe8af5ace7b098c7bdf7
2 changes: 1 addition & 1 deletion src/modules/image.cpp
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 3 additions & 2 deletions src/modules/person.cpp
Original file line number Diff line number Diff line change
@@ -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));

33 changes: 18 additions & 15 deletions tests/modules/animal_test.cpp
Original file line number Diff line number Diff line change
@@ -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<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
@@ -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:
@@ -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<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
@@ -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);
@@ -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),
38 changes: 21 additions & 17 deletions tests/modules/food_test.cpp
Original file line number Diff line number Diff line change
@@ -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>
{
@@ -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<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
@@ -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);
}
Loading