Skip to content

Commit

Permalink
Merge branch 'main' into feature/issue-#251
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal authored Nov 23, 2023
2 parents cb9d00e + 111f95b commit fdd31ff
Show file tree
Hide file tree
Showing 26 changed files with 1,017 additions and 101 deletions.
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?
9 changes: 8 additions & 1 deletion include/faker-cxx/Internet.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ enum class IPv4Class
C
};

struct PasswordOptions {
bool upperLetters = true;
bool lowerLetters = true;
bool numbers = true;
bool symbols = true;
};

class Internet
{
public:
Expand Down Expand Up @@ -100,7 +107,7 @@ class Internet
* Internet::password(25) // "xv8vDu*wM!Rg0$zd0kH%8p!WY"
* @endcode
*/
static std::string password(int length = 15);
static std::string password(int length = 15, PasswordOptions options = {});

/**
* @brief Returns a random emoji.
Expand Down
34 changes: 33 additions & 1 deletion include/faker-cxx/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ std::string generateAtleastString(const GuaranteeMap& guarantee);

class String
{
private:
static std::string generateStringWithGuarantee(GuaranteeMap& guarantee, std::set<char>& targetCharacters,
unsigned int length);

public:
/**
* @brief Generates an Universally Unique Identifier with version 4.
Expand Down Expand Up @@ -232,7 +236,21 @@ class String
* String::binary(8) // "0b01110101"
* @endcode
*/
static std::string binary(GuaranteeMap&& guarantee = {}, unsigned length = 1);
static std::string binary(unsigned length = 1);

/**
* @brief Generates a binary string.
*
* @param guarantee A map specifying char count constraints if any
* @param length The number of digits to generate. Defaults to `1`.
*
* @returns Binary string.
*
* @code
* String::binary({'1',{7,8}}, 8) // "0b11110111"
* @endcode
*/
static std::string binary(GuaranteeMap&& guarantee, unsigned length = 1);

/**
* @brief Generates an octal string.
Expand All @@ -246,5 +264,19 @@ class String
* @endcode
*/
static std::string octal(unsigned length = 1);

/**
* @brief Generates an octal string.
*
* @param guarantee A map specifying char count constraints if any
* @param length The number of digits to generate. Defaults to `1`.
*
* @returns Octal string.
*
* @code
* String::octal({'4',{4,5}}, 8) // "0o42444041"
* @endcode
*/
static std::string octal(GuaranteeMap&& guarantee, unsigned length = 1);
};
}
11 changes: 10 additions & 1 deletion include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ enum class Country
Australia,
Serbia,
Macedonia,
Latvia,
Ireland,
Belarus,
Estonia,
};

const std::vector<Country> countries{
Expand All @@ -56,7 +60,8 @@ const std::vector<Country> countries{
Country::Japan, Country::Portugal, Country::Hungary, Country::Croatia, Country::Greece,
Country::Slovenia, Country::Austria, Country::Switzerland, Country::Belgium, Country::Nederlands,
Country::China, Country::Korea, Country::Canada, Country::Mexico, Country::Argentina,
Country::Australia, Country::Serbia, Country::Macedonia,
Country::Australia, Country::Serbia, Country::Macedonia, Country::Latvia, Country::Ireland,
Country::Belarus, Country::Estonia,
};

inline std::string toString(Country country)
Expand Down Expand Up @@ -100,6 +105,10 @@ inline std::string toString(Country country)
{Country::Australia, "Australia"},
{Country::Serbia, "Serbia"},
{Country::Macedonia, "Macedonia"},
{Country::Latvia, "Latvia"},
{Country::Ireland, "Ireland"},
{Country::Belarus, "Belarus"},
{Country::Estonia, "Estonia"},
};

return countryToStringMapping.at(country);
Expand Down
25 changes: 18 additions & 7 deletions src/modules/internet/Internet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "faker-cxx/String.h"
#include "faker-cxx/Word.h"
#include "fmt/format.h"
#include "../string/data/Characters.h"

namespace faker
{
Expand Down Expand Up @@ -93,16 +94,26 @@ std::string Internet::exampleEmail(std::optional<std::string> firstName, std::op
Helper::arrayElement<std::string>(emailExampleHosts));
}

std::string Internet::password(int length)
std::string Internet::password(int length, PasswordOptions options)
{
const std::string passwordCharacters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~`!@#$%^&*()_-+={[}]|:;\"'<,>.?/";
std::string characters;

std::string password;
if (options.upperLetters) {
characters += faker::upperCharacters;
}
if (options.lowerLetters) {
characters += faker::lowerCharacters;
}
if (options.numbers) {
characters += faker::numericCharacters;
}
if (options.symbols) {
characters += faker::symbolCharacters;
}

for (int i = 0; i < length; i++)
{
password += Helper::arrayElement<char>(passwordCharacters);
std::string password;
for (int i = 0; i < length; ++i) {
password += Helper::arrayElement<char>(characters);
}

return password;
Expand Down
6 changes: 6 additions & 0 deletions src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "data/argentina/ArgentinianPeopleNames.h"
#include "data/australia/AustralianPeopleNames.h"
#include "data/austria/AustrianPeopleNames.h"
#include "data/belarus/BelarusianPeopleNames.h"
#include "data/belgium/BelgianPeopleNames.h"
#include "data/brazil/BrazilianPeopleNames.h"
#include "data/canada/CanadianPeopleNames.h"
Expand All @@ -16,6 +17,7 @@
#include "data/czech/CzechPeopleNames.h"
#include "data/denmark/DanishPeopleNames.h"
#include "data/england/EnglishPeopleNames.h"
#include "data/estonia/EstonianPeopleNames.h"
#include "data/finland/FinnishPeopleNames.h"
#include "data/france/FrenchPeopleNames.h"
#include "data/Gender.h"
Expand All @@ -24,11 +26,13 @@
#include "data/Hobbies.h"
#include "data/hungary/HungarianPeopleNames.h"
#include "data/india/IndianPeopleNames.h"
#include "data/ireland/IrishPeopleNames.h"
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/korea/KoreanPeopleNames.h"
#include "data/Languages.h"
#include "data/latvia/LatvianPeopleNames.h"
#include "data/macedonia/MacedonianPeopleNames.h"
#include "data/mexico/MexicanPeopleNames.h"
#include "data/Nationalities.h"
Expand Down Expand Up @@ -78,6 +82,8 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Canada, canadianPeopleNames}, {Country::Mexico, mexicanPeopleNames},
{Country::Argentina, argentinianPeopleNames}, {Country::Australia, australianPeopleNames},
{Country::Serbia, serbianPeopleNames}, {Country::Macedonia, macedonianPeopleNames},
{Country::Latvia, latvianPeopleNames}, {Country::Ireland, irishPeopleNames},
{Country::Belarus, belarusianPeopleNames}, {Country::Estonia, estonianPeopleNames},
};

std::string middleNameForCountry(Country country, std::optional<Sex> sex);
Expand Down
8 changes: 8 additions & 0 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#include "data/argentina/ArgentinianPeopleNames.h"
#include "data/australia/AustralianPeopleNames.h"
#include "data/austria/AustrianPeopleNames.h"
#include "data/belarus/BelarusianPeopleNames.h"
#include "data/belgium/BelgianPeopleNames.h"
#include "data/canada/CanadianPeopleNames.h"
#include "data/china/ChinesePeopleNames.h"
#include "data/croatia/CroatianPeopleNames.h"
#include "data/czech/CzechPeopleNames.h"
#include "data/denmark/DanishPeopleNames.h"
#include "data/england/EnglishPeopleNames.h"
#include "data/estonia/EstonianPeopleNames.h"
#include "data/finland/FinnishPeopleNames.h"
#include "data/france/FrenchPeopleNames.h"
#include "data/Gender.h"
Expand All @@ -23,11 +25,13 @@
#include "data/Hobbies.h"
#include "data/hungary/HungarianPeopleNames.h"
#include "data/india/IndianPeopleNames.h"
#include "data/ireland/IrishPeopleNames.h"
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/korea/KoreanPeopleNames.h"
#include "data/Languages.h"
#include "data/latvia/LatvianPeopleNames.h"
#include "data/macedonia/MacedonianPeopleNames.h"
#include "data/mexico/MexicanPeopleNames.h"
#include "data/Nationalities.h"
Expand Down Expand Up @@ -78,6 +82,8 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Canada, canadianPeopleNames}, {Country::Mexico, mexicanPeopleNames},
{Country::Argentina, argentinianPeopleNames}, {Country::Australia, australianPeopleNames},
{Country::Serbia, serbianPeopleNames}, {Country::Macedonia, macedonianPeopleNames},
{Country::Latvia, latvianPeopleNames}, {Country::Ireland, irishPeopleNames},
{Country::Belarus, belarusianPeopleNames}, {Country::Estonia, estonianPeopleNames},
};

const std::map<Country, std::string> generatedTestName{
Expand All @@ -100,6 +106,8 @@ const std::map<Country, std::string> generatedTestName{
{Country::Canada, "shouldGenerateCanadianName"}, {Country::Mexico, "shouldGenerateMexicanName"},
{Country::Argentina, "shouldGenerateArgentinianName"}, {Country::Australia, "shouldGenerateAustralianName"},
{Country::Serbia, "shouldGenerateSerbianName"}, {Country::Macedonia, "shouldGenerateMacedonianName"},
{Country::Latvia, "shouldGenerateLatvianName"}, {Country::Ireland, "shouldGenerateIrishName"},
{Country::Belarus, "shouldGenerateBelarusianName"}, {Country::Estonia, "shouldGenerateEstonianName"},
};
}

Expand Down
101 changes: 101 additions & 0 deletions src/modules/person/data/belarus/BelarusianFirstNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> belarusianMalesFirstNames = {
"Sergey", "Andrey", "Aleksandr", "Dmitriy", "Vladimir", "Alexander", "Pavel", "Aleksey",
"Evgeniy", "Dmitry", "Igor", "Nikolay", "Maksim", "Ivan", "Artyom", "Mikhail",
"Alexey", "Ilya", "Oleg", "Viktor", "Roman", "Anton", "Vadim", "Kirill",
"Yuriy", "Maxim", "Evgeny", "Vitaliy", "Egor", "Vladislav", "Konstantin", "Artem",
"Vitaly", "Stanislav", "Ruslan", "Artur", "Valeriy", "Yury", "Vyacheslav", "Gennadiy",
"Anatoliy", "Petr", "Leonid", "Daniil", "Vasily", "Anatoly", "Eduard", "Valentin",
"Gleb", "Danil", "Yaroslav", "Boris", "Timofey", "Matvey", "Stepan", "Bogdan",
"Arseniy", "Mark", "Georgiy", "Timur", "Svyatoslav", "German", "Andrei", "Grigory",
"Fedor", "Sergei", "Kiril", "Nazar", "David", "Ignat", "Alex", "Marat",
"Georgy", "Rodion", "Arkadiy", "Rustam", "Aleks", "Alexandr", "Rostislav", "Albert",
"Sergej", "Semen", "Taras", "Lev", "Philip", "Miroslav", "Robert", "Vsevolod",
"Ales", "Renat", "Filipp", "Edgar", "Vital", "Erik", "Alik", "Andrej",
"Alexandar", "Aleksander", "Aleksandar", "Adam", "Victor", "Edvard", "Ali", "Daniel",
"Arsen", "Dinis", "Martin", "Aleksei", "Iosif", "Emil", "Mihail", "Nikolai",
"Mikola", "Eldar", "Leon", "Arnold", "Ernest", "Vasil", "Murat", "Vitali",
"Nick", "Alexei", "Vladimer", "Eugene", "Aleksej", "Richard", "Kris", "Miron",
"Zhan", "Dmitri", "Stefan", "Aliaksandr", "Samir", "Serge", "Dmitrij", "Rinat",
"Angel", "Sasa", "Dzmitry", "Dominik", "Andre", "Marek", "Petro", "John",
"Serafim", "Milan", "Paul", "Viktar", "Feliks", "Damir", "Arslan", "Felix",
"Tomas", "Tata", "Raman", "Armen", "Rafael", "Valdemar", "Ramil", "Akim",
"Adrian", "Alan", "Ashot", "Andrian", "Sergio", "Karim", "Tom", "Arman",
"Vitalii", "Jack", "Tigran", "Aziz", "Peter", "Oskar", "Dimitry", "Uladzimir",
"Nikolas", "Yanik", "Sem", "Murad", "Illya", "Filip", "Suleyman", "Siarhei",
"Evgeni", "Artiom", "Sam", "Andry", "Vasili", "Dimitriy", "Adel", "Jan",
"Aslan", "Aliaksei", "Patrik", "Romeo", "Elvin", "Anatoli", "Kristian", "Zaur",
"Ismail", "Aram", "Romuald", "Arthur", "Amir", "Sancho", "Andriy", "Shamil",
"George", "Farid", "Antony", "Karl", "Marsel", "Ostap", "Ilyas", "Mustafa",
"Sergiy", "Alfred", "Ahmed", "Bob", "Said", "Simon", "Magomed", "Deni",
"Iliya", "Yurii", "Alen", "Nil", "Jon", "Rafik", "Emin", "Sashko",
"Ruben", "Kamil", "Gevorg", "Ihar", "Aleh", "Slavomir", "Leonard", "Pol",
"Ben", "Ahmet", "Tony", "Di", "Rudolf", "Abram", "Omar", "Dionis",
"Markus", "Chris", "Edward", "Kevin", "Gor", "Michail", "Luka", "Samuil",
"Gabriel", "Bladimir", "Nikolaj", "Ramin", "Natan", "Edvin", "Adolf", "Rasim",
"Sascha", "Antoni", "Raul", "Zurab", "Georg", "James", "Frank", "Andreu",
"Eugen", "Ramiz", "Niko", "Donat", "Papa", "Amin", "Sultan", "Yegor",
"Mir", "Oleksandr", "Fred", "Ahmad", "Mansur", "Alessandro", "Pan", "Pavlo",
"Samvel", "Just", "Anatolii", "Eric", "Makha", "Sergy", "Olexandr", "Ilja",
"Kemal", "Mehmet", "Emir", "Rauf", "Nail", "Pablo", "William", "Musa",
"Ibrahim", "Mohammad", "Ladislav", "Wiktor", "Rashid", "Dani", "Da", "Levon",
"Arif", "Ronald", "Salim", "Aron", "Mohamad", "Vakhtang", "Suren", "Vazgen",
"Anis", "Luis", "Kosta", "Valerii", "Patrick", "Elvis", "Rashad", "Dzhamal",
"Dzianis", "Mikhaylo", "Vardan", "Narek", "Pedro", "Migel", "Irakli", "Alexy",
"Mohammed", "Edgard", "Levan", "Pawel", "Parviz", "Abdul", "Andranik", "Asel",
"Svetoslav", "Dante", "Yunus", "Gospodin", "Arseni", "Wladimir",
};

const std::vector<std::string> belarusianFemalesFirstNames = {
"Olga", "Tatyana", "Ekaterina", "Natalya", "Elena", "Anastasiya", "Irina", "Svetlana",
"Anna", "Marina", "Darya", "Denis", "Viktoriya", "Mariya", "Yuliya", "Kristina",
"Anastasia", "Nikita", "Alina", "Veronika", "Lyudmila", "Yulia", "Nadezhda", "Viktoria",
"Anya", "Alyona", "Aleksandra", "Elizaveta", "Yana", "Diana", "Valentina", "Galina",
"Kseniya", "Inna", "Valeriya", "Polina", "Karina", "Maria", "Oksana", "Oxana",
"Margarita", "Alexandra", "Alla", "Evgeniya", "Angelina", "Sasha", "Alena", "Lyubov",
"Zhanna", "Larisa", "Olesya", "Nina", "Tamara", "Vera", "Zhenya", "Ksenia",
"Valeria", "Evgenia", "Natalia", "Anzhelika", "Nataliya", "Nika", "Arina", "Ulyana",
"Valery", "Snezhana", "Violetta", "Danila", "Anzhela", "Ilona", "Yan", "Alisa",
"Antonina", "Milana", "Inga", "Vladislava", "Marta", "Lilia", "Karolina", "Sofiya",
"Liliya", "Sanya", "Dina", "Kira", "Zoya", "Lidiya", "Inessa", "Raisa",
"Yanina", "Lina", "Varvara", "Zinaida", "Elvira", "Sofya", "Mayya", "Yuliana",
"Darina", "Mila", "Eva", "Lidia", "Dana", "Vasilisa", "Albina", "Milena",
"Lilya", "Asya", "Lika", "Sofia", "Nelli", "Regina", "Lana", "Lolita",
"Vitalina", "Sashka", "Zlata", "Evelina", "Sabina", "Julia", "Elina", "Marianna",
"Renata", "Liana", "Yulianna", "Rimma", "Inka", "Vasilina", "Ruslana", "Kate",
"Anita", "Tina", "Tatiana", "Emma", "Zarina", "Daria", "Miroslava", "Lada",
"Lora", "Alevtina", "Ilonka", "Irena", "Eleonora", "Taisa", "Nadka", "Sandra",
"Yaroslava", "Roza", "Maryana", "Victoria", "Taisia", "Erika", "Veta", "Agata",
"Dominika", "Rina", "Ann", "Katrina", "Faina", "Viola", "Mira", "Anfisa",
"Liya", "Natallia", "Vitaliya", "Dinara", "Kamilla", "Vitalia", "Mari", "Tatsiana",
"Verka", "Leyla", "Elmira", "Danuta", "Emiliya", "Tereza", "Lia", "Emilia",
"Stella", "Helen", "Sabrina", "Dayana", "Amina", "Maya", "Dariya", "Tania",
"Nonna", "Dinka", "Violeta", "Stanislava", "Lara", "Dan", "Luiza", "Kamila",
"Klavdiya", "Nastia", "Mary", "Ludmila", "Alesia", "Katarina", "Ninel", "Nadin",
"Malvina", "Yulian", "Katia", "Adelina", "Elka", "Rada", "Ariana", "Gulnara",
"Syuzanna", "Aksana", "Karen", "Teresa", "Liliana", "Ivanna", "Ada", "Bella",
"Elza", "Alexa", "Meri", "Linda", "Anuta", "Iya", "Tonka", "Laura",
"Kim", "Nadia", "Marika", "Lisa", "Christina", "Maryan", "Izabella", "Yuri",
"Nikola", "Ariadna", "Daniela", "Hanna", "Glafira", "Monika", "Ina", "Lili",
"Valeri", "Ilia", "Vanda", "Snezhanka", "Ana", "Iryna", "Sara", "Alisha",
"Fatima", "Elen", "Danka", "Ivona", "Nataly", "Anet", "Sana", "Anika",
"Adriana", "Madina", "Nona", "Edita", "Helena", "Aida", "Mishel", "Zena",
"Bogdana", "Aleksandrina", "Elizabet", "Samira", "Pavlina", "Ganna", "Irma", "Slavka",
"Elizabeth", "Eliza", "Darinka", "Ania", "Stefaniya", "Nelya", "Beata", "Ani",
"Jane", "Venera", "Veronica", "Sania", "Angelika", "Katy", "Sima", "Mariyka",
"Tanja", "Stefania", "Sava", "Ioanna", "Alice", "Pavla", "Nella", "Vania",
"Yanis", "Li", "Tatjana", "Annet", "Mama", "Gala", "Klara", "Sacha",
"Vanessa", "Kati", "Natalie", "Mariana", "Nana", "Nadzeya", "Ya", "Islam",
"Radmila", "Ayna", "Nila", "Tamila", "Roksana", "Katja", "Petra", "Dennis",
"Mika", "Beronika", "Arianna", "Angela", "Helga", "Verona", "Zara", "Viktoryia",
"Elis", "Victoriya", "Jana", "Alexandrina", "Mariam", "Liudmila", "Tinka", "Juli",
"Lyubka", "Dunya", "Emili", "Amira", "Dara", "Roxana", "Tana", "Anastacia",
"Barbara", "Maryna", "Lady", "Aliona", "Halina", "Nelly",
};
}
Loading

0 comments on commit fdd31ff

Please sign in to comment.