diff --git a/include/faker-cxx/Sport.h b/include/faker-cxx/Sport.h index 4d2a1a7a4..a5085b39a 100644 --- a/include/faker-cxx/Sport.h +++ b/include/faker-cxx/Sport.h @@ -2,11 +2,8 @@ #include -namespace faker +namespace faker::Sport { -class Sport -{ -public: /** * @brief Returns a random sport. * @@ -16,7 +13,8 @@ class Sport * Sport::sport() // "football" * @endcode */ - static std::string_view sport(); + + std::string_view sport(); /** * @brief Returns a random soccer team. @@ -27,7 +25,7 @@ class Sport * Sport::soccerTeam() // "Manchester United" * @endcode */ - static std::string_view soccerTeam(); + std::string_view soccerTeam(); /** * @brief Returns a random male athlete. @@ -38,7 +36,7 @@ class Sport * Sport::maleAthlete() // "Cristiano Ronaldo" * @endcode */ - static std::string_view maleAthlete(); + std::string_view maleAthlete(); /** * @brief Returns a random female athlete. @@ -49,7 +47,7 @@ class Sport * Sport::femaleAthlete() // "Serena Williams" * @endcode */ - static std::string_view femaleAthlete(); + std::string_view femaleAthlete(); /** * @brief Returns a random Sport Event. @@ -60,6 +58,5 @@ class Sport * Sport::sportEvent() // "Super Bowl" * @endcode */ - static std::string_view sportEvent(); -}; + std::string_view sportEvent(); } diff --git a/src/modules/sport/Sport.cpp b/src/modules/sport/Sport.cpp index 385bc3f98..b4f6f8d39 100644 --- a/src/modules/sport/Sport.cpp +++ b/src/modules/sport/Sport.cpp @@ -5,30 +5,30 @@ #include "faker-cxx/Helper.h" #include "SportData.h" -namespace faker +namespace faker::Sport { -std::string_view Sport::sport() +std::string_view sport() { - return Helper::arrayElement(sport::sportNames); + return Helper::arrayElement(sportNames); } -std::string_view Sport::soccerTeam() +std::string_view soccerTeam() { - return Helper::arrayElement(sport::soccerTeams); + return Helper::arrayElement(soccerTeams); } -std::string_view Sport::maleAthlete() +std::string_view maleAthlete() { - return Helper::arrayElement(sport::maleAthletes); + return Helper::arrayElement(maleAthletes); } -std::string_view Sport::femaleAthlete() +std::string_view femaleAthlete() { - return Helper::arrayElement(sport::femaleAthletes); + return Helper::arrayElement(femaleAthletes); } -std::string_view Sport::sportEvent() +std::string_view sportEvent() { - return Helper::arrayElement(sport::sportEvents); + return Helper::arrayElement(sportEvents); } } diff --git a/src/modules/sport/SportData.h b/src/modules/sport/SportData.h index a01000271..c0a4b3e8b 100644 --- a/src/modules/sport/SportData.h +++ b/src/modules/sport/SportData.h @@ -3,7 +3,7 @@ #include #include -namespace faker::sport +namespace faker::Sport { const auto femaleAthletes = std::to_array({ "Alex Morgan", "Jackie Joyner-Kersee", "Lindsey Vonn", "Martina Navratilova", "Mia Hamm", diff --git a/tests/modules/sport/SportTest.cpp b/tests/modules/sport/SportTest.cpp index caa729258..56b00deb2 100644 --- a/tests/modules/sport/SportTest.cpp +++ b/tests/modules/sport/SportTest.cpp @@ -9,6 +9,7 @@ using namespace ::testing; using namespace faker; +using namespace faker::Sport; class SportTest : public Test { @@ -17,41 +18,41 @@ class SportTest : public Test TEST_F(SportTest, shouldGenerateSport) { - const auto generatedSport = Sport::sport(); + const auto generatedSport = sport(); - ASSERT_TRUE(std::ranges::any_of(sport::sportNames, [generatedSport](const std::string_view& sport) + ASSERT_TRUE(std::ranges::any_of(sportNames, [generatedSport](const std::string_view& sport) { return sport == generatedSport; })); } TEST_F(SportTest, shouldGenerateSoccerTeam) { - const auto generatedSoccerTeam = Sport::soccerTeam(); + const auto generatedSoccerTeam = soccerTeam(); - ASSERT_TRUE(std::ranges::any_of(sport::soccerTeams, [generatedSoccerTeam](const std::string_view& soccerTeam) + ASSERT_TRUE(std::ranges::any_of(soccerTeams, [generatedSoccerTeam](const std::string_view& soccerTeam) { return soccerTeam == generatedSoccerTeam; })); } TEST_F(SportTest, shouldGenerateSportEvent) { - const auto generatedSportEvent = Sport::sportEvent(); + const auto generatedSportEvent = sportEvent(); - ASSERT_TRUE(std::ranges::any_of(sport::sportEvents, [generatedSportEvent](const std::string_view& sportEvent) + ASSERT_TRUE(std::ranges::any_of(sportEvents, [generatedSportEvent](const std::string_view& sportEvent) { return sportEvent == generatedSportEvent; })); } TEST_F(SportTest, shouldGenerateMaleAthlete) { - const auto generatedMaleAthlete = Sport::maleAthlete(); + const auto generatedMaleAthlete = maleAthlete(); - ASSERT_TRUE(std::ranges::any_of(sport::maleAthletes, [generatedMaleAthlete](const std::string_view& maleAthlete) + ASSERT_TRUE(std::ranges::any_of(maleAthletes, [generatedMaleAthlete](const std::string_view& maleAthlete) { return maleAthlete == generatedMaleAthlete; })); } TEST_F(SportTest, shouldGenerateFemaleAthlete) { - const auto generatedFemaleAthlete = Sport::femaleAthlete(); + const auto generatedFemaleAthlete = femaleAthlete(); - ASSERT_TRUE(std::ranges::any_of(sport::femaleAthletes, + ASSERT_TRUE(std::ranges::any_of(femaleAthletes, [generatedFemaleAthlete](const std::string_view& femaleAthlete) { return femaleAthlete == generatedFemaleAthlete; })); }