Skip to content

Commit

Permalink
Refactored Movies (#583)
Browse files Browse the repository at this point in the history
* Refactored actors and actresses

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add more movie data

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add movie data to cmake lists

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Update movies test

Signed-off-by: Uilian Ries <uilianries@gmail.com>

---------

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed May 24, 2024
1 parent f37c036 commit 788be8c
Show file tree
Hide file tree
Showing 12 changed files with 1,347 additions and 1,361 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ set(FAKER_SOURCES
src/modules/lorem/Lorem.cpp
src/modules/medicine/Medicine.cpp
src/modules/movie/Movie.cpp
src/modules/movie/MovieData.cpp
src/modules/music/Music.cpp
src/modules/number/Number.cpp
src/modules/person/Person.cpp
Expand All @@ -52,7 +53,6 @@ set(FAKER_SOURCES
src/modules/videoGame/VideoGame.cpp
src/modules/weather/Weather.cpp
src/modules/word/Word.cpp

src/common/FormatHelper.cpp
src/common/LuhnCheck.cpp
src/common/StringHelper.cpp
Expand Down
14 changes: 7 additions & 7 deletions include/faker-cxx/Movie.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <string>
#include <string_view>

namespace faker
{
Expand All @@ -16,7 +16,7 @@ class Movie
* Movie::genre() // "Drama"
* @endcode
*/
static std::string genre();
static std::string_view genre();

/**
* @brief Returns a random movie title.
Expand All @@ -27,7 +27,7 @@ class Movie
* Movie::movieTitle() // "Pulp Fiction"
* @endcode
*/
static std::string movieTitle();
static std::string_view movieTitle();

/**
* @brief Returns a random tv show.
Expand All @@ -38,7 +38,7 @@ class Movie
* Movie::tvShow() // "The Sopranos"
* @endcode
*/
static std::string tvShow();
static std::string_view tvShow();

/**
* @brief Returns a random movie director name.
Expand All @@ -49,7 +49,7 @@ class Movie
* Movie::director() // "Quentin Tarantino"
* @endcode
*/
static std::string director();
static std::string_view director();

/**
* @brief Returns a random actor name.
Expand All @@ -60,7 +60,7 @@ class Movie
* Movie::actor() // "John Travolta"
* @endcode
*/
static std::string actor();
static std::string_view actor();

/**
* @brief Returns a random actress name.
Expand All @@ -71,6 +71,6 @@ class Movie
* Movie::actress() // "Scarlett Johansson"
* @endcode
*/
static std::string actress();
static std::string_view actress();
};
}
31 changes: 13 additions & 18 deletions src/modules/movie/Movie.cpp
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
#include "faker-cxx/Movie.h"

#include "data/Actors.h"
#include "data/Actresses.h"
#include "data/Directors.h"
#include "data/Genres.h"
#include "data/Movies.h"
#include "data/TvShows.h"
#include "MovieData.h"
#include "faker-cxx/Helper.h"

namespace faker
{
std::string Movie::genre()
std::string_view Movie::genre()
{
return Helper::arrayElement<std::string>(genres);
return Helper::arrayElement(genres);
}

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

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

std::string Movie::director()
std::string_view Movie::director()
{
return Helper::arrayElement<std::string>(directors);
return Helper::arrayElement(directors);
}

std::string Movie::actor()
std::string_view Movie::actor()
{
return Helper::arrayElement<std::string>(actors);
return Helper::arrayElement(actors);
}

std::string Movie::actress()
std::string_view Movie::actress()
{
return Helper::arrayElement<std::string>(actresses);
return Helper::arrayElement(actresses);
}

}
Loading

0 comments on commit 788be8c

Please sign in to comment.