-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e7ec1f
commit 020f3c0
Showing
9 changed files
with
234 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,65 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace faker | ||
{ | ||
class Sport | ||
{ | ||
public: | ||
/** | ||
* @brief Returns a random sport. | ||
* | ||
* @returns sport. | ||
* | ||
* @code | ||
* Sport::sport() // "football" | ||
* @endcode | ||
*/ | ||
static std::string sport(); | ||
|
||
/** | ||
* @brief Returns a random soccer team. | ||
* | ||
* @returns soccer team. | ||
* | ||
* @code | ||
* Sport::soccerTeam() // "Manchester United" | ||
* @endcode | ||
*/ | ||
static std::string soccerTeam(); | ||
|
||
/** | ||
* @brief Returns a random male athlete. | ||
* | ||
* @returns male athlete. | ||
* | ||
* @code | ||
* Sport::maleAthlete() // "Cristiano Ronaldo" | ||
* @endcode | ||
*/ | ||
static std::string maleAthlete(); | ||
|
||
/** | ||
* @brief Returns a random female athlete. | ||
* | ||
* @returns female athlete. | ||
* | ||
* @code | ||
* Sport::femaleAthlete() // "Serena Williams" | ||
* @endcode | ||
*/ | ||
static std::string femaleAthlete(); | ||
|
||
/** | ||
* @brief Returns a random Sport Event. | ||
* | ||
* @returns Sport Event. | ||
* | ||
* @code | ||
* Sport::sportEvent() // "Super Bowl" | ||
* @endcode | ||
*/ | ||
static std::string sportEvent(); | ||
}; | ||
} |
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,39 @@ | ||
#include "faker-cxx/Sport.h" | ||
#include "faker-cxx/Helper.h" | ||
|
||
|
||
#include <string> | ||
|
||
#include "data/FemaleAthletes.h" | ||
#include "data/MaleAthletes.h" | ||
#include "data/SoccerTeams.h" | ||
#include "data/SportEvents.h" | ||
#include "data/SportNames.h" | ||
|
||
namespace faker | ||
{ | ||
std::string Sport::sport() | ||
{ | ||
return Helper::arrayElement<std::string>(sportNames); | ||
} | ||
|
||
std::string Sport::soccerTeam() | ||
{ | ||
return Helper::arrayElement<std::string>(soccerTeams); | ||
} | ||
|
||
std::string Sport::maleAthlete() | ||
{ | ||
return Helper::arrayElement<std::string>(maleAthletes); | ||
} | ||
|
||
std::string Sport::femaleAthlete() | ||
{ | ||
return Helper::arrayElement<std::string>(femaleAthletes); | ||
} | ||
|
||
std::string Sport::sportEvent() | ||
{ | ||
return Helper::arrayElement<std::string>(sportEvents); | ||
} | ||
} |
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,60 @@ | ||
#include "faker-cxx/Sport.h" | ||
|
||
#include <algorithm> | ||
#include <string> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "data/FemaleAthletes.h" | ||
#include "data/MaleAthletes.h" | ||
#include "data/SoccerTeams.h" | ||
#include "data/SportEvents.h" | ||
#include "data/SportNames.h" | ||
|
||
using namespace ::testing; | ||
using namespace faker; | ||
|
||
class SportTest : public Test | ||
{ | ||
public: | ||
}; | ||
|
||
TEST_F(SportTest, shouldGenerateSport) | ||
{ | ||
std::string generatedSport = Sport::sport(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(sportNames, | ||
[generatedSport](const std::string& sport) { return sport == generatedSport; })); | ||
} | ||
|
||
TEST_F(SportTest, shouldGenerateSoccerTeam) | ||
{ | ||
std::string generatedSoccerTeam = Sport::soccerTeam(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(soccerTeams, [generatedSoccerTeam](const std::string& soccerTeam) | ||
{ return soccerTeam == generatedSoccerTeam; })); | ||
} | ||
|
||
TEST_F(SportTest, shouldGenerateSportEvent) | ||
{ | ||
std::string generatedSportEvent = Sport::sportEvent(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(sportEvents, [generatedSportEvent](const std::string& sportEvent) | ||
{ return sportEvent == generatedSportEvent; })); | ||
} | ||
|
||
TEST_F(SportTest, shouldGenerateMaleAthlete) | ||
{ | ||
std::string generatedMaleAthlete = Sport::maleAthlete(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(maleAthletes, [generatedMaleAthlete](const std::string& maleAthlete) | ||
{ return maleAthlete == generatedMaleAthlete; })); | ||
} | ||
|
||
TEST_F(SportTest, shouldGenerateFemaleAthlete) | ||
{ | ||
std::string generatedFemaleAthlete = Sport::femaleAthlete(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(femaleAthletes, [generatedFemaleAthlete](const std::string& femaleAthlete) | ||
{ return femaleAthlete == generatedFemaleAthlete; })); | ||
} |
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,12 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace faker | ||
{ | ||
const std::vector<std::string> femaleAthletes = { | ||
"Serena Williams", "Simone Biles", "Mia Hamm", "Ronda Rousey", "Lindsey Vonn", "Alex Morgan", | ||
"Martina Navratilova", "Jackie Joyner-Kersee", "Nadia Comăneci", "Steffi Graf", | ||
}; | ||
} |
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,12 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace faker | ||
{ | ||
const std::vector<std::string> maleAthletes = { | ||
"Lionel Messi", "Cristiano Ronaldo", "LeBron James", "Usain Bolt", "Michael Phelps", | ||
"Roger Federer", "Kobe Bryant", "Tom Brady", "Muhammad Ali", "Michael Jordan", | ||
}; | ||
} |
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,12 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace faker | ||
{ | ||
const std::vector<std::string> soccerTeams{ | ||
"FC Barcelona", "Real Madrid CF", "Manchester United FC", "Liverpool FC", "FC Bayern Munich", | ||
"AC Milan", "Inter Milan", "Juventus FC", "Paris Saint-Germain FC", "Chelsea FC", | ||
}; | ||
} |
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,20 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace faker | ||
{ | ||
const std::vector<std::string> sportEvents = { | ||
"World Cup", | ||
"Olympics", | ||
"Super Bowl", | ||
"World Athletics Championship", | ||
"UEFA Champions League", | ||
"NBA Finals", | ||
"Wimbledon", | ||
"ICC Cricket World Cup", | ||
"The Masters", | ||
"Rugby World Cup", | ||
}; | ||
} |
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,12 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace faker | ||
{ | ||
const std::vector<std::string> sportNames = { | ||
"Soccer", "Cricket", "Basketball", "Tennis", "Volleyball", "Table Tennis", | ||
"Golf", "Baseball", "American Football", "Rugby", | ||
}; | ||
} |