From ab8d1b074f09e5a094d06ce04c804c4994969ca9 Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 15:08:20 -0300 Subject: [PATCH 1/9] feat : adding locale to sport module --- include/faker-cxx/sport.h | 19 ++-- src/modules/sport.cpp | 53 ++++++++-- src/modules/sport_data.h | 176 +++++++++++++++++++++++++++++++- tests/modules/internet_test.cpp | 1 + tests/modules/sport_test.cpp | 79 +++++++++----- 5 files changed, 283 insertions(+), 45 deletions(-) diff --git a/include/faker-cxx/sport.h b/include/faker-cxx/sport.h index 8383e34e2..a4f787c91 100644 --- a/include/faker-cxx/sport.h +++ b/include/faker-cxx/sport.h @@ -4,11 +4,13 @@ #include "faker-cxx/export.h" +#include "faker-cxx/types/locale.h" + namespace faker::sport { /** * @brief Returns a random sport. - * + * @param locale The locale. Defaults to `Locale::en_US`. * @returns Sport. * * @code @@ -16,21 +18,24 @@ namespace faker::sport * @endcode */ -FAKER_CXX_EXPORT std::string_view sportName(); +FAKER_CXX_EXPORT std::string_view sportName(Locale locale = Locale::en_US); + /** * @brief Returns a random soccer team. * * @returns Coccer team. + * @param locale The locale. Defaults to `Locale::en_US`. * * @code * faker::sport::soccerTeam() // "Manchester United" * @endcode */ -FAKER_CXX_EXPORT std::string_view soccerTeam(); +FAKER_CXX_EXPORT std::string_view soccerTeam(Locale locale = Locale::en_US); /** * @brief Returns a random male athlete. + * @param locale The locale. Defaults to `Locale::en_US`. * * @returns Male athlete. * @@ -38,10 +43,11 @@ FAKER_CXX_EXPORT std::string_view soccerTeam(); * faker::sport::maleAthlete() // "Cristiano Ronaldo" * @endcode */ -FAKER_CXX_EXPORT std::string_view maleAthlete(); +FAKER_CXX_EXPORT std::string_view maleAthlete(Locale locale = Locale::en_US); /** * @brief Returns a random female athlete. + * @param locale The locale. Defaults to `Locale::en_US`. * * @returns Female athlete. * @@ -49,10 +55,11 @@ FAKER_CXX_EXPORT std::string_view maleAthlete(); * faker::sport::femaleAthlete() // "Serena Williams" * @endcode */ -FAKER_CXX_EXPORT std::string_view femaleAthlete(); +FAKER_CXX_EXPORT std::string_view femaleAthlete(Locale locale = Locale::en_US); /** * @brief Returns a random Sport Event. + * @param locale The locale. Defaults to `Locale::en_US`. * * @returns Sport Event. * @@ -60,5 +67,5 @@ FAKER_CXX_EXPORT std::string_view femaleAthlete(); * faker::sport::sportEvent() // "Super Bowl" * @endcode */ -FAKER_CXX_EXPORT std::string_view sportEvent(); +FAKER_CXX_EXPORT std::string_view sportEvent(Locale locale = Locale::en_US); } diff --git a/src/modules/sport.cpp b/src/modules/sport.cpp index d890bc3ed..501326ceb 100644 --- a/src/modules/sport.cpp +++ b/src/modules/sport.cpp @@ -7,28 +7,59 @@ namespace faker::sport { -std::string_view sportName() -{ - return helper::randomElement(sportNames); +std::string_view sportName(Locale locale) +{ + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).sportNames); } -std::string_view soccerTeam() +std::string_view soccerTeam(Locale locale) { - return helper::randomElement(soccerTeams); + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).soccerTeams); } -std::string_view maleAthlete() +std::string_view maleAthlete(Locale locale) { - return helper::randomElement(maleAthletes); + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).maleAthletes); } -std::string_view femaleAthlete() +std::string_view femaleAthlete(Locale locale) { - return helper::randomElement(femaleAthletes); + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).femaleAthletes); } -std::string_view sportEvent() +std::string_view sportEvent(Locale locale) { - return helper::randomElement(sportEvents); + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).sportEvents); } + } diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index df9f9bb6c..9f8096a0e 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -2,10 +2,27 @@ #include #include +#include +#include +#include namespace faker::sport { -const auto femaleAthletes = std::to_array({ + + +struct SportDefinition +{ + std::span femaleAthletes; + std::span maleAthletes; + std::span soccerTeams; + std::span sportEvents; + std::span sportNames; +}; + +//"en_US" + + +const auto enUsFemaleAthletes = std::to_array({ "Alex Morgan", "Jackie Joyner-Kersee", "Lindsey Vonn", @@ -18,7 +35,7 @@ const auto femaleAthletes = std::to_array({ "Steffi Graf", }); -const auto maleAthletes = std::to_array({ +const auto enUSMaleAthletes = std::to_array({ "Cristiano Ronaldo", "Kobe Bryant", "LeBron James", @@ -31,7 +48,7 @@ const auto maleAthletes = std::to_array({ "Usain Bolt", }); -const auto soccerTeams = std::to_array({ +const auto enUSSoccerTeams = std::to_array({ "AC Milan", "Chelsea FC", "FC Barcelona", @@ -44,7 +61,7 @@ const auto soccerTeams = std::to_array({ "Real Madrid CF", }); -const auto sportEvents = std::to_array({ +const auto enUSSportEvents = std::to_array({ "ICC Cricket World Cup", "NBA Finals", "Olympics", @@ -57,7 +74,7 @@ const auto sportEvents = std::to_array({ "World Cup", }); -const auto sportNames = std::to_array({ +const auto enUSSportNames = std::to_array({ "American Football", "Baseball", "Basketball", @@ -70,4 +87,153 @@ const auto sportNames = std::to_array({ "Volleyball", }); +const SportDefinition enUSSportDefinition = { + .femaleAthletes = enUsFemaleAthletes, + .maleAthletes = enUSMaleAthletes, + .soccerTeams = enUSSoccerTeams, + .sportEvents = enUSSportEvents, + .sportNames = enUSSportNames + }; + + +//"es_AR" +const auto esARSportNames = std::to_array({ + "Futbol","Baseball","Basquet","Cricket", "Golf","Rugby", + "Polo","Ping Pong","Tenis","Voley", +}); + +const auto esARFemaleAthletes = std::to_array({ + "Gabriela Sabatini", + "Gisela Dulko", + "Paula Pareto", + "Luciana Aymar", + "Georgina Bardach", + "Sabrina Ameghino", + "Noemí Simonetto", + "Micaela Retegui", + "Cecilia Carranza Saroli", + "VAnina Onetto", +}); + +const auto esARMaleAthletes = std::to_array({ + "Emanuel Ginóbili", + "Lionel Messi", + "Diego Maradona", + "Carlos Monzón", + "Guillermo Vilas", + "Carlos Reutemann", + "Nicolino Locche", + "Carlos Teves", + "Walter Pérez", + "Sebastián Crismanich", +}); + + +const auto esARSoccerTeams = std::to_array({ + "Boca Juniors", + "River Plate", + "Colon Santa Fe", + "Independiente", + "Rosario Central", + "Racing", + "San Lorenzo", + "Newels Old Boys", + "Velez Sarfield", + "Talleres", +}); + + +const auto esARSportEvents = std::to_array({ + "Superliga", + "Copa Argentina", + "Primera B Nacional", + "Liga Nacional de Basquet", + "Turismo Carretera", + "Copa Libertadores", + "Liga de Voley Argentina", + "Argentina Open Tennis", + "Juegos Argentinos de Alto Rendimiento", + "MotoGP", +}); + +const SportDefinition esARSportDefinition = { + .femaleAthletes = esARFemaleAthletes, + .maleAthletes = esARMaleAthletes, + .soccerTeams = esARSoccerTeams, + .sportEvents = esARSportEvents, + .sportNames = esARSportNames + }; + +//"pt-br" +const auto ptBRSportNames = std::to_array({ + "Futebol","Handebol","Tênis","boxe", "Golf","rúgbi", + "Polo","Natação","Artes marciais","Voleibol", +}); + +const auto ptBRFemaleAthletes = std::to_array({ + "Amanda Nunes", + "Natahsa Ferreira", + "Paula Pareto", + "Larissa França", + "Juliana Veloso", + "Leticia Santos", + "Sissi", + "Thaísa", + "Marta Vieira", +}); + +const auto ptBRMaleAthletes = std::to_array({ + "Pele", + "Ayrton Senna", + "Nelson Piquet", + "Ronaldo", + "Ronaldinho", + "Guga Kuerten", + "Kaka", + "Neymar", + "Garrincha", + "Socrates", +}); + +const auto ptBRSoccerTeams = std::to_array({ + "Sao Paulo", + "Flamengo", + "Inter Porto Alegre", + "Santos", + "Cruzeiro", + "Corinthians", + "Gremio", + "Atletico Mineiro", + "Vasco da Gamma", + "Botafogo", +}); + +const auto ptBRSportEvents = std::to_array({ + "Brasileirao", + "Campeonato Paulista", + "Copa Brasil", + "GP Interlagos", + "ATP 500 Rio de Janeiro", + "ATP 250 Sao Paulo", + "Libertadores de América", + "MotoGP Rio do Janeiro", +}); + +const SportDefinition ptBRSportDefinition = { + .femaleAthletes = ptBRFemaleAthletes, + .maleAthletes = ptBRMaleAthletes, + .soccerTeams = ptBRSoccerTeams, + .sportEvents = ptBRSportEvents, + .sportNames = ptBRSportNames + }; + + +//general structure containing all the definitions + +const std::map sportMapSpan({ + {faker::Locale::en_US, {enUSSportDefinition}}, + {faker::Locale::es_AR, {esARSportDefinition}}, + {faker::Locale::pt_BR, {ptBRSportDefinition}}, + }); + } diff --git a/tests/modules/internet_test.cpp b/tests/modules/internet_test.cpp index 11f2caf71..6e7124d06 100644 --- a/tests/modules/internet_test.cpp +++ b/tests/modules/internet_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "gtest/gtest.h" diff --git a/tests/modules/sport_test.cpp b/tests/modules/sport_test.cpp index 49814f82e..1939c3818 100644 --- a/tests/modules/sport_test.cpp +++ b/tests/modules/sport_test.cpp @@ -5,52 +5,85 @@ #include "faker-cxx/sport.h" #include "sport_data.h" +#include "locale.h" using namespace ::testing; using namespace faker; using namespace faker::sport; -class SportTest : public Test + +namespace +{ + +const struct SportDefinition& getSportMapDefinition(Locale locale) +{ + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + return sportMapSpan.at(Locale::en_US); + } + else + { + return sportMapSpan.at(locale); + } +} +} + +class SportTestLocale : public TestWithParam { public: }; -TEST_F(SportTest, shouldGenerateSport) +TEST_P(SportTestLocale, shouldGenerateSportLocale) { - const auto generatedSport = sportName(); + auto extra = GetParam(); + auto sportDefinition = getSportMapDefinition(extra); + const auto generatedSport = faker::sport::sportName(extra); + - ASSERT_TRUE(std::ranges::any_of(sportNames, [generatedSport](const std::string_view& sport) + ASSERT_TRUE(std::ranges::any_of(sportDefinition.sportNames, [generatedSport](const std::string_view& sport) { return sport == generatedSport; })); } - -TEST_F(SportTest, shouldGenerateSoccerTeam) +TEST_P(SportTestLocale, shouldGenerateFemaleAthleteLocale) { - const auto generatedSoccerTeam = soccerTeam(); + auto extra = GetParam(); + auto sportDefinition = getSportMapDefinition(extra); - ASSERT_TRUE(std::ranges::any_of(soccerTeams, [generatedSoccerTeam](const std::string_view& soccerTeam) - { return soccerTeam == generatedSoccerTeam; })); -} + const auto generatedFemaleAthlete = femaleAthlete(extra); -TEST_F(SportTest, shouldGenerateSportEvent) -{ - const auto generatedSportEvent = sportEvent(); + 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(sportEvents, [generatedSportEvent](const std::string_view& sportEvent) - { return sportEvent == generatedSportEvent; })); + ASSERT_TRUE(std::ranges::any_of(sportDefinition.maleAthletes, [generatedMaleAthlete](const std::string_view& maleAthlete) + { return maleAthlete == generatedMaleAthlete; })); } -TEST_F(SportTest, shouldGenerateMaleAthlete) + +TEST_P(SportTestLocale, shouldGenerateSoccerTeamLocale) { - const auto generatedMaleAthlete = maleAthlete(); + auto extra = GetParam(); + auto sportDefinition = getSportMapDefinition(extra); + const auto generatedSoccerTeam = soccerTeam(extra); - ASSERT_TRUE(std::ranges::any_of(maleAthletes, [generatedMaleAthlete](const std::string_view& maleAthlete) - { return maleAthlete == generatedMaleAthlete; })); + ASSERT_TRUE(std::ranges::any_of(sportDefinition.soccerTeams, [generatedSoccerTeam](const std::string_view& soccerTeam) + { return soccerTeam == generatedSoccerTeam; })); } -TEST_F(SportTest, shouldGenerateFemaleAthlete) +TEST_P(SportTestLocale, shouldGenerateSportEventLocale) { - const auto generatedFemaleAthlete = femaleAthlete(); + auto extra = GetParam(); + auto sportDefinition = getSportMapDefinition(extra); + const auto generatedSportEvent = sportEvent(extra); - ASSERT_TRUE(std::ranges::any_of(femaleAthletes, [generatedFemaleAthlete](const std::string_view& femaleAthlete) - { return femaleAthlete == generatedFemaleAthlete; })); + 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); }); From a2d8327a41c69d12c9926587f3863fdc2bc413f9 Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 15:28:53 -0300 Subject: [PATCH 2/9] fix: fixing unformatted files --- include/faker-cxx/sport.h | 3 - src/modules/sport.cpp | 82 +++---- src/modules/sport_data.h | 455 +++++++++++++++++++------------------- 3 files changed, 270 insertions(+), 270 deletions(-) diff --git a/include/faker-cxx/sport.h b/include/faker-cxx/sport.h index a4f787c91..1c0b354db 100644 --- a/include/faker-cxx/sport.h +++ b/include/faker-cxx/sport.h @@ -1,9 +1,7 @@ #pragma once #include - #include "faker-cxx/export.h" - #include "faker-cxx/types/locale.h" namespace faker::sport @@ -20,7 +18,6 @@ namespace faker::sport FAKER_CXX_EXPORT std::string_view sportName(Locale locale = Locale::en_US); - /** * @brief Returns a random soccer team. * diff --git a/src/modules/sport.cpp b/src/modules/sport.cpp index 501326ceb..1ae780d89 100644 --- a/src/modules/sport.cpp +++ b/src/modules/sport.cpp @@ -7,59 +7,59 @@ namespace faker::sport { -std::string_view sportName(Locale locale) -{ - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) - { - localeLocal = Locale::en_US; + std::string_view sportName(Locale locale) + { + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).sportNames); } - return helper::randomElement((sportMapSpan.at(localeLocal)).sportNames); -} -std::string_view soccerTeam(Locale locale) -{ - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) + std::string_view soccerTeam(Locale locale) { - localeLocal = Locale::en_US; + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).soccerTeams); } - return helper::randomElement((sportMapSpan.at(localeLocal)).soccerTeams); -} -std::string_view maleAthlete(Locale locale) -{ - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) + std::string_view maleAthlete(Locale locale) { - localeLocal = Locale::en_US; + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).maleAthletes); } - return helper::randomElement((sportMapSpan.at(localeLocal)).maleAthletes); -} -std::string_view femaleAthlete(Locale locale) -{ - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) + std::string_view femaleAthlete(Locale locale) { - localeLocal = Locale::en_US; + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).femaleAthletes); } - return helper::randomElement((sportMapSpan.at(localeLocal)).femaleAthletes); -} -std::string_view sportEvent(Locale locale) -{ - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) + std::string_view sportEvent(Locale locale) { - localeLocal = Locale::en_US; + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; + } + return helper::randomElement((sportMapSpan.at(localeLocal)).sportEvents); } - return helper::randomElement((sportMapSpan.at(localeLocal)).sportEvents); -} } diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index 9f8096a0e..2f5dadc72 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -1,239 +1,242 @@ #pragma once #include -#include +#include #include +#include #include -#include + namespace faker::sport { -struct SportDefinition -{ - std::span femaleAthletes; - std::span maleAthletes; - std::span soccerTeams; - std::span sportEvents; - std::span sportNames; -}; - -//"en_US" - - -const auto enUsFemaleAthletes = std::to_array({ - "Alex Morgan", - "Jackie Joyner-Kersee", - "Lindsey Vonn", - "Martina Navratilova", - "Mia Hamm", - "Nadia Comăneci", - "Ronda Rousey", - "Serena Williams", - "Simone Biles", - "Steffi Graf", -}); - -const auto enUSMaleAthletes = std::to_array({ - "Cristiano Ronaldo", - "Kobe Bryant", - "LeBron James", - "Lionel Messi", - "Michael Jordan", - "Michael Phelps", - "Muhammad Ali", - "Roger Federer", - "Tom Brady", - "Usain Bolt", -}); - -const auto enUSSoccerTeams = std::to_array({ - "AC Milan", - "Chelsea FC", - "FC Barcelona", - "FC Bayern Munich", - "Inter Milan", - "Juventus FC", - "Liverpool FC", - "Manchester United FC", - "Paris Saint-Germain FC", - "Real Madrid CF", -}); - -const auto enUSSportEvents = std::to_array({ - "ICC Cricket World Cup", - "NBA Finals", - "Olympics", - "Rugby World Cup", - "Super Bowl", - "The Masters", - "UEFA Champions League", - "Wimbledon", - "World Athletics Championship", - "World Cup", -}); - -const auto enUSSportNames = std::to_array({ - "American Football", - "Baseball", - "Basketball", - "Cricket", - "Golf", - "Rugby", - "Soccer", - "Table Tennis", - "Tennis", - "Volleyball", -}); - -const SportDefinition enUSSportDefinition = { - .femaleAthletes = enUsFemaleAthletes, - .maleAthletes = enUSMaleAthletes, - .soccerTeams = enUSSoccerTeams, - .sportEvents = enUSSportEvents, - .sportNames = enUSSportNames - }; - - -//"es_AR" -const auto esARSportNames = std::to_array({ - "Futbol","Baseball","Basquet","Cricket", "Golf","Rugby", - "Polo","Ping Pong","Tenis","Voley", -}); - -const auto esARFemaleAthletes = std::to_array({ - "Gabriela Sabatini", - "Gisela Dulko", - "Paula Pareto", - "Luciana Aymar", - "Georgina Bardach", - "Sabrina Ameghino", - "Noemí Simonetto", - "Micaela Retegui", - "Cecilia Carranza Saroli", - "VAnina Onetto", -}); - -const auto esARMaleAthletes = std::to_array({ - "Emanuel Ginóbili", - "Lionel Messi", - "Diego Maradona", - "Carlos Monzón", - "Guillermo Vilas", - "Carlos Reutemann", - "Nicolino Locche", - "Carlos Teves", - "Walter Pérez", - "Sebastián Crismanich", -}); - - -const auto esARSoccerTeams = std::to_array({ - "Boca Juniors", - "River Plate", - "Colon Santa Fe", - "Independiente", - "Rosario Central", - "Racing", - "San Lorenzo", - "Newels Old Boys", - "Velez Sarfield", - "Talleres", -}); - - -const auto esARSportEvents = std::to_array({ - "Superliga", - "Copa Argentina", - "Primera B Nacional", - "Liga Nacional de Basquet", - "Turismo Carretera", - "Copa Libertadores", - "Liga de Voley Argentina", - "Argentina Open Tennis", - "Juegos Argentinos de Alto Rendimiento", - "MotoGP", -}); - -const SportDefinition esARSportDefinition = { - .femaleAthletes = esARFemaleAthletes, - .maleAthletes = esARMaleAthletes, - .soccerTeams = esARSoccerTeams, - .sportEvents = esARSportEvents, - .sportNames = esARSportNames - }; - -//"pt-br" -const auto ptBRSportNames = std::to_array({ - "Futebol","Handebol","Tênis","boxe", "Golf","rúgbi", - "Polo","Natação","Artes marciais","Voleibol", -}); - -const auto ptBRFemaleAthletes = std::to_array({ - "Amanda Nunes", - "Natahsa Ferreira", - "Paula Pareto", - "Larissa França", - "Juliana Veloso", - "Leticia Santos", - "Sissi", - "Thaísa", - "Marta Vieira", -}); - -const auto ptBRMaleAthletes = std::to_array({ - "Pele", - "Ayrton Senna", - "Nelson Piquet", - "Ronaldo", - "Ronaldinho", - "Guga Kuerten", - "Kaka", - "Neymar", - "Garrincha", - "Socrates", -}); - -const auto ptBRSoccerTeams = std::to_array({ - "Sao Paulo", - "Flamengo", - "Inter Porto Alegre", - "Santos", - "Cruzeiro", - "Corinthians", - "Gremio", - "Atletico Mineiro", - "Vasco da Gamma", - "Botafogo", -}); - -const auto ptBRSportEvents = std::to_array({ - "Brasileirao", - "Campeonato Paulista", - "Copa Brasil", - "GP Interlagos", - "ATP 500 Rio de Janeiro", - "ATP 250 Sao Paulo", - "Libertadores de América", - "MotoGP Rio do Janeiro", -}); - -const SportDefinition ptBRSportDefinition = { - .femaleAthletes = ptBRFemaleAthletes, - .maleAthletes = ptBRMaleAthletes, - .soccerTeams = ptBRSoccerTeams, - .sportEvents = ptBRSportEvents, - .sportNames = ptBRSportNames - }; - - -//general structure containing all the definitions - -const std::map sportMapSpan({ - {faker::Locale::en_US, {enUSSportDefinition}}, - {faker::Locale::es_AR, {esARSportDefinition}}, - {faker::Locale::pt_BR, {ptBRSportDefinition}}, + struct SportDefinition + { + std::span femaleAthletes; + std::span maleAthletes; + std::span soccerTeams; + std::span sportEvents; + std::span sportNames; + }; + + //"en_US" + + + const auto enUsFemaleAthletes = std::to_array({ + "Alex Morgan", + "Jackie Joyner-Kersee", + "Lindsey Vonn", + "Martina Navratilova", + "Mia Hamm", + "Nadia Comăneci", + "Ronda Rousey", + "Serena Williams", + "Simone Biles", + "Steffi Graf", + }); + + const auto enUSMaleAthletes = std::to_array({ + "Cristiano Ronaldo", + "Kobe Bryant", + "LeBron James", + "Lionel Messi", + "Michael Jordan", + "Michael Phelps", + "Muhammad Ali", + "Roger Federer", + "Tom Brady", + "Usain Bolt", + }); + + const auto enUSSoccerTeams = std::to_array({ + "AC Milan", + "Chelsea FC", + "FC Barcelona", + "FC Bayern Munich", + "Inter Milan", + "Juventus FC", + "Liverpool FC", + "Manchester United FC", + "Paris Saint-Germain FC", + "Real Madrid CF", + }); + + const auto enUSSportEvents = std::to_array({ + "ICC Cricket World Cup", + "NBA Finals", + "Olympics", + "Rugby World Cup", + "Super Bowl", + "The Masters", + "UEFA Champions League", + "Wimbledon", + "World Athletics Championship", + "World Cup", + }); + + const auto enUSSportNames = std::to_array({ + "American Football", + "Baseball", + "Basketball", + "Cricket", + "Golf", + "Rugby", + "Soccer", + "Table Tennis", + "Tennis", + "Volleyball", + }); + + const SportDefinition enUSSportDefinition = {.femaleAthletes = enUsFemaleAthletes, + .maleAthletes = enUSMaleAthletes, + .soccerTeams = enUSSoccerTeams, + .sportEvents = enUSSportEvents, + .sportNames = enUSSportNames}; + + + //"es_AR" + const auto esARSportNames = std::to_array({ + "Futbol","Baseball","Basquet","Cricket", "Golf","Rugby", + "Polo","Ping Pong","Tenis","Voley", + }); + + const auto esARFemaleAthletes = std::to_array({ + "Gabriela Sabatini", + "Gisela Dulko", + "Paula Pareto", + "Luciana Aymar", + "Georgina Bardach", + "Sabrina Ameghino", + "Noemí Simonetto", + "Micaela Retegui", + "Cecilia Carranza Saroli", + "VAnina Onetto", + }); + + const auto esARMaleAthletes = std::to_array({ + "Emanuel Ginóbili", + "Lionel Messi", + "Diego Maradona", + "Carlos Monzón", + "Guillermo Vilas", + "Carlos Reutemann", + "Nicolino Locche", + "Carlos Teves", + "Walter Pérez", + "Sebastián Crismanich", + }); + + + const auto esARSoccerTeams = std::to_array({ + "Boca Juniors", + "River Plate", + "Colon Santa Fe", + "Independiente", + "Rosario Central", + "Racing", + "San Lorenzo", + "Newels Old Boys", + "Velez Sarfield", + "Talleres", + }); + + + const auto esARSportEvents = std::to_array({ + "Superliga", + "Copa Argentina", + "Primera B Nacional", + "Liga Nacional de Basquet", + "Turismo Carretera", + "Copa Libertadores", + "Liga de Voley Argentina", + "Argentina Open Tennis", + "Juegos Argentinos de Alto Rendimiento", + "MotoGP", + }); + + const SportDefinition esARSportDefinition = {.femaleAthletes = esARFemaleAthletes, + .maleAthletes = esARMaleAthletes, + .soccerTeams = esARSoccerTeams, + .sportEvents = esARSportEvents, + .sportNames = esARSportNames}; + + //"pt-br" + const auto ptBRSportNames = std::to_array({ + "Futebol", + "Handebol", + "Tênis", + "boxe", + "Golf", + "rúgbi", + "Polo", + "Natação", + "Artes marciais", + "Voleibol", + }); + + const auto ptBRFemaleAthletes = std::to_array({ + "Amanda Nunes", + "Natahsa Ferreira", + "Paula Pareto", + "Larissa França", + "Juliana Veloso", + "Leticia Santos", + "Sissi", + "Thaísa", + "Marta Vieira", }); + const auto ptBRMaleAthletes = std::to_array({ + "Pele", + "Ayrton Senna", + "Nelson Piquet", + "Ronaldo", + "Ronaldinho", + "Guga Kuerten", + "Kaka", + "Neymar", + "Garrincha", + "Socrates", + }); + + const auto ptBRSoccerTeams = std::to_array({ + "Sao Paulo", + "Flamengo", + "Inter Porto Alegre", + "Santos", + "Cruzeiro", + "Corinthians", + "Gremio", + "Atletico Mineiro", + "Vasco da Gamma", + "Botafogo", + }); + + const auto ptBRSportEvents = std::to_array({ + "Brasileirao", + "Campeonato Paulista", + "Copa Brasil", + "GP Interlagos", + "ATP 500 Rio de Janeiro", + "ATP 250 Sao Paulo", + "Libertadores de América", + "MotoGP Rio do Janeiro", + }); + + const SportDefinition ptBRSportDefinition = {.femaleAthletes = ptBRFemaleAthletes, + .maleAthletes = ptBRMaleAthletes, + .soccerTeams = ptBRSoccerTeams, + .sportEvents = ptBRSportEvents, + .sportNames = ptBRSportNames}; + + + // general structure containing all the definitions + + const std::map sportMapSpan({ + {faker::Locale::en_US, {enUSSportDefinition}}, + {faker::Locale::es_AR, {esARSportDefinition}}, + {faker::Locale::pt_BR, {ptBRSportDefinition}}, + }); + } From a0d0a07ae06bc0e34a74cc1643f33d58cce66003 Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 15:33:53 -0300 Subject: [PATCH 3/9] fix: another code formatting --- include/faker-cxx/sport.h | 1 + src/modules/sport.cpp | 82 +++---- src/modules/sport_data.h | 454 +++++++++++++++++++------------------- 3 files changed, 268 insertions(+), 269 deletions(-) diff --git a/include/faker-cxx/sport.h b/include/faker-cxx/sport.h index 1c0b354db..9a9611744 100644 --- a/include/faker-cxx/sport.h +++ b/include/faker-cxx/sport.h @@ -1,6 +1,7 @@ #pragma once #include + #include "faker-cxx/export.h" #include "faker-cxx/types/locale.h" diff --git a/src/modules/sport.cpp b/src/modules/sport.cpp index 1ae780d89..501326ceb 100644 --- a/src/modules/sport.cpp +++ b/src/modules/sport.cpp @@ -7,59 +7,59 @@ namespace faker::sport { - std::string_view sportName(Locale locale) - { - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) - { - localeLocal = Locale::en_US; - } - return helper::randomElement((sportMapSpan.at(localeLocal)).sportNames); +std::string_view sportName(Locale locale) +{ + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) + { + localeLocal = Locale::en_US; } + return helper::randomElement((sportMapSpan.at(localeLocal)).sportNames); +} - std::string_view soccerTeam(Locale locale) +std::string_view soccerTeam(Locale locale) +{ + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) { - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) - { - localeLocal = Locale::en_US; - } - return helper::randomElement((sportMapSpan.at(localeLocal)).soccerTeams); + localeLocal = Locale::en_US; } + return helper::randomElement((sportMapSpan.at(localeLocal)).soccerTeams); +} - std::string_view maleAthlete(Locale locale) +std::string_view maleAthlete(Locale locale) +{ + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) { - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) - { - localeLocal = Locale::en_US; - } - return helper::randomElement((sportMapSpan.at(localeLocal)).maleAthletes); + localeLocal = Locale::en_US; } + return helper::randomElement((sportMapSpan.at(localeLocal)).maleAthletes); +} - std::string_view femaleAthlete(Locale locale) +std::string_view femaleAthlete(Locale locale) +{ + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) { - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) - { - localeLocal = Locale::en_US; - } - return helper::randomElement((sportMapSpan.at(localeLocal)).femaleAthletes); + localeLocal = Locale::en_US; } + return helper::randomElement((sportMapSpan.at(localeLocal)).femaleAthletes); +} - std::string_view sportEvent(Locale locale) +std::string_view sportEvent(Locale locale) +{ + auto localeLocal = locale; + + if (sportMapSpan.find(locale) == sportMapSpan.end()) { - auto localeLocal = locale; - - if (sportMapSpan.find(locale) == sportMapSpan.end()) - { - localeLocal = Locale::en_US; - } - return helper::randomElement((sportMapSpan.at(localeLocal)).sportEvents); + localeLocal = Locale::en_US; } + return helper::randomElement((sportMapSpan.at(localeLocal)).sportEvents); +} } diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index 2f5dadc72..8507682bf 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -9,234 +9,232 @@ namespace faker::sport { - - - struct SportDefinition - { - std::span femaleAthletes; - std::span maleAthletes; - std::span soccerTeams; - std::span sportEvents; - std::span sportNames; - }; - - //"en_US" - - - const auto enUsFemaleAthletes = std::to_array({ - "Alex Morgan", - "Jackie Joyner-Kersee", - "Lindsey Vonn", - "Martina Navratilova", - "Mia Hamm", - "Nadia Comăneci", - "Ronda Rousey", - "Serena Williams", - "Simone Biles", - "Steffi Graf", - }); - - const auto enUSMaleAthletes = std::to_array({ - "Cristiano Ronaldo", - "Kobe Bryant", - "LeBron James", - "Lionel Messi", - "Michael Jordan", - "Michael Phelps", - "Muhammad Ali", - "Roger Federer", - "Tom Brady", - "Usain Bolt", - }); - - const auto enUSSoccerTeams = std::to_array({ - "AC Milan", - "Chelsea FC", - "FC Barcelona", - "FC Bayern Munich", - "Inter Milan", - "Juventus FC", - "Liverpool FC", - "Manchester United FC", - "Paris Saint-Germain FC", - "Real Madrid CF", - }); - - const auto enUSSportEvents = std::to_array({ - "ICC Cricket World Cup", - "NBA Finals", - "Olympics", - "Rugby World Cup", - "Super Bowl", - "The Masters", - "UEFA Champions League", - "Wimbledon", - "World Athletics Championship", - "World Cup", - }); - - const auto enUSSportNames = std::to_array({ - "American Football", - "Baseball", - "Basketball", - "Cricket", - "Golf", - "Rugby", - "Soccer", - "Table Tennis", - "Tennis", - "Volleyball", - }); - - const SportDefinition enUSSportDefinition = {.femaleAthletes = enUsFemaleAthletes, - .maleAthletes = enUSMaleAthletes, - .soccerTeams = enUSSoccerTeams, - .sportEvents = enUSSportEvents, - .sportNames = enUSSportNames}; - - - //"es_AR" - const auto esARSportNames = std::to_array({ - "Futbol","Baseball","Basquet","Cricket", "Golf","Rugby", - "Polo","Ping Pong","Tenis","Voley", - }); - - const auto esARFemaleAthletes = std::to_array({ - "Gabriela Sabatini", - "Gisela Dulko", - "Paula Pareto", - "Luciana Aymar", - "Georgina Bardach", - "Sabrina Ameghino", - "Noemí Simonetto", - "Micaela Retegui", - "Cecilia Carranza Saroli", - "VAnina Onetto", - }); - - const auto esARMaleAthletes = std::to_array({ - "Emanuel Ginóbili", - "Lionel Messi", - "Diego Maradona", - "Carlos Monzón", - "Guillermo Vilas", - "Carlos Reutemann", - "Nicolino Locche", - "Carlos Teves", - "Walter Pérez", - "Sebastián Crismanich", - }); - - - const auto esARSoccerTeams = std::to_array({ - "Boca Juniors", - "River Plate", - "Colon Santa Fe", - "Independiente", - "Rosario Central", - "Racing", - "San Lorenzo", - "Newels Old Boys", - "Velez Sarfield", - "Talleres", - }); - - - const auto esARSportEvents = std::to_array({ - "Superliga", - "Copa Argentina", - "Primera B Nacional", - "Liga Nacional de Basquet", - "Turismo Carretera", - "Copa Libertadores", - "Liga de Voley Argentina", - "Argentina Open Tennis", - "Juegos Argentinos de Alto Rendimiento", - "MotoGP", - }); - - const SportDefinition esARSportDefinition = {.femaleAthletes = esARFemaleAthletes, - .maleAthletes = esARMaleAthletes, - .soccerTeams = esARSoccerTeams, - .sportEvents = esARSportEvents, - .sportNames = esARSportNames}; - - //"pt-br" - const auto ptBRSportNames = std::to_array({ - "Futebol", - "Handebol", - "Tênis", - "boxe", - "Golf", - "rúgbi", - "Polo", - "Natação", - "Artes marciais", - "Voleibol", - }); - - const auto ptBRFemaleAthletes = std::to_array({ - "Amanda Nunes", - "Natahsa Ferreira", - "Paula Pareto", - "Larissa França", - "Juliana Veloso", - "Leticia Santos", - "Sissi", - "Thaísa", - "Marta Vieira", - }); - - const auto ptBRMaleAthletes = std::to_array({ - "Pele", - "Ayrton Senna", - "Nelson Piquet", - "Ronaldo", - "Ronaldinho", - "Guga Kuerten", - "Kaka", - "Neymar", - "Garrincha", - "Socrates", - }); - - const auto ptBRSoccerTeams = std::to_array({ - "Sao Paulo", - "Flamengo", - "Inter Porto Alegre", - "Santos", - "Cruzeiro", - "Corinthians", - "Gremio", - "Atletico Mineiro", - "Vasco da Gamma", - "Botafogo", - }); - - const auto ptBRSportEvents = std::to_array({ - "Brasileirao", - "Campeonato Paulista", - "Copa Brasil", - "GP Interlagos", - "ATP 500 Rio de Janeiro", - "ATP 250 Sao Paulo", - "Libertadores de América", - "MotoGP Rio do Janeiro", +struct SportDefinition +{ + std::span femaleAthletes; + std::span maleAthletes; + std::span soccerTeams; + std::span sportEvents; + std::span sportNames; +}; + +//"en_US" + + +const auto enUsFemaleAthletes = std::to_array({ + "Alex Morgan", + "Jackie Joyner-Kersee", + "Lindsey Vonn", + "Martina Navratilova", + "Mia Hamm", + "Nadia Comăneci", + "Ronda Rousey", + "Serena Williams", + "Simone Biles", + "Steffi Graf", +}); + +const auto enUSMaleAthletes = std::to_array({ + "Cristiano Ronaldo", + "Kobe Bryant", + "LeBron James", + "Lionel Messi", + "Michael Jordan", + "Michael Phelps", + "Muhammad Ali", + "Roger Federer", + "Tom Brady", + "Usain Bolt", +}); + +const auto enUSSoccerTeams = std::to_array({ + "AC Milan", + "Chelsea FC", + "FC Barcelona", + "FC Bayern Munich", + "Inter Milan", + "Juventus FC", + "Liverpool FC", + "Manchester United FC", + "Paris Saint-Germain FC", + "Real Madrid CF", +}); + +const auto enUSSportEvents = std::to_array({ + "ICC Cricket World Cup", + "NBA Finals", + "Olympics", + "Rugby World Cup", + "Super Bowl", + "The Masters", + "UEFA Champions League", + "Wimbledon", + "World Athletics Championship", + "World Cup", +}); + +const auto enUSSportNames = std::to_array({ + "American Football", + "Baseball", + "Basketball", + "Cricket", + "Golf", + "Rugby", + "Soccer", + "Table Tennis", + "Tennis", + "Volleyball", +}); + +const SportDefinition enUSSportDefinition = {.femaleAthletes = enUsFemaleAthletes, + .maleAthletes = enUSMaleAthletes, + .soccerTeams = enUSSoccerTeams, + .sportEvents = enUSSportEvents, + .sportNames = enUSSportNames}; + + +//"es_AR" +const auto esARSportNames = std::to_array({ + "Futbol","Baseball","Basquet","Cricket", "Golf","Rugby", + "Polo","Ping Pong","Tenis","Voley", +}); + +const auto esARFemaleAthletes = std::to_array({ + "Gabriela Sabatini", + "Gisela Dulko", + "Paula Pareto", + "Luciana Aymar", + "Georgina Bardach", + "Sabrina Ameghino", + "Noemí Simonetto", + "Micaela Retegui", + "Cecilia Carranza Saroli", + "VAnina Onetto", +}); + +const auto esARMaleAthletes = std::to_array({ + "Emanuel Ginóbili", + "Lionel Messi", + "Diego Maradona", + "Carlos Monzón", + "Guillermo Vilas", + "Carlos Reutemann", + "Nicolino Locche", + "Carlos Teves", + "Walter Pérez", + "Sebastián Crismanich", +}); + + +const auto esARSoccerTeams = std::to_array({ + "Boca Juniors", + "River Plate", + "Colon Santa Fe", + "Independiente", + "Rosario Central", + "Racing", + "San Lorenzo", + "Newels Old Boys", + "Velez Sarfield", + "Talleres", +}); + + +const auto esARSportEvents = std::to_array({ + "Superliga", + "Copa Argentina", + "Primera B Nacional", + "Liga Nacional de Basquet", + "Turismo Carretera", + "Copa Libertadores", + "Liga de Voley Argentina", + "Argentina Open Tennis", + "Juegos Argentinos de Alto Rendimiento", + "MotoGP", +}); + +const SportDefinition esARSportDefinition = {.femaleAthletes = esARFemaleAthletes, + .maleAthletes = esARMaleAthletes, + .soccerTeams = esARSoccerTeams, + .sportEvents = esARSportEvents, + .sportNames = esARSportNames}; + +//"pt-br" +const auto ptBRSportNames = std::to_array({ + "Futebol", + "Handebol", + "Tênis", + "boxe", + "Golf", + "rúgbi", + "Polo", + "Natação", + "Artes marciais", + "Voleibol", +}); + +const auto ptBRFemaleAthletes = std::to_array({ + "Amanda Nunes", + "Natahsa Ferreira", + "Paula Pareto", + "Larissa França", + "Juliana Veloso", + "Leticia Santos", + "Sissi", + "Thaísa", + "Marta Vieira", +}); + +const auto ptBRMaleAthletes = std::to_array({ + "Pele", + "Ayrton Senna", + "Nelson Piquet", + "Ronaldo", + "Ronaldinho", + "Guga Kuerten", + "Kaka", + "Neymar", + "Garrincha", + "Socrates", +}); + +const auto ptBRSoccerTeams = std::to_array({ + "Sao Paulo", + "Flamengo", + "Inter Porto Alegre", + "Santos", + "Cruzeiro", + "Corinthians", + "Gremio", + "Atletico Mineiro", + "Vasco da Gamma", + "Botafogo", +}); + +const auto ptBRSportEvents = std::to_array({ + "Brasileirao", + "Campeonato Paulista", + "Copa Brasil", + "GP Interlagos", + "ATP 500 Rio de Janeiro", + "ATP 250 Sao Paulo", + "Libertadores de América", + "MotoGP Rio do Janeiro", +}); + +const SportDefinition ptBRSportDefinition = {.femaleAthletes = ptBRFemaleAthletes, + .maleAthletes = ptBRMaleAthletes, + .soccerTeams = ptBRSoccerTeams, + .sportEvents = ptBRSportEvents, + .sportNames = ptBRSportNames}; + + +// general structure containing all the definitions + +const std::map sportMapSpan({ + {faker::Locale::en_US, {enUSSportDefinition}}, + {faker::Locale::es_AR, {esARSportDefinition}}, + {faker::Locale::pt_BR, {ptBRSportDefinition}}, }); - const SportDefinition ptBRSportDefinition = {.femaleAthletes = ptBRFemaleAthletes, - .maleAthletes = ptBRMaleAthletes, - .soccerTeams = ptBRSoccerTeams, - .sportEvents = ptBRSportEvents, - .sportNames = ptBRSportNames}; - - - // general structure containing all the definitions - - const std::map sportMapSpan({ - {faker::Locale::en_US, {enUSSportDefinition}}, - {faker::Locale::es_AR, {esARSportDefinition}}, - {faker::Locale::pt_BR, {ptBRSportDefinition}}, - }); - } From d1f54806b7a5269c696f15543cac5ed14627e4e6 Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 15:42:45 -0300 Subject: [PATCH 4/9] fix: semantic issues --- src/modules/sport.cpp | 16 +++++----------- src/modules/sport_data.h | 40 ++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/modules/sport.cpp b/src/modules/sport.cpp index 501326ceb..5b09f999b 100644 --- a/src/modules/sport.cpp +++ b/src/modules/sport.cpp @@ -9,8 +9,7 @@ namespace faker::sport { std::string_view sportName(Locale locale) { - auto localeLocal = locale; - + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -20,8 +19,7 @@ std::string_view sportName(Locale locale) std::string_view soccerTeam(Locale locale) { - auto localeLocal = locale; - + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -31,8 +29,7 @@ std::string_view soccerTeam(Locale locale) std::string_view maleAthlete(Locale locale) { - auto localeLocal = locale; - + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -42,8 +39,7 @@ std::string_view maleAthlete(Locale locale) std::string_view femaleAthlete(Locale locale) { - auto localeLocal = locale; - + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -53,13 +49,11 @@ std::string_view femaleAthlete(Locale locale) std::string_view sportEvent(Locale locale) { - auto localeLocal = locale; - + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; } return helper::randomElement((sportMapSpan.at(localeLocal)).sportEvents); } - } diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index 8507682bf..73d58f07f 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -87,16 +87,24 @@ const auto enUSSportNames = std::to_array({ }); const SportDefinition enUSSportDefinition = {.femaleAthletes = enUsFemaleAthletes, - .maleAthletes = enUSMaleAthletes, - .soccerTeams = enUSSoccerTeams, - .sportEvents = enUSSportEvents, - .sportNames = enUSSportNames}; + .maleAthletes = enUSMaleAthletes, + .soccerTeams = enUSSoccerTeams, + .sportEvents = enUSSportEvents, + .sportNames = enUSSportNames}; //"es_AR" const auto esARSportNames = std::to_array({ - "Futbol","Baseball","Basquet","Cricket", "Golf","Rugby", - "Polo","Ping Pong","Tenis","Voley", + "Futbol", + "Baseball", + "Basquet", + "Cricket", + "Golf", + "Rugby", + "Polo", + "Ping Pong", + "Tenis", + "Voley", }); const auto esARFemaleAthletes = std::to_array({ @@ -154,10 +162,10 @@ const auto esARSportEvents = std::to_array({ }); const SportDefinition esARSportDefinition = {.femaleAthletes = esARFemaleAthletes, - .maleAthletes = esARMaleAthletes, - .soccerTeams = esARSoccerTeams, - .sportEvents = esARSportEvents, - .sportNames = esARSportNames}; + .maleAthletes = esARMaleAthletes, + .soccerTeams = esARSoccerTeams, + .sportEvents = esARSportEvents, + .sportNames = esARSportNames}; //"pt-br" const auto ptBRSportNames = std::to_array({ @@ -223,18 +231,18 @@ const auto ptBRSportEvents = std::to_array({ }); const SportDefinition ptBRSportDefinition = {.femaleAthletes = ptBRFemaleAthletes, - .maleAthletes = ptBRMaleAthletes, - .soccerTeams = ptBRSoccerTeams, - .sportEvents = ptBRSportEvents, - .sportNames = ptBRSportNames}; + .maleAthletes = ptBRMaleAthletes, + .soccerTeams = ptBRSoccerTeams, + .sportEvents = ptBRSportEvents, + .sportNames = ptBRSportNames}; -// general structure containing all the definitions +// General structure containing all the definitions const std::map sportMapSpan({ {faker::Locale::en_US, {enUSSportDefinition}}, {faker::Locale::es_AR, {esARSportDefinition}}, {faker::Locale::pt_BR, {ptBRSportDefinition}}, - }); +}); } From 87126cfdac76188acbd3bca198fd7c36674108fb Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 15:49:14 -0300 Subject: [PATCH 5/9] fix: code formatting --- src/modules/sport.cpp | 2 +- src/modules/sport_data.h | 77 ++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/modules/sport.cpp b/src/modules/sport.cpp index 5b09f999b..02e498f5e 100644 --- a/src/modules/sport.cpp +++ b/src/modules/sport.cpp @@ -8,7 +8,7 @@ namespace faker::sport { std::string_view sportName(Locale locale) -{ +{ auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index 73d58f07f..751f50254 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -6,7 +6,6 @@ #include #include - namespace faker::sport { struct SportDefinition @@ -20,7 +19,6 @@ struct SportDefinition //"en_US" - const auto enUsFemaleAthletes = std::to_array({ "Alex Morgan", "Jackie Joyner-Kersee", @@ -87,25 +85,12 @@ const auto enUSSportNames = std::to_array({ }); const SportDefinition enUSSportDefinition = {.femaleAthletes = enUsFemaleAthletes, - .maleAthletes = enUSMaleAthletes, - .soccerTeams = enUSSoccerTeams, - .sportEvents = enUSSportEvents, - .sportNames = enUSSportNames}; - + .maleAthletes = enUSMaleAthletes, + .soccerTeams = enUSSoccerTeams, + .sportEvents = enUSSportEvents, + .sportNames = enUSSportNames}; //"es_AR" -const auto esARSportNames = std::to_array({ - "Futbol", - "Baseball", - "Basquet", - "Cricket", - "Golf", - "Rugby", - "Polo", - "Ping Pong", - "Tenis", - "Voley", -}); const auto esARFemaleAthletes = std::to_array({ "Gabriela Sabatini", @@ -161,26 +146,27 @@ const auto esARSportEvents = std::to_array({ "MotoGP", }); -const SportDefinition esARSportDefinition = {.femaleAthletes = esARFemaleAthletes, - .maleAthletes = esARMaleAthletes, - .soccerTeams = esARSoccerTeams, - .sportEvents = esARSportEvents, - .sportNames = esARSportNames}; - -//"pt-br" -const auto ptBRSportNames = std::to_array({ - "Futebol", - "Handebol", - "Tênis", - "boxe", +const auto esARSportNames = std::to_array({ + "Futbol", + "Baseball", + "Basquet", + "Cricket", "Golf", - "rúgbi", + "Rugby", "Polo", - "Natação", - "Artes marciais", - "Voleibol", + "Ping Pong", + "Tenis", + "Voley", }); +const SportDefinition esARSportDefinition = {.femaleAthletes = esARFemaleAthletes, + .maleAthletes = esARMaleAthletes, + .soccerTeams = esARSoccerTeams, + .sportEvents = esARSportEvents, + .sportNames = esARSportNames}; + +//"pt-br" + const auto ptBRFemaleAthletes = std::to_array({ "Amanda Nunes", "Natahsa Ferreira", @@ -230,11 +216,24 @@ const auto ptBRSportEvents = std::to_array({ "MotoGP Rio do Janeiro", }); +const auto ptBRSportNames = std::to_array({ + "Futebol", + "Handebol", + "Tênis", + "boxe", + "Golf", + "rúgbi", + "Polo", + "Natação", + "Artes marciais", + "Voleibol", +}); + const SportDefinition ptBRSportDefinition = {.femaleAthletes = ptBRFemaleAthletes, - .maleAthletes = ptBRMaleAthletes, - .soccerTeams = ptBRSoccerTeams, - .sportEvents = ptBRSportEvents, - .sportNames = ptBRSportNames}; + .maleAthletes = ptBRMaleAthletes, + .soccerTeams = ptBRSoccerTeams, + .sportEvents = ptBRSportEvents, + .sportNames = ptBRSportNames}; // General structure containing all the definitions From 8ce2acc6c8cd7beb8cb3a0ba7ef16b3c0afcf8bf Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 15:56:26 -0300 Subject: [PATCH 6/9] fix: more semantic issues --- src/modules/sport_data.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index 751f50254..909158251 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -102,7 +102,7 @@ const auto esARFemaleAthletes = std::to_array({ "Noemí Simonetto", "Micaela Retegui", "Cecilia Carranza Saroli", - "VAnina Onetto", + "Vanina Onetto", }); const auto esARMaleAthletes = std::to_array({ @@ -130,8 +130,7 @@ const auto esARSoccerTeams = std::to_array({ "Newels Old Boys", "Velez Sarfield", "Talleres", -}); - + }); const auto esARSportEvents = std::to_array({ "Superliga", @@ -220,7 +219,7 @@ const auto ptBRSportNames = std::to_array({ "Futebol", "Handebol", "Tênis", - "boxe", + "boxe", "Golf", "rúgbi", "Polo", @@ -235,7 +234,6 @@ const SportDefinition ptBRSportDefinition = {.femaleAthletes = ptBRFemaleAthlete .sportEvents = ptBRSportEvents, .sportNames = ptBRSportNames}; - // General structure containing all the definitions const std::map sportMapSpan({ From 35a61d4e8a610e6c3de8d8ae5b53b2c5f7e43a05 Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 15:57:29 -0300 Subject: [PATCH 7/9] fix: removing line in sport_data.h --- src/modules/sport_data.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index 909158251..074a86fe4 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -118,7 +118,6 @@ const auto esARMaleAthletes = std::to_array({ "Sebastián Crismanich", }); - const auto esARSoccerTeams = std::to_array({ "Boca Juniors", "River Plate", From df4876c1c45ec0bf7073848b315bccc7fad6f91a Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 16:01:32 -0300 Subject: [PATCH 8/9] fix: another semantic issues --- src/modules/sport.cpp | 5 +++++ src/modules/sport_data.h | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/sport.cpp b/src/modules/sport.cpp index 02e498f5e..b85e3b732 100644 --- a/src/modules/sport.cpp +++ b/src/modules/sport.cpp @@ -9,6 +9,7 @@ namespace faker::sport { std::string_view sportName(Locale locale) { + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { @@ -19,6 +20,7 @@ std::string_view sportName(Locale locale) std::string_view soccerTeam(Locale locale) { + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { @@ -29,6 +31,7 @@ std::string_view soccerTeam(Locale locale) std::string_view maleAthlete(Locale locale) { + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { @@ -39,6 +42,7 @@ std::string_view maleAthlete(Locale locale) std::string_view femaleAthlete(Locale locale) { + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { @@ -49,6 +53,7 @@ std::string_view femaleAthlete(Locale locale) std::string_view sportEvent(Locale locale) { + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { diff --git a/src/modules/sport_data.h b/src/modules/sport_data.h index 074a86fe4..ef0b2bbe1 100644 --- a/src/modules/sport_data.h +++ b/src/modules/sport_data.h @@ -129,7 +129,7 @@ const auto esARSoccerTeams = std::to_array({ "Newels Old Boys", "Velez Sarfield", "Talleres", - }); +}); const auto esARSportEvents = std::to_array({ "Superliga", @@ -233,8 +233,6 @@ const SportDefinition ptBRSportDefinition = {.femaleAthletes = ptBRFemaleAthlete .sportEvents = ptBRSportEvents, .sportNames = ptBRSportNames}; -// General structure containing all the definitions - const std::map sportMapSpan({ {faker::Locale::en_US, {enUSSportDefinition}}, {faker::Locale::es_AR, {esARSportDefinition}}, From 1003c3592274e9022e9d9b2f3bb67aff24c92dc8 Mon Sep 17 00:00:00 2001 From: Gustavo Bastian Date: Sun, 24 Nov 2024 16:04:29 -0300 Subject: [PATCH 9/9] fix: minor semantic issue in sport.cpp --- src/modules/sport.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/modules/sport.cpp b/src/modules/sport.cpp index b85e3b732..e7d5cf7f2 100644 --- a/src/modules/sport.cpp +++ b/src/modules/sport.cpp @@ -9,8 +9,7 @@ namespace faker::sport { std::string_view sportName(Locale locale) { - - auto localeLocal = locale; + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -20,8 +19,7 @@ std::string_view sportName(Locale locale) std::string_view soccerTeam(Locale locale) { - - auto localeLocal = locale; + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -31,8 +29,7 @@ std::string_view soccerTeam(Locale locale) std::string_view maleAthlete(Locale locale) { - - auto localeLocal = locale; + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -42,8 +39,7 @@ std::string_view maleAthlete(Locale locale) std::string_view femaleAthlete(Locale locale) { - - auto localeLocal = locale; + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US; @@ -53,8 +49,7 @@ std::string_view femaleAthlete(Locale locale) std::string_view sportEvent(Locale locale) { - - auto localeLocal = locale; + auto localeLocal = locale; if (sportMapSpan.find(locale) == sportMapSpan.end()) { localeLocal = Locale::en_US;