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

161 feature/video game module #204

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ set(FAKER_SOURCES
src/modules/movie/Movie.cpp
src/modules/hacker/Hacker.cpp
src/modules/sport/Sport.cpp
src/modules/videoGame/VideoGame.cpp
)

set(FAKER_UT_SOURCES
Expand Down Expand Up @@ -72,6 +73,7 @@ set(FAKER_UT_SOURCES
src/modules/movie/MovieTest.cpp
src/modules/hacker/HackerTest.cpp
src/modules/sport/SportTest.cpp
src/modules/videoGame/VideoGameTest.cpp
)

add_library(${LIBRARY_NAME} ${FAKER_SOURCES})
Expand Down
54 changes: 54 additions & 0 deletions include/faker-cxx/VideoGame.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#pragma once

#include <string>

namespace faker
{
class VideoGame
{
public:
/**
* @brief Returns a random video game name.
*
* @returns Video game name.
*
* @code
* Videogame::gameTitle() // "Rayman Arena"
* @endcode
*/
static std::string gameTitle();

/**
* @brief Returns a random video game genre.
*
* @returns Video game genre.
*
* @code
* VideoGame::genre() // "Platformer"
* @endcode
*/
static std::string genre();

/**
* @brief Returns a random video game platform.
*
* @returns Platform.
*
* @code
* VideoGame::platform() // "Playstation 5"
* @endcode
*/
static std::string platform();

/**
* @brief Returns a random video game studio name.
*
* @returns Studio name.
*
* @code
* VideoGame::studioName() // "Activision Blizzard"
* @endcode
*/
static std::string studioName();
};
}
30 changes: 30 additions & 0 deletions src/modules/videoGame/VideoGame.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "faker-cxx/VideoGame.h"

#include "data/GameTitles.h"
#include "data/Genres.h"
#include "data/Platforms.h"
#include "data/StudioNames.h"
#include "faker-cxx/Helper.h"

namespace faker
{
std::string VideoGame::gameTitle()
{
return Helper::arrayElement<std::string>(videoGameNames);
}

std::string VideoGame::genre()
{
return Helper::arrayElement<std::string>(genres);
}

std::string VideoGame::platform()
{
return Helper::arrayElement<std::string>(platforms);
}

std::string VideoGame::studioName()
{
return Helper::arrayElement<std::string>(studioNames);
}
}
50 changes: 50 additions & 0 deletions src/modules/videoGame/VideoGameTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "faker-cxx/VideoGame.h"

#include <algorithm>

#include "gtest/gtest.h"

#include "data/GameTitles.h"
#include "data/Genres.h"
#include "data/Platforms.h"
#include "data/StudioNames.h"

using namespace ::testing;
using namespace faker;

class VideoGameTest : public Test
{
public:
};

TEST_F(VideoGameTest, shouldGenerateGameTitle)
{
const auto generatedGameTitle = VideoGame::gameTitle();

ASSERT_TRUE(std::ranges::any_of(videoGameNames, [generatedGameTitle](const std::string& gameTitle)
{ return generatedGameTitle == gameTitle; }));
}

TEST_F(VideoGameTest, shouldGenerateGenre)
{
const auto generatedGenre = VideoGame::genre();

ASSERT_TRUE(std::ranges::any_of(genres, [generatedGenre](const std::string& genre)
{ return generatedGenre == genre; }));
}

TEST_F(VideoGameTest, shouldGeneratePlatform)
{
const auto generatedPlatform = VideoGame::platform();

ASSERT_TRUE(std::ranges::any_of(platforms, [generatedPlatform](const std::string& platform)
{ return generatedPlatform == platform; }));
}

TEST_F(VideoGameTest, shouldGenerateStudioName)
{
const auto generatedStudioName = VideoGame::studioName();

ASSERT_TRUE(std::ranges::any_of(studioNames, [generatedStudioName](const std::string& studioName)
{ return generatedStudioName == studioName; }));
}
3,161 changes: 3,161 additions & 0 deletions src/modules/videoGame/data/GameTitles.h

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions src/modules/videoGame/data/Genres.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> genres = {"Action",
"Adventure",
"Battle royale",
"Dating sim",
"Endless runner",
"Fighting",
"First-person shooter",
"Hack and slash",
"Horror",
"Massively multiplayer online",
"Music",
"Platformer",
"Puzzle",
"Racing",
"Real-time strategy",
"Roguelike",
"Role-playing game",
"Sandbox",
"Science fiction game",
"Shooter",
"Sim racing",
"Soulslike",
"Sports",
"Stealth",
"Strategy",
"Survival",
"Third-person shooter",
"Tower defense"};
}
18 changes: 18 additions & 0 deletions src/modules/videoGame/data/Platforms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> platforms = {"PC",
"Playstation 5",
"Xbox Series X",
"Nintendo Switch",
"iOS",
"Android",
"Linux",
"Stadia",
"Oculus Quest",
};
}
Loading