Skip to content

Commit

Permalink
add tv shows to movie module
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal committed Oct 16, 2023
1 parent 786d834 commit fc0af93
Show file tree
Hide file tree
Showing 6 changed files with 419 additions and 262 deletions.
11 changes: 11 additions & 0 deletions include/faker-cxx/Movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ class Movie
*/
static std::string movieTitle();

/**
* @brief Returns a random tv show.
*
* @returns Tv show.
*
* @code
* Movie::tvShow() // "The Sopranos"
* @endcode
*/
static std::string tvShow();

/**
* @brief Returns a random movie director name.
*
Expand Down
11 changes: 9 additions & 2 deletions src/modules/movie/Movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "data/Actresses.h"
#include "data/Directors.h"
#include "data/Genres.h"
#include "data/MovieTitles.h"
#include "data/Movies.h"
#include "data/TvShows.h"
#include "faker-cxx/Helper.h"

namespace faker
Expand All @@ -16,7 +17,12 @@ std::string Movie::genre()

std::string Movie::movieTitle()
{
return Helper::arrayElement<std::string>(movieTitles);
return Helper::arrayElement<std::string>(movies);
}

std::string Movie::tvShow()
{
return Helper::arrayElement<std::string>(tvShows);
}

std::string Movie::director()
Expand All @@ -33,4 +39,5 @@ std::string Movie::actress()
{
return Helper::arrayElement<std::string>(actresses);
}

}
13 changes: 11 additions & 2 deletions src/modules/movie/MovieTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include "data/Actresses.h"
#include "data/Directors.h"
#include "data/Genres.h"
#include "data/MovieTitles.h"
#include "data/Movies.h"
#include "data/TvShows.h"

using namespace ::testing;
using namespace faker;
Expand All @@ -30,10 +31,18 @@ TEST_F(MovieTest, shouldGenerateMovieTitle)
{
const auto generatedMovieTitle = Movie::movieTitle();

ASSERT_TRUE(std::ranges::any_of(movieTitles, [generatedMovieTitle](const std::string& movieTitle)
ASSERT_TRUE(std::ranges::any_of(movies, [generatedMovieTitle](const std::string& movieTitle)
{ return generatedMovieTitle == movieTitle; }));
}

TEST_F(MovieTest, shouldGenerateTvShow)
{
const auto generatedTvShow = Movie::tvShow();

ASSERT_TRUE(std::ranges::any_of(tvShows, [generatedTvShow](const std::string& tvShow)
{ return generatedTvShow == tvShow; }));
}

TEST_F(MovieTest, shouldGenerateDirector)
{
const auto generatedDirector = Movie::director();
Expand Down
258 changes: 0 additions & 258 deletions src/modules/movie/data/MovieTitles.h

This file was deleted.

Loading

0 comments on commit fc0af93

Please sign in to comment.