-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
2b5e86f
commit 94db8ba
Showing
8 changed files
with
1,413 additions
and
26 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,43 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace faker | ||
{ | ||
class Music | ||
{ | ||
public: | ||
/** | ||
* @brief Returns a random artist. | ||
* | ||
* @returns Artist. | ||
* | ||
* @code | ||
* Music::artist() // "Nirvana" | ||
* @endcode | ||
*/ | ||
static std::string artist(); | ||
|
||
/** | ||
* @brief Returns a random music genre. | ||
* | ||
* @returns Music genre. | ||
* | ||
* @code | ||
* Music::genre() // "Rock" | ||
* @endcode | ||
*/ | ||
static std::string genre(); | ||
|
||
/** | ||
* @brief Returns a random song name. | ||
* | ||
* @returns Song name. | ||
* | ||
* @code | ||
* Music::songName() // "Light My Fire" | ||
* @endcode | ||
*/ | ||
static std::string songName(); | ||
}; | ||
} |
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,24 @@ | ||
#include "faker-cxx/Music.h" | ||
|
||
#include "data/Artists.h" | ||
#include "data/Genres.h" | ||
#include "data/SongNames.h" | ||
#include "faker-cxx/Helper.h" | ||
|
||
namespace faker | ||
{ | ||
std::string Music::artist() | ||
{ | ||
return Helper::arrayElement<std::string>(artists); | ||
} | ||
|
||
std::string Music::genre() | ||
{ | ||
return Helper::arrayElement<std::string>(genres); | ||
} | ||
|
||
std::string Music::songName() | ||
{ | ||
return Helper::arrayElement<std::string>(songNames); | ||
} | ||
} |
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,42 @@ | ||
#include "faker-cxx/Music.h" | ||
|
||
#include <algorithm> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "data/Artists.h" | ||
#include "data/Genres.h" | ||
#include "data/SongNames.h" | ||
|
||
using namespace ::testing; | ||
using namespace faker; | ||
|
||
class MusicTest : public Test | ||
{ | ||
public: | ||
}; | ||
|
||
TEST_F(MusicTest, shouldGenerateArtist) | ||
{ | ||
const auto generatedArtist = Music::artist(); | ||
|
||
ASSERT_TRUE(std::any_of(artists.begin(), artists.end(), | ||
[generatedArtist](const std::string& artist) { return generatedArtist == artist; })); | ||
} | ||
|
||
TEST_F(MusicTest, shouldGenerateGenre) | ||
{ | ||
const auto generatedGenre = Music::genre(); | ||
|
||
ASSERT_TRUE(std::any_of(genres.begin(), genres.end(), | ||
[generatedGenre](const std::string& genre) { return generatedGenre == genre; })); | ||
} | ||
|
||
TEST_F(MusicTest, shouldGenerateSongName) | ||
{ | ||
const auto generatedSongName = Music::songName(); | ||
|
||
ASSERT_TRUE(std::any_of(songNames.begin(), songNames.end(), | ||
[generatedSongName](const std::string& songName) | ||
{ return generatedSongName == songName; })); | ||
} |
Oops, something went wrong.