Skip to content

Commit

Permalink
Merge branch 'cieslarmichal:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wsekta authored Nov 28, 2023
2 parents 842ac11 + 657370b commit 9267fe3
Show file tree
Hide file tree
Showing 58 changed files with 3,449 additions and 120 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [cieslarmichal]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ build-linux-gxx
build-linux-clang
#clangd index files
.cache/
#vim swap files
*.sw?
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ set(FAKER_SOURCES
src/modules/weather/Weather.cpp
src/common/WeatherHelper.cpp
src/modules/airline/Airline.cpp
src/modules/image/Image.cpp)
src/modules/image/Image.cpp
src/modules/crypto/Crypto.cpp)

set(FAKER_UT_SOURCES
src/modules/animal/AnimalTest.cpp
Expand Down Expand Up @@ -91,7 +92,8 @@ set(FAKER_UT_SOURCES
src/modules/weather/WeatherTest.cpp
src/common/WeatherHelperTest.cpp
src/modules/airline/AirlineTest.cpp
src/modules/image/ImageTest.cpp)
src/modules/image/ImageTest.cpp
src/modules/crypto/CryptoTest.cpp)

add_library(${LIBRARY_NAME} ${FAKER_SOURCES})

Expand Down
49 changes: 49 additions & 0 deletions ExternalLicenses.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
External repositories licenses:

1. flexxxxer/md5_hash:

MIT License

Copyright (c) 2019 Alexandr

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2. System-Glitch/SHA256:

MIT License

Copyright (c) 2021 Jérémy LAMBERT (SystemGlitch)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
151 changes: 63 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h1>C++ Faker</h1>
<div align="center">
<img src="./docs/public/logo.png" width="250" alt="C++ Faker, a powerful tool for generating realistic and randomized fake data in C++ programming, enhancing data testing and development workflows"/>
<h1>Faker C++</h1>
<p>Generate fake (but realistic) data for testing and development.</p>

[![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)
Expand All @@ -7,79 +10,46 @@
[![mingw](https://github.com/cieslarmichal/faker-cxx/actions/workflows/windows-mingw-build.yml/badge.svg?branch=main)](https://github.com/cieslarmichal/faker-cxx/actions/workflows/windows-mingw-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)
[![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: building tests (BUILD_FAKER_TESTS=OFF CMake flag to disable)
- fmt
[![Chat on Discord](https://img.shields.io/badge/chat-discord-blue?style=flat&logo=discord)](https://discord.gg/h2ur8H6mK6)
</div>

## 🎯 Goal

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

## Example

Lets see some simple example of generating fake data
## Usage

```cpp
#include <format>
#include <iostream>

#include "faker-cxx/Datatype.h"
#include "faker-cxx/Date.h"
#include "faker-cxx/Internet.h"
#include "faker-cxx/Location.h"
#include "faker-cxx/String.h"

int main()
{
const auto id = faker::String::uuid(); // 6fdb588e-0be9-480e-9eeb-8ff11b8afc00
const auto email = faker::Internet::email(); // [email protected]
const auto password = faker::Internet::password(); // 91gZxLB*TfhAA!G
const auto nickname = faker::Internet::username(); // Stuart_Boyle
const auto active = faker::Datatype::boolean(); // true
const auto emailVerified = faker::Datatype::boolean(); // false
const auto verificationCode = faker::String::numeric(8); // 56910620
const auto createdAt = faker::Date::pastDate(); // 2023-03-11T08:33:34Z
const auto updatedAt = faker::Date::recentDate(); // 2023-07-19T22:59:19Z

std::cout << std::format("id: {}, email: {}, password: {}, nickname: {}, active: {}, emailVerified: {}. "
"verificationCode: {}, createdAt: {}, updatedAt: {}",
id, email, password, nickname, active, emailVerified, verificationCode, createdAt,
updatedAt);
const auto id = faker::String::uuid();
const auto email = faker::Internet::email();
const auto password = faker::Internet::password();
const auto verificationCode = faker::String::numeric(8);
const auto createdAt = faker::Date::pastDate();
const auto city = faker::Location::city();
const auto streetAddress = faker::Location::streetAddress();

std::cout << id << std::endl; // 58018063-ce5a-4fa7-adfd-327eb2e2d9a5
std::cout << email << std::endl; // [email protected]
std::cout << password << std::endl; // @cWLwgM#Knalxeb
std::cout << verificationCode << std::endl; // 31457428
std::cout << createdAt << std::endl; // 2023-06-20T02:06:36Z
std::cout << city << std::endl; // Sayreville
std::cout << streetAddress << std::endl; // 1716 Harriet Alley

return 0;
}
```

## 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.

## 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)
add_subdirectory(externals/faker-cxx)
add_executable(main Main.cpp)
target_link_libraries(main faker-cxx)
```

## 💎 Modules

- 🛩 Airline - aircraft types, airlines, airports, flight numbers
Expand All @@ -93,7 +63,7 @@ target_link_libraries(main faker-cxx)
- 📅 Date - past, future dates
- 🏦 Finance - currency, IBAN, BIC, account name, account number, pin, credit card numbers
- 🍝 Food - food category, vegetables, fruits, meats, dishes
- 📁 Git - branch names, commit messages, commit hash
- 📁 Git - branch names, commit messages, commit hash
- 👨‍💻 Hacker - hacker words
- ✋ Helper - random element from container
- 🌐 Internet - emails, usernames, passwords, IP, HTTP
Expand All @@ -113,53 +83,58 @@ target_link_libraries(main faker-cxx)
- 🌤️ Weather - temperature, pressure, humidity, weather description
- 💬 Word - sample words, nouns, verbs


## 📖 Documentation

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

## ✨ Contributing

Feel free to join Faker C++ development! 🚀
## Consuming library with CMake (CMake 3.22 or newer)

Please check [CONTRIBUTING](https://github.com/cieslarmichal/faker-cxx/blob/main/CONTRIBUTING.md) guide.
1. Add faker to git submodules (execute in project root):

[Discord Channel](https://discord.gg/h2ur8H6mK6) for contributors.
```
mkdir externals
cd externals
git submodule add https://github.com/cieslarmichal/faker-cxx.git
```
<br />
2. Link with library:
## 🔨 Building from sources with Clang 16
```cmake
set(BUILD_FAKER_TESTS OFF)
add_subdirectory(externals/faker-cxx)
add_executable(main Main.cpp)
target_link_libraries(main faker-cxx)
```
#### 1. Install Clang 16
```
sudo add-apt-repository ppa:trebelnik-stefina/launchpad-getkeys \
&& sudo apt-get update \
&& sudo apt-get install launchpad-getkeys \
&& sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' \
&& sudo launchpad-getkeys \
&& sudo apt-get update -y \
&& sudo apt-get install -y lld-16 ninja-build build-essential libstdc++-13-dev \
clang-16 clang-tools-16 llvm-16 lcov
```
## Compiler support
#### 2. Prepare build directory
- [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.
```
git clone https://github.com/cieslarmichal/faker-cxx.git
cd faker-cxx
git submodule update --init --recursive
mkdir build
cd build
```
## Dependencies
#### 3. CMake setup with Clang 16
- GTest (```BUILD_FAKER_TESTS=OFF``` CMake flag to disable)
- fmt
```
cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/clang++-16
```
#### 4. Build
## ✨ Contributing
```
make
```
Feel free to join Faker C++ development! 🚀
Please check [CONTRIBUTING](https://github.com/cieslarmichal/faker-cxx/blob/main/CONTRIBUTING.md) guide.
[Discord Channel](https://discord.gg/h2ur8H6mK6) for contributors.
## 📝 Compilation guides
- [Clang++](./docs/clang++_compilation_guide.md)
- [Apple Clang++](./docs/apple_clang++_compilation_guide.md)
13 changes: 13 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
comment: no # do not comment PR with the result

coverage:
range: 50..90 # coverage lower than 50 is red, higher than 90 green, between color code

status:
project: # settings affecting project coverage
default:
target: auto # auto % coverage target
threshold: 5% # allow for 5% reduction of coverage without failing

# do not run coverage on patch nor changes
patch: false
68 changes: 68 additions & 0 deletions docs/apple_clang++_compilation_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

# Building from Sources with Clang 16 on macOS

This guide provides instructions on how to build from sources using Clang 16 on a macOS system.

## 1. Install Clang 16

Clang is part of the LLVM project and can be installed on macOS using Homebrew, a popular package manager.

First, ensure you have Homebrew installed. If not, install Homebrew by running the following in the Terminal:

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

Then, install LLVM (which includes Clang) with:

```bash
brew install llvm@16
```

## 2. Prepare Build Directory

Clone the desired repository and set up the build environment:

```bash
git clone https://github.com/cieslarmichal/faker-cxx.git
cd faker-cxx
git submodule update --init --recursive
mkdir build
cd build
```

## 3. CMake Setup with Clang 16

Before proceeding, ensure CMake is installed. If not, install it using Homebrew:

```bash
brew install cmake
```

Then, set up CMake for building with Clang 16:

```bash
cmake .. -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm@16/bin/clang++
```

⚠️ **Warning:** Ensure that the path `/opt/homebrew/opt/llvm@16/bin/clang++` is valid on your system. If this path is not correct, replace it with the correct path to your Clang 16 compiler. You can find the correct path by using the command `brew --prefix llvm@16`. Adjust the CMake command accordingly.

## 4. Build

Finally, build the project:

```bash
make
```

## 5. Run

After building, you can run the built executable:

```bash
./faker-cxx-UT
```

---

**Note:** This guide assumes a standard installation of Homebrew and the default paths it uses. If your Homebrew or LLVM installation paths are different, you will need to adjust the commands accordingly. Remember that paths and specific commands might vary depending on your system configuration and the versions of the tools installed.
Loading

0 comments on commit 9267fe3

Please sign in to comment.