Skip to content

Commit

Permalink
Merge branch 'feature/git-module' of https://github.com/Pe7o/faker-cxx
Browse files Browse the repository at this point in the history
…into feature/git-module
  • Loading branch information
Peter Mento committed Oct 15, 2023
2 parents 7327170 + 68a8d9a commit f49a53a
Show file tree
Hide file tree
Showing 91 changed files with 9,171 additions and 209 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-clang-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: clang
name: clang++

on:
push:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/macos-clang-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: apple-clang++

on:
push:
branches:
- 'main'
pull_request:

env:
BUILD_TYPE: Debug

jobs:
build:
runs-on: macos-latest

steps:
- name: Install clang
run: brew install llvm@16 && echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile && source /Users/runner/.bash_profile && which clang++

- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- working-directory: build/
run: ./faker-cxx-UT
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "externals/googletest"]
path = externals/googletest
url = https://github.com/google/googletest.git
[submodule "externals/fmt"]
path = externals/fmt
url = https://github.com/fmtlib/fmt.git
23 changes: 20 additions & 3 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 @@ -41,9 +42,14 @@ set(FAKER_SOURCES
src/modules/music/Music.cpp
src/modules/movie/Movie.cpp
src/modules/git/Git.cpp
)
src/modules/hacker/Hacker.cpp
src/modules/sport/Sport.cpp
src/modules/videoGame/VideoGame.cpp
src/modules/medicine/Medicine.cpp
)

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 All @@ -68,7 +74,11 @@ set(FAKER_UT_SOURCES
src/modules/music/MusicTest.cpp
src/modules/movie/MovieTest.cpp
src/modules/git/GitTest.cpp
)
src/modules/hacker/HackerTest.cpp
src/modules/sport/SportTest.cpp
src/modules/videoGame/VideoGameTest.cpp
src/modules/medicine/MedicineTest.cpp
)

add_library(${LIBRARY_NAME} ${FAKER_SOURCES})

Expand All @@ -77,8 +87,15 @@ target_include_directories(${LIBRARY_NAME}
"${CMAKE_CURRENT_LIST_DIR}/include"
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/include"
${FMT_INCLUDE_DIR}
)

add_subdirectory(externals/fmt)

set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include")

target_link_libraries(${LIBRARY_NAME} PRIVATE fmt)

if (BUILD_FAKER_TESTS)
add_subdirectory(externals/googletest)

Expand All @@ -97,7 +114,7 @@ if (BUILD_FAKER_TESTS)

target_link_libraries(${LIBRARY_NAME}-UT PRIVATE gtest_main gmock_main faker-cxx)

target_include_directories(${LIBRARY_NAME}-UT PRIVATE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(${LIBRARY_NAME}-UT PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR})

add_test(NAME ${LIBRARY_NAME}-UT COMMAND ${LIBRARY_NAME}-UT WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

Expand Down
31 changes: 17 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@ How to contribute
Getting Started
---------------

- Pick a feature from the [TODO Features](https://github.com/cieslarmichal/faker-cxx/blob/main/TODO.md) or [Issues](https://github.com/cieslarmichal/faker-cxx/issues). You could also implement your own module/functions.
- If you picked a feature from list, please create an issue for it (so other contributors don't implement the same feature).
- Fork the repository on GitHub
- Pick a feature from the [TODO Features](https://github.com/cieslarmichal/faker-cxx/blob/main/TODO.md)
or [Issues](https://github.com/cieslarmichal/faker-cxx/issues). You could also implement your own module/functions.
- If you picked a feature from list, please create an issue for it (so other contributors don't implement the same
feature).
- Fork the repository on GitHub

Making Changes
--------------

- Create a feature/bug branch from main branch:
- Create a feature/bug branch from main branch:

``git checkout -b feature/feature-name``
Please avoid working directly on the ``main`` branch.
- Make commits of logical units.
- Make sure you have added the necessary tests for your changes.
- Run *all* the tests to assure nothing else was accidentally broken.
``git checkout -b feature/feature-name``

Please avoid working directly on the ``main`` branch.
- Make commits of logical units.
- Make sure you have added the necessary tests for your changes.
- Run *all* the tests to assure nothing else was accidentally broken.

Submitting Changes
------------------

- Push your changes to the branch in your fork of the repository.
- Submit a pull request to the repository.
- Format code with ``clang-format src/**/*.cpp src/**/*.h include/**/*.h -i -style=file``
- Push your changes to the branch in your fork of the repository.
- Submit a pull request to the repository.

Additional Resources
====================

- If you have any questions about features you can join [Discord Channel](https://discord.com/invite/h2ur8H6mK6).
- Features implementations in [Faker.js](https://github.com/faker-js/faker) could be helpful as a reference.
- If you have any questions about features you can join [Discord Channel](https://discord.com/invite/h2ur8H6mK6).
- Features implementations in [Faker.js](https://github.com/faker-js/faker) could be helpful as a reference.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<h1>C++ Faker</h1>

[![clang](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-clang-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-clang-build.yml?query=branch%3Amain)
[![clang++](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-clang-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-clang-build.yml?query=branch%3Amain)
[![apple clang++](https://github.com/cieslarmichal/faker-cxx/actions/workflows/macos-clang-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/macos-clang-build.yml?query=branch%3Amain)
[![g++](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-gxx-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/linux-gxx-build.yml?query=branch%3Amain)
[![msvc](https://github.com/cieslarmichal/faker-cxx/actions/workflows/windows-msvc-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/windows-msvc-build.yml?query=branch%3Amain)
[![codecov](https://codecov.io/github/cieslarmichal/faker-cxx/branch/main/graph/badge.svg?token=0RTV4JFH2U)](https://codecov.io/github/cieslarmichal/faker-cxx)
[![GitHub](https://img.shields.io/github/license/cieslarmichal/faker-cxx)](https://github.com/cieslarmichal/faker-cxx/blob/main/LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![Discord Shield](https://img.shields.io/badge/discord-join-blue)](https://discord.gg/h2ur8H6mK6)

C++ Faker is a modern C++20 open-source library for generating fake data for testing and development.

The library is heavily inspired by [Faker.js](https://github.com/faker-js/faker).

Dependencies: GTest for building library tests (can be disabled by setting CMake flag BUILD_FAKER_TESTS=OFF)
Dependencies:
- GTest: building library tests (can be disabled by setting CMake flag BUILD_FAKER_TESTS=OFF)
- fmt: formatting

## 🎯 Goal

Expand Down Expand Up @@ -59,6 +61,7 @@ int main()
- [MSVC➚](https://en.wikipedia.org/wiki/Microsoft_Visual_Studio) version 143 or newer.
- [GCC➚](https://gcc.gnu.org/) version 13 or newer.
- [Clang➚](https://clang.llvm.org/) version 16 or newer.
- [Apple Clang➚](https://clang.llvm.org/) version 16 or newer.

### [CMake](https://cmake.org/) version 3.22 or newer

Expand Down
1 change: 1 addition & 0 deletions externals/fmt
Submodule fmt added at f76603
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();

/**
* @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();
};
}
12 changes: 12 additions & 0 deletions include/faker-cxx/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,17 @@ class Color
*/
static std::string hex(HexCasing casing = HexCasing::Lower, HexPrefix prefix = HexPrefix::Hash,
bool includeAlpha = false);

/**
* @brief Returns an HSL color.
*
* @param includeAlpha Adds an alpha value to the color (HSLA). Defaults to `false`.
* @returns HSL color formatted with hsl(X,X,X) or hsla(X,X,X,X).
* @code
* Color::hsl() // "hsl(0, 20, 100)"
* Color::hsl(true) // "hsla(0, 0, 100, 0.50)"
* @endcode
*/
static std::string hsl(bool includeAlpha = false);
};
}
Loading

0 comments on commit f49a53a

Please sign in to comment.