diff --git a/include/faker-cxx/VideoGame.h b/include/faker-cxx/VideoGame.h index 9ba793ed4..542c19127 100644 --- a/include/faker-cxx/VideoGame.h +++ b/include/faker-cxx/VideoGame.h @@ -2,11 +2,8 @@ #include -namespace faker +namespace faker::videogame { -class VideoGame -{ -public: /** * @brief Returns a random video game name. * @@ -16,7 +13,7 @@ class VideoGame * VideoGame::gameTitle() // "Rayman Arena" * @endcode */ - static std::string_view gameTitle(); + std::string_view gameTitle(); /** * @brief Returns a random video game genre. @@ -27,7 +24,7 @@ class VideoGame * VideoGame::genre() // "Platformer" * @endcode */ - static std::string_view genre(); + std::string_view genre(); /** * @brief Returns a random video game platform. @@ -38,7 +35,7 @@ class VideoGame * VideoGame::platform() // "Playstation 5" * @endcode */ - static std::string_view platform(); + std::string_view platform(); /** * @brief Returns a random video game studio name. @@ -49,6 +46,5 @@ class VideoGame * VideoGame::studioName() // "Activision Blizzard" * @endcode */ - static std::string_view studioName(); -}; + std::string_view studioName(); } diff --git a/src/modules/videoGame/VideoGame.cpp b/src/modules/videoGame/VideoGame.cpp index ed37b2026..8424674f0 100644 --- a/src/modules/videoGame/VideoGame.cpp +++ b/src/modules/videoGame/VideoGame.cpp @@ -5,25 +5,25 @@ #include "faker-cxx/Helper.h" #include "VideoGameData.h" -namespace faker +namespace faker::videogame { -std::string_view VideoGame::gameTitle() +std::string_view gameTitle() { - return Helper::arrayElement(videoGame::videoGameNames); + return Helper::arrayElement(videoGameNames); } -std::string_view VideoGame::genre() +std::string_view genre() { - return Helper::arrayElement(videoGame::videoGameGenres); + return Helper::arrayElement(videoGameGenres); } -std::string_view VideoGame::platform() +std::string_view platform() { - return Helper::arrayElement(videoGame::platforms); + return Helper::arrayElement(platforms); } -std::string_view VideoGame::studioName() +std::string_view studioName() { - return Helper::arrayElement(videoGame::studioNames); + return Helper::arrayElement(studioNames); } } diff --git a/src/modules/videoGame/VideoGameData.h b/src/modules/videoGame/VideoGameData.h index 9cf587cab..f93c1c3ce 100644 --- a/src/modules/videoGame/VideoGameData.h +++ b/src/modules/videoGame/VideoGameData.h @@ -3,9 +3,7 @@ #include #include -namespace faker -{ -namespace videoGame +namespace faker::videogame { const auto videoGameNames = std::to_array({ "#killallzombies", @@ -3594,4 +3592,3 @@ const auto studioNames = std::to_array({ }); } -} diff --git a/tests/modules/videoGame/VideoGameTest.cpp b/tests/modules/videoGame/VideoGameTest.cpp index c961f5a93..7fb52b88a 100644 --- a/tests/modules/videoGame/VideoGameTest.cpp +++ b/tests/modules/videoGame/VideoGameTest.cpp @@ -9,6 +9,7 @@ using namespace ::testing; using namespace faker; +using namespace faker::videogame; class VideoGameTest : public Test { @@ -17,32 +18,32 @@ class VideoGameTest : public Test TEST_F(VideoGameTest, shouldGenerateGameTitle) { - const auto generatedGameTitle = VideoGame::gameTitle(); + const auto generatedGameTitle = gameTitle(); - ASSERT_TRUE(std::ranges::any_of(videoGame::videoGameNames, [generatedGameTitle](const std::string_view& gameTitle) + ASSERT_TRUE(std::ranges::any_of(videoGameNames, [generatedGameTitle](const std::string_view& gameTitle) { return generatedGameTitle == gameTitle; })); } TEST_F(VideoGameTest, shouldGenerateGenre) { - const auto generatedGenre = VideoGame::genre(); + const auto generatedGenre = genre(); - ASSERT_TRUE(std::ranges::any_of(videoGame::videoGameGenres, [generatedGenre](const std::string_view& genre) + ASSERT_TRUE(std::ranges::any_of(videoGameGenres, [generatedGenre](const std::string_view& genre) { return generatedGenre == genre; })); } TEST_F(VideoGameTest, shouldGeneratePlatform) { - const auto generatedPlatform = VideoGame::platform(); + const auto generatedPlatform = platform(); - ASSERT_TRUE(std::ranges::any_of(videoGame::platforms, [generatedPlatform](const std::string_view& platform) + ASSERT_TRUE(std::ranges::any_of(platforms, [generatedPlatform](const std::string_view& platform) { return generatedPlatform == platform; })); } TEST_F(VideoGameTest, shouldGenerateStudioName) { - const auto generatedStudioName = VideoGame::studioName(); + const auto generatedStudioName = studioName(); - ASSERT_TRUE(std::ranges::any_of(videoGame::studioNames, [generatedStudioName](const std::string_view& studioName) + ASSERT_TRUE(std::ranges::any_of(studioNames, [generatedStudioName](const std::string_view& studioName) { return generatedStudioName == studioName; })); }