Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

160-feature/animal module #176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ endif ()
set(LIBRARY_NAME faker-cxx)

set(FAKER_SOURCES
src/modules/animal/Animal.cpp
src/modules/book/Book.cpp
src/modules/color/Color.cpp
src/modules/commerce/Commerce.cpp
Expand All @@ -43,6 +44,7 @@ set(FAKER_SOURCES
)

set(FAKER_UT_SOURCES
src/modules/animal/AnimalTest.cpp
src/modules/book/BookTest.cpp
src/modules/color/ColorTest.cpp
src/modules/commerce/CommerceTest.cpp
Expand Down
175 changes: 175 additions & 0 deletions include/faker-cxx/Animal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#pragma once

#include <string>

namespace faker
{
class Animal
{
public:
/**
* @brief Returns a random species of bear.
*
* @returns Species of bear.
*
* @code
* Animal::bear() // "Polar bear"
* @endcode
*/
static std::string bear();
Globostofo marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Returns a random species of bird.
*
* @returns Species of bird.
*
* @code
* Animal::bird() // "Black-bellied Whistling-Duck"
* @endcode
*/
static std::string bird();

/**
* @brief Returns a random species of cat.
*
* @returns Species of cat.
*
* @code
* Animal::cat() // "Chartreux"
* @endcode
*/
static std::string cat();

/**
* @brief Returns a random species of cetacean.
*
* @returns Species of cetacean.
*
* @code
* Animal::cetacean() // "Blue Whale"
* @endcode
*/
static std::string cetacean();

/**
* @brief Returns a random species of cow.
*
* @returns Species of cow.
*
* @code
* Animal::cow() // "American Angus"
* @endcode
*/
static std::string cow();

/**
* @brief Returns a random species of crocodilia.
*
* @returns Species of crocodilia.
*
* @code
* Animal::crocodilia() // "Dwarf Crocodile"
* @endcode
*/
static std::string crocodilia();

/**
* @brief Returns a random species of dog.
*
* @returns Species of dog.
*
* @code
* Animal::dog() // "Shiba Inu"
* @endcode
*/
static std::string dog();

/**
* @brief Returns a random species of fish.
*
* @returns Species of fish.
*
* @code
* Animal::fish() // "Silver carp"
* @endcode
*/
static std::string fish();

/**
* @brief Returns a random species of horse.
*
* @returns Species of horse.
*
* @code
* Animal::horse() // "Fjord Horse"
* @endcode
*/
static std::string horse();

/**
* @brief Returns a random species of insect.
*
* @returns Species of insect.
*
* @code
* Animal::insect() // "Bee"
* @endcode
*/
static std::string insect();

/**
* @brief Returns a random species of lion.
*
* @returns Species of lion.
*
* @code
* Animal::lion() // "West African Lion"
* @endcode
*/
static std::string lion();

/**
* @brief Returns a random species of rabbit.
*
* @returns Species of rabbit.
*
* @code
* Animal::rabbit() // "Californian"
* @endcode
*/
static std::string rabbit();

/**
* @brief Returns a random species of rodent.
*
* @returns Species of rodent.
*
* @code
* Animal::rodent() // "Chinchilla"
* @endcode
*/
static std::string rodent();

/**
* @brief Returns a random species of snake.
*
* @returns Species of snake.
*
* @code
* Animal::snake() // "Boa constrictor"
* @endcode
*/
static std::string snake();

/**
* @brief Returns a random type of animal.
*
* @returns Type of animal.
*
* @code
* Animal::type() // "dog"
* @endcode
*/
static std::string type();
};
}
96 changes: 96 additions & 0 deletions src/modules/animal/Animal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "faker-cxx/Animal.h"

#include "data/Bears.h"
#include "data/Birds.h"
#include "data/Cats.h"
#include "data/Cetaceans.h"
#include "data/Cows.h"
#include "data/Crocodilia.h"
#include "data/Dogs.h"
#include "data/Fishes.h"
#include "data/Horses.h"
#include "data/Insects.h"
#include "data/Lions.h"
#include "data/Rabbits.h"
#include "data/Rodents.h"
#include "data/Snakes.h"
#include "data/Types.h"
#include "faker-cxx/Helper.h"

namespace faker
{
std::string Animal::bear()
{
return Helper::arrayElement<std::string>(bears);
}

std::string Animal::bird()
{
return Helper::arrayElement<std::string>(birds);
}

std::string Animal::cat()
{
return Helper::arrayElement<std::string>(cats);
}

std::string Animal::cetacean()
{
return Helper::arrayElement<std::string>(cetaceans);
}

std::string Animal::cow()
{
return Helper::arrayElement<std::string>(cows);
}

std::string Animal::crocodilia()
{
return Helper::arrayElement<std::string>(faker::crocodilia);
}

std::string Animal::dog()
{
return Helper::arrayElement<std::string>(dogs);
}

std::string Animal::fish()
{
return Helper::arrayElement<std::string>(fishes);
}

std::string Animal::horse()
{
return Helper::arrayElement<std::string>(horses);
}

std::string Animal::insect()
{
return Helper::arrayElement<std::string>(insects);
}

std::string Animal::lion()
{
return Helper::arrayElement<std::string>(lions);
}

std::string Animal::rabbit()
{
return Helper::arrayElement<std::string>(rabbits);
}

std::string Animal::rodent()
{
return Helper::arrayElement<std::string>(rodents);
}

std::string Animal::snake()
{
return Helper::arrayElement<std::string>(snakes);
}

std::string Animal::type()
{
return Helper::arrayElement<std::string>(types);
}
}
Loading