From 7b6d55b2caf65b25d7e81d2440e30ad1b142d3f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blar?= Date: Tue, 12 Sep 2023 23:29:03 +0100 Subject: [PATCH] remove too complex api in number class (#92) --- include/faker-cxx/Number.h | 257 ------- include/faker-cxx/types/Language.h | 11 +- src/modules/location/LocationTest.cpp | 4 +- .../data/russia/RussiaAddressFormat.h | 3 +- .../location/data/russia/RussiaCities.h | 642 +++++++++--------- .../data/russia/RussiaStreetPrefixes.h | 5 +- src/modules/number/NumberTest.cpp | 23 - src/modules/person/Person.cpp | 17 +- src/modules/person/PersonTest.cpp | 19 +- .../data/russian/RussianFirstNamesFemales.h | 125 +--- .../data/russian/RussianFirstNamesMales.h | 226 +----- 11 files changed, 392 insertions(+), 940 deletions(-) diff --git a/include/faker-cxx/Number.h b/include/faker-cxx/Number.h index 554f82b2a..55e2ce086 100644 --- a/include/faker-cxx/Number.h +++ b/include/faker-cxx/Number.h @@ -12,94 +12,6 @@ namespace faker { -/** - * @brief A concept that checks if a type is a valid distribution. - * - * The concept enforces a good number of the requirements specified for a RandomNumberDistribution in the C++ standard - * library. We check that the provided distribution has all the necessary member functions and nested types, and that it - * is equality comparable, copy constructible and copy assignable. - * - * This provides compile-time guarantees that the distribution is valid and can be used with the Number module. - * - * @see https://en.cppreference.com/w/cpp/named_req/RandomNumberDistribution - * @tparam DISTRIBUTION a distribution type, such as std::uniform_int_distribution. - */ -template -concept Distribution = - requires { - // check that the result of the distribution is the same as the result of the operator() - // also checks for existence of the result_type and param_type nested types, as well as the operator() - requires std::is_same_v()(std::declval()))>; - - // check that the distribution has a min(), max() and reset() member functions - { - std::declval().min() - } -> std::same_as; - { - std::declval().max() - } -> std::same_as; - { - std::declval().reset() - } -> std::same_as; - - // check that the distribution is equality comparable, copy constructible and copy assignable - { - std::equality_comparable - }; - { - std::is_copy_constructible_v - }; - { - std::is_copy_assignable_v - }; - // check that the parameter type is equality comparable, copy constructible and copy assignable - { - std::equality_comparable - }; - { - std::is_copy_constructible_v - }; - { - std::is_copy_assignable_v - }; - - // Check that the distribution has a param() -> param_type - // and param(const param_type&) member functions - { - std::declval().param() - } -> std::same_as; - { - std::declval().param(std::declval()) - } -> std::same_as; - - // check that D is printable to std::ostream - { - std::declval() << std::declval() - } -> std::same_as; - - // check that D can receive a value from std::istream - { - std::declval() >> std::declval() - } -> std::same_as; - }; - -/** - * @brief A concept that checks if a type is a valid integer distribution. - * - * @tparam DISTRIBUTION a distribution type, must accept integral types as result_type. - */ -template -concept IntegerDistribution = Distribution && std::integral; - -/** - * @brief A concept that checks if a type is a valid decimal distribution. - * - * @tparam DISTRIBUTION a distribution type, must accept floating point types as result_type. - */ -template -concept DecimalDistribution = Distribution && std::floating_point; - class Number { public: @@ -131,9 +43,6 @@ class Number /** * @brief Generates a random integer between 0 and the given maximum value, bounds included. * - * The function invokes the integer(I, I) function with min = 0, hence the distribution used is - * std::uniform_int_distribution. - * * @tparam I the type of the generated number, must be an integral type (int, long, long long, etc.). * @param max the maximum value of the range. * @@ -149,91 +58,10 @@ class Number return Number::integer(static_cast(0), max); } - /** - * @brief Generates a random integer in the given range with a given distribution, bounds included. - * - * Note that for any distribution other than std::uniform_int_distribution, the bounds are enforced - * through a std::clamp call, hence the statistical properties of the distribution may be altered, - * especially for long tailed distributions. - * - * @tparam I the type of the generated number, must be an integral type (int, long, long long, etc.). - * @tparam D the type of the distribution, must be a valid integer distribution (std::uniform_int_distribution, - * std::binomial_distribution, etc.). - * - * @throws std::invalid_argument if min is greater than max. - * - * @param distribution The distribution to use. - * @param min The minimum value of the range. - * @param max The maximum value of the range. - * - * @return I a random integer number. - */ - template - static I integer(D distribution, I min, I max) - { - if constexpr (std::is_same_v>) - { - return Number::integer(min, max); - } - { - if (min > max) - { - throw std::invalid_argument("Minimum value must be smaller than maximum value."); - } - - return std::clamp(distribution(pseudoRandomGenerator), min, max); - } - } - - /** - * @brief Generates a random integer between 0 and the given maximum value with a given distribution, bounds - * included. - * - * Defaults to a min value of 0. - * - * @tparam I The type of the generated number, must be an integral type (int, long, long long, etc.). - * @tparam D The type of the distribution, must be a valid integer distribution (std::uniform_int_distribution, - * std::binomial_distribution, etc.). - * @param distribution The distribution to use. - * @param max The maximum value of the range. - * - * @see IntegerDistribution - * @see integer(D, I, I) - * - * @throws std::invalid_argument if max is smaller than 0. - * - * @return I A random integer number - */ - template - static I integer(D distribution, I max) - { - return Number::integer(distribution, static_cast(0), max); - } - - /** - * @brief Generates a random integer, unbounded, with a given distribution. - * - * @tparam I The type of the generated number, must be an integral type (int, long, long long, etc.). - * @tparam D The type of the distribution, must be a valid integer distribution (std::uniform_int_distribution, - * std::binomial_distribution, etc.). - * - * @param distribution The distribution to use. - * - * @return I A random integer number. - * - */ - template - static I integer(D distribution) - { - return distribution(pseudoRandomGenerator); - } - /** * @brief Generates a random decimal number in the given range, bounds included. * * @tparam F the type of the generated number, must be a floating point type (float, double, long double). - * @tparam D the type of the distribution, must be a valid float distribution (std::uniform_real_distribution, - * std::normal_distribution, etc.). * * @param min The minimum value of the range. * @param max The maximum value of the range. @@ -256,50 +84,9 @@ class Number return distribution(pseudoRandomGenerator); } - /** - * @brief Generates a random decimal number in the given range with a given distribution, bounds included. - * - * Note that for any distribution other than std::uniform_real_distribution, the bounds are enforced - * through a std::clamp call, hence the statistical properties of the distribution may be altered, - * especially for long tailed distributions. - * - * @tparam D the type of the distribution, must be a valid decimal distribution (std::uniform_real_distribution, - * std::normal_distribution, etc.). - * @tparam F the type of the generated number, must be a floating point type (float, double, long double). - * - * @throws std::invalid_argument if min is greater than max. - * - * @see DecimalDistribution - * - * @param distribution The distribution to use. - * @param min The minimum value of the range. - * @param max The maximum value of the range. - * - * @return F a random decimal number. - */ - template - static F decimal(D distribution, F min, F max) - { - if constexpr (std::is_same_v>) - { - return Number::decimal(min, max); - } - { - if (min > max) - { - throw std::invalid_argument("Minimum value must be smaller than maximum value."); - } - - return std::clamp(distribution(pseudoRandomGenerator), min, max); - } - } - /** * @brief Generates a random decimal number between 0 and the given maximum value, bounds included. * - * The function invokes the decimal(F, F) function with min = 0, hence the distribution used is - * std::uniform_real_distribution. - * * @tparam F The type of the generated number, must be a floating point type (float, double, long double). * @param max The maximum value of the range. * @@ -315,50 +102,6 @@ class Number return decimal(static_cast(0.), max); } - /** - * @brief Generates a random decimal number between 0 and the given maximum value with a given distribution, bounds - * included. - * - * @tparam F The type of the generated number, must be a floating point type (float, double, long double). - * @tparam D The type of the distribution, must be a valid float distribution (std::uniform_real_distribution, - * std::normal_distribution, etc.). - * - * @param distribution The distribution to use. - * @param max The maximum value of the range. - * - * @see decimal(D, F, F) - * @see DecimalDistribution - * - * @throws std::invalid_argument if max is less than 0. - * - * @return F a random decimal number. - * - */ - template - static F decimal(D distribution, F max) - { - return Number::decimal(distribution, static_cast(0.), max); - } - - /** - * @brief Generates a random decimal number in the given range, bounds included. - * - * @tparam F the type of the generated number, must be a floating point type (float, double, long double). - * @tparam D the type of the distribution, must be a valid float distribution (std::uniform_real_distribution, - * std::normal_distribution, etc.). - * - * @see DecimalDistribution - * - * @param distribution the distribution to use. - * - * @return F a random decimal number. - */ - template - static F decimal(D distribution) - { - return distribution(pseudoRandomGenerator); - } - /** * @brief Returns a lowercase hexadecimal number. * diff --git a/include/faker-cxx/types/Language.h b/include/faker-cxx/types/Language.h index 6a60f6e78..b666a89e8 100644 --- a/include/faker-cxx/types/Language.h +++ b/include/faker-cxx/types/Language.h @@ -17,13 +17,10 @@ enum class Language inline std::string toString(Language language) { - std::map languageToStringMapping{{Language::English, "English"}, - {Language::Polish, "Polish"}, - {Language::Italian, "Italian"}, - {Language::French, "French"}, - {Language::German, "German"}, - {Language::Russian, "Russian"}, - {Language::Romanian, "Romanian"}}; + std::map languageToStringMapping{ + {Language::English, "English"}, {Language::Polish, "Polish"}, {Language::Italian, "Italian"}, + {Language::French, "French"}, {Language::German, "German"}, {Language::Russian, "Russian"}, + {Language::Romanian, "Romanian"}}; return languageToStringMapping.at(language); } diff --git a/src/modules/location/LocationTest.cpp b/src/modules/location/LocationTest.cpp index 43073bbb7..571482a12 100644 --- a/src/modules/location/LocationTest.cpp +++ b/src/modules/location/LocationTest.cpp @@ -11,12 +11,12 @@ #include "../string/data/Characters.h" #include "data/Countries.h" #include "data/Directions.h" +#include "data/russia/RussiaCities.h" +#include "data/russia/RussiaStreetPrefixes.h" #include "data/States.h" #include "data/TimeZones.h" #include "data/usa/UsaCities.h" #include "data/usa/UsaStreetSuffixes.h" -#include "data/russia/RussiaCities.h" -#include "data/russia/RussiaStreetPrefixes.h" using namespace ::testing; using namespace faker; diff --git a/src/modules/location/data/russia/RussiaAddressFormat.h b/src/modules/location/data/russia/RussiaAddressFormat.h index eb789aef1..4b379334a 100644 --- a/src/modules/location/data/russia/RussiaAddressFormat.h +++ b/src/modules/location/data/russia/RussiaAddressFormat.h @@ -11,6 +11,7 @@ const std::vector russiaBuildingNumberFormats = {"#", "##", "###"}; const std::string russiaZipCodeFormat = "######"; -const std::vector russiaStreetFormats = {"{streetPrefix} {firstName}", "{streetPrefix} {lastName}", "{streetPrefix} {streetName}"}; +const std::vector russiaStreetFormats = {"{streetPrefix} {firstName}", "{streetPrefix} {lastName}", + "{streetPrefix} {streetName}"}; } diff --git a/src/modules/location/data/russia/RussiaCities.h b/src/modules/location/data/russia/RussiaCities.h index 40b74626d..538642bcc 100644 --- a/src/modules/location/data/russia/RussiaCities.h +++ b/src/modules/location/data/russia/RussiaCities.h @@ -6,325 +6,325 @@ namespace faker { const std::vector russiaCities = {"Абакан", -"Азов", -"Александров", -"Алексин", -"Альметьевск", -"Анапа", -"Ангарск", -"Анжеро-Судженск", -"Апатиты", -"Арзамас", -"Армавир", -"Арсеньев", -"Артем", -"Архангельск", -"Асбест", -"Астрахань", -"Ачинск", -"Балаково", -"Балахна", -"Балашиха", -"Балашов", -"Барнаул", -"Батайск", -"Белгород", -"Белебей", -"Белово", -"Белогорск", -"Белорецк", -"Белореченск", -"Бердск", -"Березники", -"Березовский", -"Бийск", -"Биробиджан", -"Благовещенск", -"Бор", -"Борисоглебск", -"Боровичи", -"Братск", -"Брянск", -"Бугульма", -"Буденновск", -"Бузулук", -"Буйнакск", -"Великие", -"Великий", -"Верхняя", -"Видное", -"Владивосток", -"Владикавказ", -"Владимир", -"Волгоград", -"Волгодонск", -"Волжск", -"Волжский", -"Вологда", -"Вольск", -"Воркута", -"Воронеж", -"Воскресенск", -"Воткинск", -"Всеволожск", -"Выборг", -"Выкса", -"Вязьма", -"Гатчина", -"Геленджик", -"Георгиевск", -"Глазов", -"Горно-Алтайск", -"Грозный", -"Губкин", -"Гудермес", -"Гуково", -"Гусь-Хрустальный", -"Дербент", -"Дзержинск", -"Димитровград", -"Дмитров", -"Долгопрудный", -"Домодедово", -"Донской", -"Дубна", -"Евпатория", -"Егорьевск", -"Ейск", -"Екатеринбург", -"Елабуга", -"Елец", -"Ессентуки", -"Железногорск", -"Железногорск", -"Жигулевск", -"Жуковский", -"Заречный", -"Зеленогорск", -"Зеленодольск", -"Златоуст", -"Иваново", -"Ивантеевка", -"Ижевск", -"Избербаш", -"Иркутск", -"Искитим", -"Ишим", -"Ишимбай", -"Йошкар-Ола", -"Казань", -"Калининград", -"Калуга", -"Каменск-Уральский", -"Каменск-Шахтинский", -"Камышин", -"Канск", -"Каспийск", -"Кемерово", -"Керчь", -"Кинешма", -"Кириши", -"Киров", -"Кирово-Чепецк", -"Киселевск", -"Кисловодск", -"Клин", -"Клинцы", -"Ковров", -"Когалым", -"Коломна", -"Комсомольск-на-Амуре", -"Копейск", -"Королев", -"Кострома", -"Котлас", -"Красногорск", -"Краснодар", -"Краснокаменск", -"Краснокамск", -"Краснотурьинск", -"Красноярск", -"Кропоткин", -"Крымск", -"Кстово", -"Кузнецк", -"Кумертау", -"Кунгур", -"Курган", -"Курск", -"Кызыл", -"Лабинск", -"Лениногорск", -"Ленинск-Кузнецкий", -"Лесосибирск", -"Липецк", -"Лиски", -"Лобня", -"Лысьва", -"Лыткарино", -"Люберцы", -"Магадан", -"Магнитогорск", -"Майкоп", -"Махачкала", -"Междуреченск", -"Мелеуз", -"Миасс", -"Минеральные", -"Минусинск", -"Михайловка", -"Михайловск", -"Мичуринск", -"Москва", -"Мурманск", -"Муром", -"Мытищи", -"Набережные", -"Назарово", -"Назрань", -"Нальчик", -"Наро-Фоминск", -"Находка", -"Невинномысск", -"Нерюнгри", -"Нефтекамск", -"Нефтеюганск", -"Нижневартовск", -"Нижнекамск", -"Нижний", -"Нижний", -"Новоалтайск", -"Новокузнецк", -"Новокуйбышевск", -"Новомосковск", -"Новороссийск", -"Новосибирск", -"Новотроицк", -"Новоуральск", -"Новочебоксарск", -"Новочеркасск", -"Новошахтинск", -"Новый", -"Ногинск", -"Норильск", -"Ноябрьск", -"Нягань", -"Обнинск", -"Одинцово", -"Озерск", -"Октябрьский", -"Омск", -"Орел", -"Оренбург", -"Орехово-Зуево", -"Орск", -"Павлово", -"Павловский", -"Пенза", -"Первоуральск", -"Пермь", -"Петрозаводск", -"Петропавловск-Камчатский", -"Подольск", -"Полевской", -"Прокопьевск", -"Прохладный", -"Псков", -"Пушкино", -"Пятигорск", -"Раменское", -"Ревда", -"Реутов", -"Ржев", -"Рославль", -"Россошь", -"Ростов-на-Дону", -"Рубцовск", -"Рыбинск", -"Рязань", -"Салават", -"Сальск", -"Самара", -"Санкт-Петербург", -"Саранск", -"Сарапул", -"Саратов", -"Саров", -"Свободный", -"Севастополь", -"Северодвинск", -"Северск", -"Сергиев", -"Серов", -"Серпухов", -"Сертолово", -"Сибай", -"Симферополь", -"Славянск-на-Кубани", -"Смоленск", -"Соликамск", -"Солнечногорск", -"Сосновый", -"Сочи", -"Ставрополь", -"Старый", -"Стерлитамак", -"Ступино", -"Сургут", -"Сызрань", -"Сыктывкар", -"Таганрог", -"Тамбов", -"Тверь", -"Тимашевск", -"Тихвин", -"Тихорецк", -"Тобольск", -"Тольятти", -"Томск", -"Троицк", -"Туапсе", -"Туймазы", -"Тула", -"Тюмень", -"Узловая", -"Улан-Удэ", -"Ульяновск", -"Урус-Мартан", -"Усолье-Сибирское", -"Уссурийск", -"Усть-Илимск", -"Уфа", -"Ухта", -"Феодосия", -"Фрязино", -"Хабаровск", -"Ханты-Мансийск", -"Хасавюрт", -"Химки", -"Чайковский", -"Чапаевск", -"Чебоксары", -"Челябинск", -"Черемхово", -"Череповец", -"Черкесск", -"Черногорск", -"Чехов", -"Чистополь", -"Чита", -"Шадринск", -"Шали", -"Шахты", -"Шуя", -"Щекино", -"Щелково", -"Электросталь", -"Элиста", -"Энгельс", -"Южно-Сахалинск", -"Юрга", -"Якутск", -"Ялта", -"Ярославль"}; + "Азов", + "Александров", + "Алексин", + "Альметьевск", + "Анапа", + "Ангарск", + "Анжеро-Судженск", + "Апатиты", + "Арзамас", + "Армавир", + "Арсеньев", + "Артем", + "Архангельск", + "Асбест", + "Астрахань", + "Ачинск", + "Балаково", + "Балахна", + "Балашиха", + "Балашов", + "Барнаул", + "Батайск", + "Белгород", + "Белебей", + "Белово", + "Белогорск", + "Белорецк", + "Белореченск", + "Бердск", + "Березники", + "Березовский", + "Бийск", + "Биробиджан", + "Благовещенск", + "Бор", + "Борисоглебск", + "Боровичи", + "Братск", + "Брянск", + "Бугульма", + "Буденновск", + "Бузулук", + "Буйнакск", + "Великие", + "Великий", + "Верхняя", + "Видное", + "Владивосток", + "Владикавказ", + "Владимир", + "Волгоград", + "Волгодонск", + "Волжск", + "Волжский", + "Вологда", + "Вольск", + "Воркута", + "Воронеж", + "Воскресенск", + "Воткинск", + "Всеволожск", + "Выборг", + "Выкса", + "Вязьма", + "Гатчина", + "Геленджик", + "Георгиевск", + "Глазов", + "Горно-Алтайск", + "Грозный", + "Губкин", + "Гудермес", + "Гуково", + "Гусь-Хрустальный", + "Дербент", + "Дзержинск", + "Димитровград", + "Дмитров", + "Долгопрудный", + "Домодедово", + "Донской", + "Дубна", + "Евпатория", + "Егорьевск", + "Ейск", + "Екатеринбург", + "Елабуга", + "Елец", + "Ессентуки", + "Железногорск", + "Железногорск", + "Жигулевск", + "Жуковский", + "Заречный", + "Зеленогорск", + "Зеленодольск", + "Златоуст", + "Иваново", + "Ивантеевка", + "Ижевск", + "Избербаш", + "Иркутск", + "Искитим", + "Ишим", + "Ишимбай", + "Йошкар-Ола", + "Казань", + "Калининград", + "Калуга", + "Каменск-Уральский", + "Каменск-Шахтинский", + "Камышин", + "Канск", + "Каспийск", + "Кемерово", + "Керчь", + "Кинешма", + "Кириши", + "Киров", + "Кирово-Чепецк", + "Киселевск", + "Кисловодск", + "Клин", + "Клинцы", + "Ковров", + "Когалым", + "Коломна", + "Комсомольск-на-Амуре", + "Копейск", + "Королев", + "Кострома", + "Котлас", + "Красногорск", + "Краснодар", + "Краснокаменск", + "Краснокамск", + "Краснотурьинск", + "Красноярск", + "Кропоткин", + "Крымск", + "Кстово", + "Кузнецк", + "Кумертау", + "Кунгур", + "Курган", + "Курск", + "Кызыл", + "Лабинск", + "Лениногорск", + "Ленинск-Кузнецкий", + "Лесосибирск", + "Липецк", + "Лиски", + "Лобня", + "Лысьва", + "Лыткарино", + "Люберцы", + "Магадан", + "Магнитогорск", + "Майкоп", + "Махачкала", + "Междуреченск", + "Мелеуз", + "Миасс", + "Минеральные", + "Минусинск", + "Михайловка", + "Михайловск", + "Мичуринск", + "Москва", + "Мурманск", + "Муром", + "Мытищи", + "Набережные", + "Назарово", + "Назрань", + "Нальчик", + "Наро-Фоминск", + "Находка", + "Невинномысск", + "Нерюнгри", + "Нефтекамск", + "Нефтеюганск", + "Нижневартовск", + "Нижнекамск", + "Нижний", + "Нижний", + "Новоалтайск", + "Новокузнецк", + "Новокуйбышевск", + "Новомосковск", + "Новороссийск", + "Новосибирск", + "Новотроицк", + "Новоуральск", + "Новочебоксарск", + "Новочеркасск", + "Новошахтинск", + "Новый", + "Ногинск", + "Норильск", + "Ноябрьск", + "Нягань", + "Обнинск", + "Одинцово", + "Озерск", + "Октябрьский", + "Омск", + "Орел", + "Оренбург", + "Орехово-Зуево", + "Орск", + "Павлово", + "Павловский", + "Пенза", + "Первоуральск", + "Пермь", + "Петрозаводск", + "Петропавловск-Камчатский", + "Подольск", + "Полевской", + "Прокопьевск", + "Прохладный", + "Псков", + "Пушкино", + "Пятигорск", + "Раменское", + "Ревда", + "Реутов", + "Ржев", + "Рославль", + "Россошь", + "Ростов-на-Дону", + "Рубцовск", + "Рыбинск", + "Рязань", + "Салават", + "Сальск", + "Самара", + "Санкт-Петербург", + "Саранск", + "Сарапул", + "Саратов", + "Саров", + "Свободный", + "Севастополь", + "Северодвинск", + "Северск", + "Сергиев", + "Серов", + "Серпухов", + "Сертолово", + "Сибай", + "Симферополь", + "Славянск-на-Кубани", + "Смоленск", + "Соликамск", + "Солнечногорск", + "Сосновый", + "Сочи", + "Ставрополь", + "Старый", + "Стерлитамак", + "Ступино", + "Сургут", + "Сызрань", + "Сыктывкар", + "Таганрог", + "Тамбов", + "Тверь", + "Тимашевск", + "Тихвин", + "Тихорецк", + "Тобольск", + "Тольятти", + "Томск", + "Троицк", + "Туапсе", + "Туймазы", + "Тула", + "Тюмень", + "Узловая", + "Улан-Удэ", + "Ульяновск", + "Урус-Мартан", + "Усолье-Сибирское", + "Уссурийск", + "Усть-Илимск", + "Уфа", + "Ухта", + "Феодосия", + "Фрязино", + "Хабаровск", + "Ханты-Мансийск", + "Хасавюрт", + "Химки", + "Чайковский", + "Чапаевск", + "Чебоксары", + "Челябинск", + "Черемхово", + "Череповец", + "Черкесск", + "Черногорск", + "Чехов", + "Чистополь", + "Чита", + "Шадринск", + "Шали", + "Шахты", + "Шуя", + "Щекино", + "Щелково", + "Электросталь", + "Элиста", + "Энгельс", + "Южно-Сахалинск", + "Юрга", + "Якутск", + "Ялта", + "Ярославль"}; } diff --git a/src/modules/location/data/russia/RussiaStreetPrefixes.h b/src/modules/location/data/russia/RussiaStreetPrefixes.h index adbe7e006..efbd7c15c 100644 --- a/src/modules/location/data/russia/RussiaStreetPrefixes.h +++ b/src/modules/location/data/russia/RussiaStreetPrefixes.h @@ -5,7 +5,6 @@ namespace faker { -const std::vector russiaStreetPrefixes = { - "улица", "аллея", "бульвар", "линия", "набережная", "тракт", "тупик", "шоссе", "переулок", "проспект", "мост", "авеню" -}; +const std::vector russiaStreetPrefixes = {"улица", "аллея", "бульвар", "линия", "набережная", "тракт", + "тупик", "шоссе", "переулок", "проспект", "мост", "авеню"}; } diff --git a/src/modules/number/NumberTest.cpp b/src/modules/number/NumberTest.cpp index e121225bc..35a2c08a0 100644 --- a/src/modules/number/NumberTest.cpp +++ b/src/modules/number/NumberTest.cpp @@ -1,7 +1,6 @@ #include "faker-cxx/Number.h" #include -#include #include "gtest/gtest.h" @@ -56,30 +55,8 @@ TEST_F(NumberTest, givenRangeWithSameNumberSection_shouldGenerateThisNumberForDe ASSERT_EQ(actualRandomNumber, 2.f); } -TEST_F(NumberTest, givenDiscreteDistribution_shouldGenerateNumberThatIsInGivenRange) -{ - auto dist = std::binomial_distribution(10, 0.5); - - const int actualRandomNumber = Number::integer>(dist, 2, 10); - - ASSERT_TRUE(actualRandomNumber >= 2); - ASSERT_TRUE(actualRandomNumber <= 10); -} - -TEST_F(NumberTest, givenRealDistribution_shouldGenerateNumberThatIsInGivenRange) -{ - auto dist = std::normal_distribution(5.f, 2.f); - - const std::floating_point auto actualRandomNumber = - Number::decimal>(dist, 2.f, 10.f); - - ASSERT_TRUE(actualRandomNumber >= 2.f); - ASSERT_TRUE(actualRandomNumber <= 10.f); -} - TEST_F(NumberTest, HexMethodTest) { - std::string result = Number::hex(); ASSERT_EQ(result.size(), 1); ASSERT_TRUE(std::isxdigit(result[0])); diff --git a/src/modules/person/Person.cpp b/src/modules/person/Person.cpp index 157abcc38..4dc0d48e6 100644 --- a/src/modules/person/Person.cpp +++ b/src/modules/person/Person.cpp @@ -20,13 +20,13 @@ #include "data/polish/PolishFirstNamesFemales.h" #include "data/polish/PolishFirstNamesMales.h" #include "data/polish/PolishLastNames.h" +#include "data/romanian/RomanianFirstNamesFemales.h" +#include "data/romanian/RomanianFirstNamesMales.h" +#include "data/romanian/RomanianLastNames.h" #include "data/russian/RussianFirstNamesFemales.h" #include "data/russian/RussianFirstNamesMales.h" #include "data/russian/RussianLastNamesFemales.h" #include "data/russian/RussianLastNamesMales.h" -#include "data/romanian/RomanianFirstNamesFemales.h" -#include "data/romanian/RomanianFirstNamesMales.h" -#include "data/romanian/RomanianLastNames.h" #include "faker-cxx/Helper.h" namespace faker @@ -95,15 +95,20 @@ std::string Person::lastName(Language language, std::optional sex) std::vector lastNames; - if (sex == Sex::Male) { + if (sex == Sex::Male) + { const auto& lastNamesMales = lastNamesBySexMapping.at(Sex::Male); lastNames.insert(lastNames.end(), lastNamesMales.begin(), lastNamesMales.end()); - } else if (sex == Sex::Female) { + } + else if (sex == Sex::Female) + { const auto& lastNamesFemales = lastNamesBySexMapping.at(Sex::Female); lastNames.insert(lastNames.end(), lastNamesFemales.begin(), lastNamesFemales.end()); - } else { + } + else + { const auto& lastNamesMales = lastNamesBySexMapping.at(Sex::Male); const auto& lastNamesFemales = lastNamesBySexMapping.at(Sex::Female); diff --git a/src/modules/person/PersonTest.cpp b/src/modules/person/PersonTest.cpp index 30b214c86..d5cff2a91 100644 --- a/src/modules/person/PersonTest.cpp +++ b/src/modules/person/PersonTest.cpp @@ -21,13 +21,13 @@ #include "data/polish/PolishFirstNamesFemales.h" #include "data/polish/PolishFirstNamesMales.h" #include "data/polish/PolishLastNames.h" +#include "data/romanian/RomanianFirstNamesFemales.h" +#include "data/romanian/RomanianFirstNamesMales.h" +#include "data/romanian/RomanianLastNames.h" #include "data/russian/RussianFirstNamesFemales.h" #include "data/russian/RussianFirstNamesMales.h" #include "data/russian/RussianLastNamesFemales.h" #include "data/russian/RussianLastNamesMales.h" -#include "data/romanian/RomanianFirstNamesFemales.h" -#include "data/romanian/RomanianFirstNamesMales.h" -#include "data/romanian/RomanianLastNames.h" #include "src/common/StringHelper.h" using namespace ::testing; @@ -39,8 +39,8 @@ const auto malePrefix{"Mr."}; const std::vector femalePrefixes{"Ms.", "Miss"}; const std::vector allPrefixes{"Mr.", "Ms.", "Miss"}; -const std::vector languages{Language::English, Language::French, Language::German, Language::Italian, - Language::Polish, Language::Russian, Language::Romanian}; +const std::vector languages{Language::English, Language::French, Language::German, Language::Italian, + Language::Polish, Language::Russian, Language::Romanian}; const std::map>> languageToFirstNamesMapping{ {Language::English, {{Sex::Male, englishFirstNamesMales}, {Sex::Female, englishFirstNamesFemales}}}, @@ -63,11 +63,10 @@ const std::map>> languageToLast }; const std::map generatedTestName{ - {Language::English, "shouldGenerateEnglishName"}, {Language::French, "shouldGenerateFrenchName"}, - {Language::German, "shouldGenerateGermanName"}, {Language::Italian, "shouldGenerateItalianName"}, - {Language::Polish, "shouldGeneratePolishName"}, {Language::Russian, "shouldGenerateRussianName"}, - {Language::Romanian, "shouldGenerateRomanianName"} -}; + {Language::English, "shouldGenerateEnglishName"}, {Language::French, "shouldGenerateFrenchName"}, + {Language::German, "shouldGenerateGermanName"}, {Language::Italian, "shouldGenerateItalianName"}, + {Language::Polish, "shouldGeneratePolishName"}, {Language::Russian, "shouldGenerateRussianName"}, + {Language::Romanian, "shouldGenerateRomanianName"}}; } class PersonTest : public TestWithParam diff --git a/src/modules/person/data/russian/RussianFirstNamesFemales.h b/src/modules/person/data/russian/RussianFirstNamesFemales.h index e90e34d57..9010aad7d 100644 --- a/src/modules/person/data/russian/RussianFirstNamesFemales.h +++ b/src/modules/person/data/russian/RussianFirstNamesFemales.h @@ -5,114 +5,19 @@ namespace faker { -const std::vector russianFirstNamesFemales = {"Агафья", -"Аглая", -"Агния", -"Агриппина", -"Аза", -"Акулина", -"Алевтина", -"Александра", -"Алина", -"Алиса", -"Алла", -"Анастасия", -"Ангелина", -"Анжела", -"Анжелика", -"Анна", -"Антонина", -"Анфиса", -"Валентина", -"Валерия", -"Варвара", -"Василиса", -"Вера", -"Вероника", -"Виктория", -"Владимира", -"Галина", -"Глафира", -"Гликерия", -"Дана", -"Дарья", -"Евгения", -"Евдокия", -"Евлалия", -"Евлампия", -"Евпраксия", -"Евфросиния", -"Екатерина", -"Елена", -"Елизавета", -"Епистима", -"Ермиония", -"Жанна", -"Зинаида", -"Злата", -"Зоя", -"Инга", -"Инесса", -"Инна", -"Иоанна", -"Ираида", -"Ирина", -"Капитолина", -"Карина", -"Каролина", -"Кира", -"Клавдия", -"Ксения", -"Лада", -"Лариса", -"Лидия", -"Лилия", -"Любовь", -"Людмила", -"Маргарита", -"Марина", -"Мария", -"Марфа", -"Матрёна", -"Милана", -"Милица", -"Мирослава", -"Надежда", -"Наталья", -"Нина", -"Нонна", -"Оксана", -"Октябрина", -"Олимпиада", -"Ольга", -"Павлина", -"Пелагея", -"Пинна", -"Полина", -"Прасковья", -"Рада", -"Раиса", -"Регина", -"Римма", -"Рогнеда", -"Светлана", -"Серафима", -"Снежана", -"София", -"Сусанна", -"Таисия", -"Тамара", -"Татьяна", -"Улита", -"Ульяна", -"Урсула", -"Фаина", -"Феврония", -"Фёкла", -"Феодора", -"Целестина", -"Элеонора", -"Юлия", -"Яна", -"Ярослава"}; +const std::vector russianFirstNamesFemales = { + "Агафья", "Аглая", "Агния", "Агриппина", "Аза", "Акулина", "Алевтина", "Александра", + "Алина", "Алиса", "Алла", "Анастасия", "Ангелина", "Анжела", "Анжелика", "Анна", + "Антонина", "Анфиса", "Валентина", "Валерия", "Варвара", "Василиса", "Вера", "Вероника", + "Виктория", "Владимира", "Галина", "Глафира", "Гликерия", "Дана", "Дарья", "Евгения", + "Евдокия", "Евлалия", "Евлампия", "Евпраксия", "Евфросиния", "Екатерина", "Елена", "Елизавета", + "Епистима", "Ермиония", "Жанна", "Зинаида", "Злата", "Зоя", "Инга", "Инесса", + "Инна", "Иоанна", "Ираида", "Ирина", "Капитолина", "Карина", "Каролина", "Кира", + "Клавдия", "Ксения", "Лада", "Лариса", "Лидия", "Лилия", "Любовь", "Людмила", + "Маргарита", "Марина", "Мария", "Марфа", "Матрёна", "Милана", "Милица", "Мирослава", + "Надежда", "Наталья", "Нина", "Нонна", "Оксана", "Октябрина", "Олимпиада", "Ольга", + "Павлина", "Пелагея", "Пинна", "Полина", "Прасковья", "Рада", "Раиса", "Регина", + "Римма", "Рогнеда", "Светлана", "Серафима", "Снежана", "София", "Сусанна", "Таисия", + "Тамара", "Татьяна", "Улита", "Ульяна", "Урсула", "Фаина", "Феврония", "Фёкла", + "Феодора", "Целестина", "Элеонора", "Юлия", "Яна", "Ярослава"}; } diff --git a/src/modules/person/data/russian/RussianFirstNamesMales.h b/src/modules/person/data/russian/RussianFirstNamesMales.h index e4dfcfe1f..b14909aec 100644 --- a/src/modules/person/data/russian/RussianFirstNamesMales.h +++ b/src/modules/person/data/russian/RussianFirstNamesMales.h @@ -5,204 +5,30 @@ namespace faker { -const std::vector russianFirstNamesMales = {"Авдей", -"Авксентий", -"Агапит", -"Агафон", -"Акакий", -"Акиндин", -"Александр", -"Алексей", -"Альберт", -"Анатолий", -"Андрей", -"Аникий", -"Аникита", -"Антон", -"Антонин", -"Анфим", -"Аристарх", -"Аркадий", -"Арсений", -"Артём", -"Артемий", -"Артур", -"Архипп", -"Афанасий", -"Богдан", -"Борис", -"Вавила", -"Вадим", -"Валентин", -"Валерий", -"Валерьян", -"Варлам", -"Варсонофий", -"Варфоломей", -"Василий", -"Венедикт", -"Вениамин", -"Викентий", -"Виктор", -"Виссарион", -"Виталий", -"Владимир", -"Владислав", -"Владлен", -"Влас", -"Всеволод", -"Вячеслав", -"Гавриил", -"Галактион", -"Геласий", -"Геннадий", -"Георгий", -"Герасим", -"Герман", -"Германн", -"Глеб", -"Гордей", -"Григорий", -"Данакт", -"Даниил", -"Демид", -"Демьян", -"Денис", -"Дмитрий", -"Добрыня", -"Донат", -"Дорофей", -"Евгений", -"Евграф", -"Евдоким", -"Евсей", -"Евстафий", -"Егор", -"Емельян", -"Еремей", -"Ермолай", -"Ерофей", -"Ефим", -"Ефрем", -"Ждан", -"Зиновий", -"Иакинф", -"Иван", -"Игнатий", -"Игорь", -"Изот", -"Илья", -"Иннокентий", -"Ираклий", -"Ириней", -"Исаак", -"Исидор", -"Иуда", -"Иулиан", -"Капитон", -"Ким", -"Кир", -"Кирилл", -"Климент", -"Кондрат", -"Конон", -"Константин", -"Корнилий", -"Кузьма", -"Куприян", -"Лаврентий", -"Лев", -"Леонид", -"Леонтий", -"Логгин", -"Лука", -"Лукий", -"Лукьян", -"Магистриан", -"Макар", -"Максим", -"Мамонт", -"Марк", -"Мартын", -"Матвей", -"Мелентий", -"Мина", -"Мирослав", -"Митрофан", -"Михаил", -"Мстислав", -"Назар", -"Нестор", -"Никандр", -"Никанор", -"Никита", -"Никифор", -"Никодим", -"Николай", -"Никон", -"Олег", -"Онисим", -"Онуфрий", -"Павел", -"Паисий", -"Панкратий", -"Пантелеймон", -"Парфений", -"Пафнутий", -"Пахомий", -"Пётр", -"Платон", -"Поликарп", -"Порфирий", -"Потап", -"Пров", -"Прокопий", -"Протасий", -"Прохор", -"Разумник", -"Родион", -"Роман", -"Ростислав", -"Руслан", -"Савва", -"Савелий", -"Самуил", -"Святополк", -"Святослав", -"Севастьян", -"Семён", -"Серафим", -"Сергей", -"Сила", -"Сильвестр", -"Созон", -"Софрон", -"Спиридон", -"Станислав", -"Степан", -"Тарас", -"Тимофей", -"Тимур", -"Тит", -"Тихон", -"Трифон", -"Трофим", -"Урбан", -"Фаддей", -"Фёдор", -"Федосей", -"Федот", -"Феликс", -"Феоктист", -"Филат", -"Филимон", -"Филипп", -"Фирс", -"Фока", -"Фома", -"Фотий", -"Фрол", -"Харитон", -"Хрисанф", -"Христофор"}; +const std::vector russianFirstNamesMales = { + "Авдей", "Авксентий", "Агапит", "Агафон", "Акакий", "Акиндин", "Александр", "Алексей", + "Альберт", "Анатолий", "Андрей", "Аникий", "Аникита", "Антон", "Антонин", "Анфим", + "Аристарх", "Аркадий", "Арсений", "Артём", "Артемий", "Артур", "Архипп", "Афанасий", + "Богдан", "Борис", "Вавила", "Вадим", "Валентин", "Валерий", "Валерьян", "Варлам", + "Варсонофий", "Варфоломей", "Василий", "Венедикт", "Вениамин", "Викентий", "Виктор", "Виссарион", + "Виталий", "Владимир", "Владислав", "Владлен", "Влас", "Всеволод", "Вячеслав", "Гавриил", + "Галактион", "Геласий", "Геннадий", "Георгий", "Герасим", "Герман", "Германн", "Глеб", + "Гордей", "Григорий", "Данакт", "Даниил", "Демид", "Демьян", "Денис", "Дмитрий", + "Добрыня", "Донат", "Дорофей", "Евгений", "Евграф", "Евдоким", "Евсей", "Евстафий", + "Егор", "Емельян", "Еремей", "Ермолай", "Ерофей", "Ефим", "Ефрем", "Ждан", + "Зиновий", "Иакинф", "Иван", "Игнатий", "Игорь", "Изот", "Илья", "Иннокентий", + "Ираклий", "Ириней", "Исаак", "Исидор", "Иуда", "Иулиан", "Капитон", "Ким", + "Кир", "Кирилл", "Климент", "Кондрат", "Конон", "Константин", "Корнилий", "Кузьма", + "Куприян", "Лаврентий", "Лев", "Леонид", "Леонтий", "Логгин", "Лука", "Лукий", + "Лукьян", "Магистриан", "Макар", "Максим", "Мамонт", "Марк", "Мартын", "Матвей", + "Мелентий", "Мина", "Мирослав", "Митрофан", "Михаил", "Мстислав", "Назар", "Нестор", + "Никандр", "Никанор", "Никита", "Никифор", "Никодим", "Николай", "Никон", "Олег", + "Онисим", "Онуфрий", "Павел", "Паисий", "Панкратий", "Пантелеймон", "Парфений", "Пафнутий", + "Пахомий", "Пётр", "Платон", "Поликарп", "Порфирий", "Потап", "Пров", "Прокопий", + "Протасий", "Прохор", "Разумник", "Родион", "Роман", "Ростислав", "Руслан", "Савва", + "Савелий", "Самуил", "Святополк", "Святослав", "Севастьян", "Семён", "Серафим", "Сергей", + "Сила", "Сильвестр", "Созон", "Софрон", "Спиридон", "Станислав", "Степан", "Тарас", + "Тимофей", "Тимур", "Тит", "Тихон", "Трифон", "Трофим", "Урбан", "Фаддей", + "Фёдор", "Федосей", "Федот", "Феликс", "Феоктист", "Филат", "Филимон", "Филипп", + "Фирс", "Фока", "Фома", "Фотий", "Фрол", "Харитон", "Хрисанф", "Христофор"}; }