-
-
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.
* Removed uneeded functions and moved some to StringHelper * Added Sport Module
- Loading branch information
1 parent
d6e26e1
commit 51ba70d
Showing
17 changed files
with
275 additions
and
100 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
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
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
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
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
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; })); | ||
} |
Oops, something went wrong.