Skip to content

C++ Faker library that generates fake data for you.

License

Notifications You must be signed in to change notification settings

mdkhani/faker-cxx

 
 

Repository files navigation

C++ Faker

build and test codecov CodeFactor GitHub PRs Welcome Discord Shield

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: GTest for building library tests (can be disabled by setting CMake flag BUILD_TESTS=OFF)

🎯 Goal

My goal is to provide a library like Faker.js for C++ developers.

Example

Lets dive into some simple example of generating fake data

#include <format>
#include <iostream>
#include "faker-cxx/Internet.h"
#include "faker-cxx/String.h"
#include "faker-cxx/Date.h"

int main()
{
    const auto id = faker::String::uuid();
    const auto email = faker::Internet::email();
    const auto password = faker::Internet::password();
    const auto createdAt = faker::Date::pastDate();
    const auto updatedAt = faker::Date::recentDate();

    std::cout << std::format("id: {}, email: {}, password: {}, createdAt: {}, updatedAt: {}", id, email, password,
                             createdAt, updatedAt);

    return 0;
}

Consuming library with CMake

add_subdirectory(third_party/faker-cxx)

add_executable(main main.cpp)

target_link_libraries(main faker-cxx)

💎 Modules

  • 🌐 Internet - Generate emails, usernames and passwords.
  • 🧑 Person - Generate first, last names, job titles, genders, sex.
  • 🛒 Commerce - Generate commerce department, product name, sku, price.
  • 📅 Date - Generate past, future dates.
  • 🏦 Finance - Generate currency, IBAN, BIC, account name, account number, pin.
  • 🏢 Company - Generate company name.
  • 🔢 Number - Generate random integers, floating point numbers.
  • 🎨 Color - Generate color names, rgb, hex.
  • ℹ️ Datatype - Generate booleans.
  • 📚 Lorem - Generate lorem text.
  • 🔢 String - Generate uuids, alphanumeric, numberic, hexadecimal.

✨ Contributing

Feel free to join Faker C++ development! 🚀

Please check CONTRIBUTING guide.

Discord Channel for contributors.

About

C++ Faker library that generates fake data for you.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 81.0%
  • CMake 19.0%