-
-
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.
* use string_view instead of string Signed-off-by: Uilian Ries <[email protected]> * use array instead of vector for sports * fix sport name when testing Signed-off-by: Uilian Ries <[email protected]> --------- Signed-off-by: Uilian Ries <[email protected]>
- Loading branch information
1 parent
e4fc0cc
commit 0d1f6ec
Showing
11 changed files
with
117 additions
and
108 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 |
---|---|---|
@@ -1,38 +1,34 @@ | ||
#include "faker-cxx/Sport.h" | ||
|
||
#include <string> | ||
#include <string_view> | ||
|
||
#include "data/FemaleAthletes.h" | ||
#include "data/MaleAthletes.h" | ||
#include "data/SoccerTeams.h" | ||
#include "data/SportEvents.h" | ||
#include "data/SportNames.h" | ||
#include "SportData.h" | ||
#include "faker-cxx/Helper.h" | ||
|
||
namespace faker | ||
{ | ||
std::string Sport::sport() | ||
std::string_view Sport::sport() | ||
{ | ||
return Helper::arrayElement<std::string>(sportNames); | ||
return Helper::arrayElement(sport::sportNames); | ||
} | ||
|
||
std::string Sport::soccerTeam() | ||
std::string_view Sport::soccerTeam() | ||
{ | ||
return Helper::arrayElement<std::string>(soccerTeams); | ||
return Helper::arrayElement(sport::soccerTeams); | ||
} | ||
|
||
std::string Sport::maleAthlete() | ||
std::string_view Sport::maleAthlete() | ||
{ | ||
return Helper::arrayElement<std::string>(maleAthletes); | ||
return Helper::arrayElement(sport::maleAthletes); | ||
} | ||
|
||
std::string Sport::femaleAthlete() | ||
std::string_view Sport::femaleAthlete() | ||
{ | ||
return Helper::arrayElement<std::string>(femaleAthletes); | ||
return Helper::arrayElement(sport::femaleAthletes); | ||
} | ||
|
||
std::string Sport::sportEvent() | ||
std::string_view Sport::sportEvent() | ||
{ | ||
return Helper::arrayElement<std::string>(sportEvents); | ||
return Helper::arrayElement(sport::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,70 @@ | ||
#include "SportData.h" | ||
|
||
namespace faker::sport | ||
{ | ||
const std::array<std::string_view, 10> femaleAthletes = { | ||
"Alex Morgan", | ||
"Jackie Joyner-Kersee", | ||
"Lindsey Vonn", | ||
"Martina Navratilova", | ||
"Mia Hamm", | ||
"Nadia Comăneci", | ||
"Ronda Rousey", | ||
"Serena Williams", | ||
"Simone Biles", | ||
"Steffi Graf" | ||
}; | ||
|
||
const std::array<std::string_view, 10> maleAthletes = { | ||
"Cristiano Ronaldo", | ||
"Kobe Bryant", | ||
"LeBron James", | ||
"Lionel Messi", | ||
"Michael Jordan", | ||
"Michael Phelps", | ||
"Muhammad Ali", | ||
"Roger Federer", | ||
"Tom Brady", | ||
"Usain Bolt" | ||
}; | ||
|
||
const std::array<std::string_view, 10> soccerTeams = { | ||
"AC Milan", | ||
"Chelsea FC", | ||
"FC Barcelona", | ||
"FC Bayern Munich", | ||
"Inter Milan", | ||
"Juventus FC", | ||
"Liverpool FC", | ||
"Manchester United FC", | ||
"Paris Saint-Germain FC", | ||
"Real Madrid CF" | ||
}; | ||
|
||
const std::array<std::string_view, 10> sportEvents = { | ||
"ICC Cricket World Cup", | ||
"NBA Finals", | ||
"Olympics", | ||
"Rugby World Cup", | ||
"Super Bowl", | ||
"The Masters", | ||
"UEFA Champions League", | ||
"Wimbledon", | ||
"World Athletics Championship", | ||
"World Cup" | ||
}; | ||
|
||
const std::array<std::string_view, 10> sportNames = { | ||
"American Football", | ||
"Baseball", | ||
"Basketball", | ||
"Cricket", | ||
"Golf", | ||
"Rugby", | ||
"Soccer", | ||
"Table Tennis", | ||
"Tennis", | ||
"Volleyball" | ||
}; | ||
|
||
} |
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,14 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <array> | ||
|
||
namespace faker::sport { | ||
|
||
extern const std::array<std::string_view, 10> femaleAthletes; | ||
extern const std::array<std::string_view, 10> maleAthletes; | ||
extern const std::array<std::string_view, 10> soccerTeams; | ||
extern const std::array<std::string_view, 10> sportEvents; | ||
extern const std::array<std::string_view, 10> sportNames; | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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