-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
161 feature/video game module (#204)
* Added video game data * Added video game methods * Added tests to video game module * Added new files to cmakelist * Fixed typos
- Loading branch information
1 parent
3105881
commit e838ce6
Showing
8 changed files
with
3,751 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; })); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}; | ||
} |
Oops, something went wrong.