Skip to content

C++ Faker library for generating fake (but realistic) data for testing and development.

License

Notifications You must be signed in to change notification settings

MichaelLog1/faker-cxx

 
 

Repository files navigation

C++ Faker, a powerful tool for generating realistic and randomized fake data in C++ programming, enhancing data testing and development workflows

Faker C++

Generate fake (but realistic) data for testing and development.

clang++ apple clang++ g++ msvc codecov PRs Welcome Chat on Discord

🎯 Goal

Goal of the Faker C++ is to provide a library like Faker.js for C++ community.

Usage

#include <iostream>

#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();
    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;
}

💎 Modules

  • 🛩 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
  • 🖥️ Computer - type, manufacturer, model, CPU info, GPU info
  • 💾 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
  • 🍝 Food - food category, vegetables, fruits, meats, dishes
  • 📁 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/

Consuming library with CMake (CMake 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
    git submodule update --init --recursive
    
  2. Link with library:

    set(BUILD_FAKER_TESTS OFF)
    
    add_subdirectory(externals/faker-cxx)
    
    add_executable(main Main.cpp)
    
    target_link_libraries(main faker-cxx)

Compiler support

Dependencies

  • GTest (BUILD_FAKER_TESTS=OFF CMake flag to disable)
  • fmt (only for Apple Clang++ compiler)

✨ Contributing

Feel free to join Faker C++ development! 🚀

Please check CONTRIBUTING guide.

Discord Channel for contributors.

📝 Compilation guides

About

C++ Faker library for generating fake (but realistic) data for testing and development.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.2%
  • Other 0.8%