Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yakupcemilk committed Nov 11, 2023
2 parents 983885f + f0a0c4a commit d31daac
Show file tree
Hide file tree
Showing 143 changed files with 12,983 additions and 713 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@16/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@16/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
41 changes: 34 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES)
option(BUILD_FAKER_TESTS DEFAULT ON)

if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /permissive-")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /permissive- /bigobj")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wconversion -Wformat -Werror")
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 @@ -35,14 +36,24 @@ set(FAKER_SOURCES
src/common/StringHelper.cpp
src/modules/phone/Phone.cpp
src/common/LuhnCheck.cpp
src/common/mappers/PrecisionMapper.cpp
src/common/mappers/precisionMapper/PrecisionMapper.cpp
src/modules/system/System.cpp
src/modules/database/Database.cpp
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
src/modules/weather/Weather.cpp
src/common/WeatherHelper.cpp
src/modules/airline/Airline.cpp
src/modules/image/Image.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 @@ -61,12 +72,21 @@ set(FAKER_UT_SOURCES
src/modules/phone/PhoneTest.cpp
src/modules/helper/HelperTest.cpp
src/common/LuhnCheckTest.cpp
src/common/mappers/PrecisionMapperTest.cpp
src/common/mappers/precisionMapper/PrecisionMapperTest.cpp
src/modules/system/SystemTest.cpp
src/modules/database/DatabaseTest.cpp
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
src/modules/weather/WeatherTest.cpp
src/common/WeatherHelperTest.cpp
src/modules/airline/AirlineTest.cpp
src/modules/image/ImageTest.cpp
)

add_library(${LIBRARY_NAME} ${FAKER_SOURCES})

Expand All @@ -75,7 +95,14 @@ 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 @@ -95,7 +122,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.
84 changes: 51 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<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 tests (BUILD_FAKER_TESTS=OFF CMake flag to disable)
- fmt

## 🎯 Goal

My goal is to provide a library like [Faker.js](https://github.com/faker-js/faker) for C++ developers.

## Example

Lets dive into some simple example of generating fake data
Lets see some simple example of generating fake data

```cpp
#include <format>
Expand Down Expand Up @@ -52,18 +54,21 @@ int main()
}
```

## Requirements

### Compiler Support

## Compiler support
- [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

## Consuming library with CMake
## Consuming library with CMake (CMake version 3.22 or newer)

1. Add faker to git submodules (execute in project root):
```
mkdir externals
cd externals
git submodule add https://github.com/cieslarmichal/faker-cxx.git
```
2. Link with library:
```cmake
set(BUILD_FAKER_TESTS OFF)
Expand All @@ -76,26 +81,39 @@ target_link_libraries(main faker-cxx)

## 💎 Modules

- 🌐 Internet - Generate emails, usernames, passwords, images urls
- 🌍 Location - Generate countries, cities, zip codes, street addresses
- 🧑 Person - Generate first, last names, job titles, genders, sex
- 📞 Phone - Generate phone number, IMEI
- 🛒 Commerce - Generate commerce department, product name, sku, price
- 📅 Date - Generate past, future dates
- 🏦 Finance - Generate currency, IBAN, BIC, account name, account number, pin, credit card numbers
- 🏢 Company - Generate company name, type, industry, catch phrase, buzz phrase
- 🔢 Number - Generate random integers, floating point numbers
- ✍ Word - Generate sample words, nouns, verbs etc
- 🎨 Color - Generate color names, rgb, hex
- 📖 Book - Generate book title, genre, author, publisher, ISBN
- 📚 Lorem - Generate lorem words, sentences, paragraphs
- 🔢 String - Generate uuids, alphanumeric, numeric, hexadecimal
- 💻 System - Generate file paths, file extensions, file names, directories, semantic version
- Database - Generate column names, column types, database engines
- 🎶 Music - Generate artists, song names, genres
- 🎥 Movie - Generate actors, actresses, genres, movie titles

### 🔨 [TODO Modules](https://github.com/cieslarmichal/faker-cxx/blob/main/TODO.md)
- 🛩 Airline - aircraft types, airlines, airports, flight numbers
- 🐼 Animal - animal types and species
- 📖 Book - book title, genre, author, publisher, ISBN
- 🎨 Color - color names, rgb, hex, hcl
- 🛒 Commerce - commerce department, product name, sku, price
- 🏢 Company - company name, type, industry, catch phrase, buzz phrase
- 💾 Database - column names, column types, database engines
- ℹ️ Datatype - booleans
- 📅 Date - past, future dates
- 🏦 Finance - currency, IBAN, BIC, account name, account number, pin, credit card numbers
- 📁 Git - branch names, commit messages, commit hash
- 👨‍💻 Hacker - hacker words
- ✋ Helper - random element from container
- 🌐 Internet - emails, usernames, passwords, IP, HTTP
- 🖼️ Image - images urls, github avatar urls, image dimensions
- 🌍 Location - countries, cities, zip codes, street addresses
- 📚 Lorem - lorem words, sentences, paragraphs
- 🏥 Medicine - conditions, medical tests, specialties
- 🎥 Movie - actors, actresses, genres, movie titles
- 🎶 Music - artists, song names, genres
- 🔢 Number - random integers, floating point numbers
- 🧑 Person - first, last names, job titles, hobby, genders, sex, nationalitiy, language
- 📞 Phone - phone number, IMEI
- ⚽ Sport - sport names, athletes, events
- 🔢 String - uuids, alphanumeric, numeric, hexadecimal
- 💻 System - file paths, file extensions, file names, directories, semantic version
- 🎮 Video game - title, genre, platform, studio
- 🌤️ Weather - temperature, pressure, humidity, weather description
- 💬 Word - sample words, nouns, verbs

## 📖 Documentation

https://cieslarmichal.github.io/faker-cxx/

## ✨ Contributing

Expand All @@ -107,7 +125,7 @@ Please check [CONTRIBUTING](https://github.com/cieslarmichal/faker-cxx/blob/main

<br />

## Building from sources with Clang 16
## 🔨 Building from sources with Clang 16

#### 1. Install Clang 16

Expand Down Expand Up @@ -138,7 +156,7 @@ cd build
cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/clang++-16
```

#### 4. Build 🔨
#### 4. Build

```
make
Expand Down
13 changes: 0 additions & 13 deletions TODO.md

This file was deleted.

1 change: 1 addition & 0 deletions externals/fmt
Submodule fmt added at f76603
Loading

0 comments on commit d31daac

Please sign in to comment.