C++ Faker library for generating fake (but realistic) data for testing and development.
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.
Dependencies:
My goal is to provide a library like Faker.js for C++ developers.
Lets dive into some simple example of generating fake data
#include <format>
#include <iostream>
#include "faker-cxx/Datatype.h"
#include "faker-cxx/Date.h"
#include "faker-cxx/Internet.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);
return 0;
}
mkdir externals
cd externals
git submodule add https://github.com/cieslarmichal/faker-cxx.git
echo "add_subdirectory(faker-cxx)" > CMakeLists.txt
set(BUILD_FAKER_TESTS OFF)
add_subdirectory(externals/faker-cxx)
add_executable(main Main.cpp)
target_link_libraries(main faker-cxx)
Feel free to join Faker C++ development! π
Please check CONTRIBUTING guide.
Discord Channel for contributors.
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
git clone https://github.com/cieslarmichal/faker-cxx.git
cd faker-cxx
git submodule update --init --recursive
mkdir build
cd build
cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/clang++-16
make