diff --git a/include/faker-cxx/Finance.h b/include/faker-cxx/Finance.h index 11dd66dee..a4f4e4cb6 100644 --- a/include/faker-cxx/Finance.h +++ b/include/faker-cxx/Finance.h @@ -7,18 +7,16 @@ #include "types/Country.h" #include "types/Precision.h" -namespace faker +namespace faker::finance { -struct Currency -{ - std::string_view name; - std::string_view code; - std::string_view symbol; -}; + struct Currency + { + std::string_view name; + std::string_view code; + std::string_view symbol; + }; + -class Finance -{ -public: /** * @brief Returns a random currency. * @@ -28,7 +26,7 @@ class Finance * Finance::currency() // "{"US Dollar","USD","$"}" * @endcode */ - static Currency currency(); + Currency currency(); /** * @brief Returns a random currency name. @@ -39,7 +37,7 @@ class Finance * Finance::currencyName() // "US Dollar" * @endcode */ - static std::string_view currencyName(); + std::string_view currencyName(); /** * @brief Returns a random currency code. @@ -50,7 +48,7 @@ class Finance * Finance::currencyCode() // "USD" * @endcode */ - static std::string_view currencyCode(); + std::string_view currencyCode(); /** * @brief Returns a random currency symbol. @@ -61,7 +59,7 @@ class Finance * Finance::currencySymbol() // "$" * @endcode */ - static std::string_view currencySymbol(); + std::string_view currencySymbol(); /** * @brief Returns a random account type. @@ -72,7 +70,7 @@ class Finance * Finance::accountType() // "Savings" * @endcode */ - static std::string_view accountType(); + std::string_view accountType(); /** * @brief Generates a random amount between the given bounds (inclusive). @@ -91,7 +89,7 @@ class Finance * Finance::amount(5, 10, Precision::TwoDp, "$") // "$5.85" * @endcode */ - static std::string amount(double min = 0, double max = 1000, Precision precision = Precision::TwoDp, + std::string amount(double min = 0, double max = 1000, Precision precision = Precision::TwoDp, const std::string& symbol = ""); enum class IbanCountry @@ -137,7 +135,7 @@ class Finance * Finance::iban(IbanCountry::Poland) // "PL61109010140000071219812874" * @endcode */ - static std::string iban(std::optional country = std::nullopt); + std::string iban(std::optional country = std::nullopt); enum class BicCountry { @@ -165,7 +163,7 @@ class Finance * Finance::bic(BicCountry::Poland) // "BREXPLPWMUL" * @endcode */ - static std::string_view bic(std::optional country = std::nullopt); + std::string_view bic(std::optional country = std::nullopt); /** * Generates a random account number. @@ -179,7 +177,7 @@ class Finance * Finance::accountNumber(26) // "55875455514825927518796290" * @endcode */ - static std::string accountNumber(unsigned length = 8); + std::string accountNumber(unsigned length = 8); /** * Generates a random PIN number. @@ -193,7 +191,7 @@ class Finance * Finance::pin(8) // "21378928" * @endcode */ - static std::string pin(unsigned length = 4); + std::string pin(unsigned length = 4); /** * Generates a random routing number. @@ -204,7 +202,7 @@ class Finance * Finance::routingNumber() // "522814402" * @endcode */ - static std::string routingNumber(); + std::string routingNumber(); enum class CreditCardType { @@ -225,7 +223,7 @@ class Finance * Finance::creditCardNumber() // "4882664999007" * @endcode */ - static std::string creditCardNumber(std::optional creditCardType = std::nullopt); + std::string creditCardNumber(std::optional creditCardType = std::nullopt); /** * Generates a random credit card CVV. @@ -236,7 +234,7 @@ class Finance * Finance::creditCardCvv() // "506" * @endcode */ - static std::string creditCardCvv(); + std::string creditCardCvv(); /** * Generates a random bitcoin address. @@ -247,7 +245,7 @@ class Finance * Finance::bitcoinAddress() // "3ySdvCkTLVy7gKD4j6JfSaf5d" * @endcode */ - static std::string bitcoinAddress(); + std::string bitcoinAddress(); /** * Generates a random litecoin address. @@ -258,7 +256,7 @@ class Finance * Finance::litecoinAddress() // "LoQaSTGWBRXkWfyxKbNKuPrAWGELzcW" * @endcode */ - static std::string litecoinAddress(); + std::string litecoinAddress(); /** * Generates a random ethereum address. @@ -269,7 +267,7 @@ class Finance * Finance::ethereumAddress() // "0xf03dfeecbafc5147241cc4c4ca20b3c9dfd04c4a" * @endcode */ - static std::string ethereumAddress(); + std::string ethereumAddress(); /** * Generates a random expiration date. @@ -280,7 +278,7 @@ class Finance * Finance::creditCardExpirationDate() // "03/26" * @endcode */ - static std::string creditCardExpirationDate(); + std::string creditCardExpirationDate(); /** * Generates a random credit card type. @@ -291,6 +289,6 @@ class Finance * Finance::creditCardType() // "Visa" * @endcode */ - static std::string_view creditCardType(); -}; + std::string_view creditCardType(); + } diff --git a/src/modules/finance/Finance.cpp b/src/modules/finance/Finance.cpp index 01feef513..fa40644d3 100644 --- a/src/modules/finance/Finance.cpp +++ b/src/modules/finance/Finance.cpp @@ -14,35 +14,36 @@ #include "faker-cxx/types/Precision.h" #include "FinanceData.h" -namespace faker + +namespace faker::finance { -Currency Finance::currency() +Currency currency() { return Helper::arrayElement(currencies); } -std::string_view Finance::currencyName() +std::string_view currencyName() { return Helper::arrayElement(currencies).name; } -std::string_view Finance::currencyCode() +std::string_view currencyCode() { return Helper::arrayElement(currencies).code; } -std::string_view Finance::currencySymbol() +std::string_view currencySymbol() { return Helper::arrayElement(currencies).symbol; } -std::string_view Finance::accountType() +std::string_view accountType() { return Helper::arrayElement(accountTypes); } -std::string Finance::amount(double min, double max, Precision precision, const std::string& symbol) +std::string amount(double min, double max, Precision precision, const std::string& symbol) { const std::floating_point auto generatedNumber = number::decimal(min, max); @@ -53,7 +54,7 @@ std::string Finance::amount(double min, double max, Precision precision, const s return result; } -std::string Finance::iban(std::optional country) +std::string iban(std::optional country) { const auto ibanCountry = country ? *country : Helper::arrayElement(ibanCountries); @@ -88,29 +89,29 @@ std::string Finance::iban(std::optional country) return iban; } -std::string_view Finance::bic(std::optional country) +std::string_view bic(std::optional country) { const auto bicCountry = country ? *country : Helper::arrayElement(bicCountries); return Helper::arrayElement(bicCountriesCodes.at(bicCountry)); } -std::string Finance::accountNumber(unsigned int length) +std::string accountNumber(unsigned int length) { return String::numeric(length, true); } -std::string Finance::pin(unsigned int length) +std::string pin(unsigned int length) { return String::numeric(length, true); } -std::string Finance::routingNumber() +std::string routingNumber() { return String::numeric(9, true); } -std::string Finance::creditCardNumber(std::optional creditCardType) +std::string creditCardNumber(std::optional creditCardType) { const auto creditCardTargetType = creditCardType ? *creditCardType : Helper::arrayElement(creditCardTypes); @@ -132,12 +133,12 @@ std::string Finance::creditCardNumber(std::optional cre return ""; } -std::string Finance::creditCardCvv() +std::string creditCardCvv() { return String::numeric(3, true); } -std::string Finance::bitcoinAddress() +std::string bitcoinAddress() { const unsigned addressLength = number::integer(26u, 33u); @@ -148,7 +149,7 @@ std::string Finance::bitcoinAddress() return address; } -std::string Finance::litecoinAddress() +std::string litecoinAddress() { const unsigned addressLength = number::integer(26u, 33u); @@ -159,19 +160,19 @@ std::string Finance::litecoinAddress() return address; } -std::string Finance::ethereumAddress() +std::string ethereumAddress() { return String::hexadecimal(40, HexCasing::Lower); } -std::string Finance::creditCardExpirationDate() +std::string creditCardExpirationDate() { const auto expirationDate = faker::date::futureDate(3); return expirationDate.substr(5, 2) + "/" + expirationDate.substr(2, 2); } -std::string_view Finance::creditCardType() +std::string_view creditCardType() { return Helper::arrayElement(creditCardNames); } diff --git a/src/modules/finance/FinanceData.h b/src/modules/finance/FinanceData.h index f2191ecb3..12ac918a0 100644 --- a/src/modules/finance/FinanceData.h +++ b/src/modules/finance/FinanceData.h @@ -7,53 +7,53 @@ #include "faker-cxx/Finance.h" -namespace faker +namespace faker::finance { -const auto bicCountries = std::to_array({ - Finance::BicCountry::Poland, Finance::BicCountry::UnitedStates, Finance::BicCountry::UnitedKingdom, - Finance::BicCountry::Germany, Finance::BicCountry::Romania, Finance::BicCountry::France, - Finance::BicCountry::Italy, Finance::BicCountry::Spain, Finance::BicCountry::Netherlands, - Finance::BicCountry::India +const auto bicCountries = std::to_array({ + BicCountry::Poland, BicCountry::UnitedStates, BicCountry::UnitedKingdom, + BicCountry::Germany, BicCountry::Romania, BicCountry::France, + BicCountry::Italy, BicCountry::Spain, BicCountry::Netherlands, + BicCountry::India }); -const auto ibanCountries = std::to_array({ - Finance::IbanCountry::Austria, Finance::IbanCountry::Belgium, Finance::IbanCountry::Bulgaria, - Finance::IbanCountry::Croatia, Finance::IbanCountry::Cyprus, Finance::IbanCountry::Czechia, - Finance::IbanCountry::Denmark, Finance::IbanCountry::Estonia, Finance::IbanCountry::Finland, - Finance::IbanCountry::France, Finance::IbanCountry::Germany, Finance::IbanCountry::Greece, - Finance::IbanCountry::Hungary, Finance::IbanCountry::Ireland, Finance::IbanCountry::Italy, - Finance::IbanCountry::Latvia, Finance::IbanCountry::Lithuania, Finance::IbanCountry::Luxembourg, - Finance::IbanCountry::Malta, Finance::IbanCountry::Netherlands, Finance::IbanCountry::Poland, - Finance::IbanCountry::Portugal, Finance::IbanCountry::Romania, Finance::IbanCountry::Slovakia, - Finance::IbanCountry::Slovenia, Finance::IbanCountry::Spain, Finance::IbanCountry::Sweden, +const auto ibanCountries = std::to_array({ + IbanCountry::Austria, IbanCountry::Belgium, IbanCountry::Bulgaria, + IbanCountry::Croatia, IbanCountry::Cyprus, IbanCountry::Czechia, + IbanCountry::Denmark, IbanCountry::Estonia, IbanCountry::Finland, + IbanCountry::France, IbanCountry::Germany, IbanCountry::Greece, + IbanCountry::Hungary, IbanCountry::Ireland, IbanCountry::Italy, + IbanCountry::Latvia, IbanCountry::Lithuania, IbanCountry::Luxembourg, + IbanCountry::Malta, IbanCountry::Netherlands, IbanCountry::Poland, + IbanCountry::Portugal, IbanCountry::Romania, IbanCountry::Slovakia, + IbanCountry::Slovenia, IbanCountry::Spain, IbanCountry::Sweden, }); const auto accountTypes = std::to_array({ "Checking", "Savings", "Money Market", "Investment", "Home Loan", "Credit Card", "Auto Loan", "Personal Loan", }); -const std::unordered_map> bicCountriesCodes = { - {Finance::BicCountry::Poland, +const std::unordered_map> bicCountriesCodes = { + {BicCountry::Poland, {"BPKOPLPW", "PKOPPLPW", "BREXPLPWMUL", "BNPAPLP", "POLUPLPR", "BIGBPLPW", "WBKPPLPP", "CITIPLPX", "INGBPLPW", "DEUTPLPK", "DEUTPLP"}}, - {Finance::BicCountry::UnitedStates, + {BicCountry::UnitedStates, {"BOFAUS3N", "CITIUS33", "WELLSFARGO", "USBKUS44", "CHASUS33", "HSBCUS33", "PNCCUS33"}}, - {Finance::BicCountry::UnitedKingdom, + {BicCountry::UnitedKingdom, {"BARCGB22", "HSBCKENW", "LOYDGB21", "NWBKGB2L", "RBOSGB2L", "HSBCGB2L", "DEUTGB2L"}}, - {Finance::BicCountry::Germany, + {BicCountry::Germany, {"DEUTDEFF", "DRESDEFF", "COBADEFF", "BYLADEM1", "GENODEFF", "HYVEDEMM", "MALADE51", "NOLADE21", "SOLADEST", "UNCRDEFF"}}, - {Finance::BicCountry::Romania, + {BicCountry::Romania, {"RNCBROBU", "BRDEROBU", "BTRLRO22", "PIRBROBU", "INGBROBU", "EXIMRO22", "CRDZROBU"}}, - {Finance::BicCountry::France, + {BicCountry::France, {"BNPAFRPP", "CEPAFRPP", "CRLYFRPP", "SOGEFRPP", "AGRIFRPP", "HSBDFRPP", "CCFRFRPP", "BNORDRPP", "CMCIFRPP"}}, - {Finance::BicCountry::Italy, {"UNCRITMM", "BCITITMM", "INTESA", "UBSPITPA", "BLOPIT22", "CITIITMX", "BNLIITRR"}}, - {Finance::BicCountry::Spain, + {BicCountry::Italy, {"UNCRITMM", "BCITITMM", "INTESA", "UBSPITPA", "BLOPIT22", "CITIITMX", "BNLIITRR"}}, + {BicCountry::Spain, {"CAIXESBB", "BBVAESMM", "SABSESBB", "BSCHESMM", "POPUESMM", "INGDESMM", "CITIES2X", "BCOEESMM"}}, - {Finance::BicCountry::Netherlands, + {BicCountry::Netherlands, {"ABNANL2A", "INGBNL2A", "RABONL2U", "TRIONL2U", "KNABNL2H", "SBINNL2X", "DEUTNL2N"}}, { - Finance::BicCountry::India, + BicCountry::India, {"HDFCINBB", "ICICINBB", "SBININBB", "PNBAINBB", "UBININBB", "AXISINBB", "KKBKINBB", "YESBINBB", "IDBIINBB"}, }}; @@ -77,11 +77,11 @@ const auto visaCreditCardFormats = std::to_array({ "4###-####-####-###L", }); -const auto creditCardTypes = std::to_array({ - Finance::CreditCardType::Visa, - Finance::CreditCardType::AmericanExpress, - Finance::CreditCardType::MasterCard, - Finance::CreditCardType::Discover, +const auto creditCardTypes = std::to_array({ + CreditCardType::Visa, + CreditCardType::AmericanExpress, + CreditCardType::MasterCard, + CreditCardType::Discover, }); const auto creditCardNames = std::to_array({ @@ -866,34 +866,34 @@ const auto currencies = std::to_array({ // Iban format structure from https://bank.codes/iban/structure/ // Note: a - alphabets (letters only), c - characters (letters & numbers), n - numbers (numbers only) -const std::unordered_map> ibanFormats{ - {Finance::IbanCountry::Austria, {"AT", "2n", "5n", "11n"}}, - {Finance::IbanCountry::Belgium, {"BE", "2n", "3n", "7n", "2n"}}, - {Finance::IbanCountry::Bulgaria, {"BG", "2n", "4a", "4n", "2n", "8c"}}, - {Finance::IbanCountry::Croatia, {"HR", "2n", "7n", "10n"}}, - {Finance::IbanCountry::Cyprus, {"CY", "2n", "3n", "5n", "16c"}}, - {Finance::IbanCountry::Czechia, {"CZ", "2n", "4n", "6n", "10n"}}, - {Finance::IbanCountry::Denmark, {"DK", "2n", "4n", "9n", "1n"}}, - {Finance::IbanCountry::Estonia, {"EE", "2n", "2n", "2n", "11n", "1n"}}, - {Finance::IbanCountry::Finland, {"FI", "2n", "6n", "7n", "1n"}}, - {Finance::IbanCountry::France, {"FR", "2n", "5n", "5n", "11c", "2n"}}, - {Finance::IbanCountry::Germany, {"DE", "2n", "8n", "10n"}}, - {Finance::IbanCountry::Greece, {"GR", "2n", "3n", "4n", "16c"}}, - {Finance::IbanCountry::Hungary, {"HU", "2n", "3n", "4n", "1n", "15n", "1n"}}, - {Finance::IbanCountry::Ireland, {"IE", "2n", "4a", "6n", "8n"}}, - {Finance::IbanCountry::Italy, {"IT", "2n", "1a", "5n", "5n", "12c"}}, - {Finance::IbanCountry::Latvia, {"LV", "2n", "4a", "13n"}}, - {Finance::IbanCountry::Lithuania, {"LT", "2n", "5n", "11n"}}, - {Finance::IbanCountry::Luxembourg, {"LU", "2n", "3n", "13c"}}, - {Finance::IbanCountry::Malta, {"MT", "2n", "4a", "5n", "18c"}}, - {Finance::IbanCountry::Netherlands, {"NL", "2n", "4a", "10n"}}, - {Finance::IbanCountry::Poland, {"PL", "2n", "3n", "4n", "1n", "16n"}}, - {Finance::IbanCountry::Portugal, {"PT", "2n", "4n", "4n", "11n", "2n"}}, - {Finance::IbanCountry::Romania, {"RO", "2n", "4a", "16c"}}, - {Finance::IbanCountry::Slovakia, {"SK", "2n", "4n", "6n", "10n"}}, - {Finance::IbanCountry::Slovenia, {"SI", "2n", "2n", "3n", "8n", "2n"}}, - {Finance::IbanCountry::Spain, {"ES", "2n", "4n", "4n", "2n", "10n"}}, - {Finance::IbanCountry::Sweden, {"SE", "2n", "3n", "16n", "1n"}}, +const std::unordered_map> ibanFormats{ + {IbanCountry::Austria, {"AT", "2n", "5n", "11n"}}, + {IbanCountry::Belgium, {"BE", "2n", "3n", "7n", "2n"}}, + {IbanCountry::Bulgaria, {"BG", "2n", "4a", "4n", "2n", "8c"}}, + {IbanCountry::Croatia, {"HR", "2n", "7n", "10n"}}, + {IbanCountry::Cyprus, {"CY", "2n", "3n", "5n", "16c"}}, + {IbanCountry::Czechia, {"CZ", "2n", "4n", "6n", "10n"}}, + {IbanCountry::Denmark, {"DK", "2n", "4n", "9n", "1n"}}, + {IbanCountry::Estonia, {"EE", "2n", "2n", "2n", "11n", "1n"}}, + {IbanCountry::Finland, {"FI", "2n", "6n", "7n", "1n"}}, + {IbanCountry::France, {"FR", "2n", "5n", "5n", "11c", "2n"}}, + {IbanCountry::Germany, {"DE", "2n", "8n", "10n"}}, + {IbanCountry::Greece, {"GR", "2n", "3n", "4n", "16c"}}, + {IbanCountry::Hungary, {"HU", "2n", "3n", "4n", "1n", "15n", "1n"}}, + {IbanCountry::Ireland, {"IE", "2n", "4a", "6n", "8n"}}, + {IbanCountry::Italy, {"IT", "2n", "1a", "5n", "5n", "12c"}}, + {IbanCountry::Latvia, {"LV", "2n", "4a", "13n"}}, + {IbanCountry::Lithuania, {"LT", "2n", "5n", "11n"}}, + {IbanCountry::Luxembourg, {"LU", "2n", "3n", "13c"}}, + {IbanCountry::Malta, {"MT", "2n", "4a", "5n", "18c"}}, + {IbanCountry::Netherlands, {"NL", "2n", "4a", "10n"}}, + {IbanCountry::Poland, {"PL", "2n", "3n", "4n", "1n", "16n"}}, + {IbanCountry::Portugal, {"PT", "2n", "4n", "4n", "11n", "2n"}}, + {IbanCountry::Romania, {"RO", "2n", "4a", "16c"}}, + {IbanCountry::Slovakia, {"SK", "2n", "4n", "6n", "10n"}}, + {IbanCountry::Slovenia, {"SI", "2n", "2n", "3n", "8n", "2n"}}, + {IbanCountry::Spain, {"ES", "2n", "4n", "4n", "2n", "10n"}}, + {IbanCountry::Sweden, {"SE", "2n", "3n", "16n", "1n"}}, }; } diff --git a/tests/modules/finance/FinanceTest.cpp b/tests/modules/finance/FinanceTest.cpp index ea2a3cb16..8f4751e81 100644 --- a/tests/modules/finance/FinanceTest.cpp +++ b/tests/modules/finance/FinanceTest.cpp @@ -18,85 +18,86 @@ using namespace ::testing; using namespace faker; +using namespace faker::finance; namespace { const std::string creditCardCharacters = "0123456789-"; -const std::unordered_map expectedRegex{ - {Finance::IbanCountry::Austria, "^(AT)([0-9]{2})([0-9]{5})([0-9]{11})$"}, - {Finance::IbanCountry::Belgium, "^(BE)([0-9]{2})([0-9]{3})([0-9]{7})([0-9]{2})$"}, - {Finance::IbanCountry::Bulgaria, "^(BG)([0-9]{2})([A-Z]{4})([0-9]{4})([0-9]{2})([a-zA-Z0-9]{8})$"}, - {Finance::IbanCountry::Croatia, "^(HR)([0-9]{2})([0-9]{7})([0-9]{10})$"}, - {Finance::IbanCountry::Cyprus, "^(CY)([0-9]{2})([0-9]{3})([0-9]{5})([a-zA-Z0-9]{16})$"}, - {Finance::IbanCountry::Czechia, "^(CZ)([0-9]{2})([0-9]{4})([0-9]{6})([0-9]{10})$"}, - {Finance::IbanCountry::Denmark, "^(DK)([0-9]{2})([0-9]{4})([0-9]{9})([0-9]{1})$"}, - {Finance::IbanCountry::Estonia, "^(EE)([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{11})([0-9]{1})$"}, - {Finance::IbanCountry::Finland, "^(FI)([0-9]{2})([0-9]{6})([0-9]{7})([0-9]{1})$"}, - {Finance::IbanCountry::France, "^(FR)([0-9]{2})([0-9]{5})([0-9]{5})([a-zA-Z0-9]{11})([0-9]{2})$"}, - {Finance::IbanCountry::Germany, "^(DE)([0-9]{2})([0-9]{8})([0-9]{10})$"}, - {Finance::IbanCountry::Greece, "^(GR)([0-9]{2})([0-9]{3})([0-9]{4})([a-zA-Z0-9]{16})$"}, - {Finance::IbanCountry::Hungary, "^(HU)([0-9]{2})([0-9]{3})([0-9]{4})([0-9]{1})([0-9]{15})([0-9]{1})$"}, - {Finance::IbanCountry::Ireland, "^(IE)([0-9]{2})([A-Z]{4})([0-9]{6})([0-9]{8})$"}, - {Finance::IbanCountry::Italy, "^(IT)([0-9]{2})([A-Z]{1})([0-9]{5})([0-9]{5})([a-zA-Z0-9]{12})$"}, - {Finance::IbanCountry::Latvia, "^(LV)([0-9]{2})([A-Z]{4})([a-zA-Z0-9]{13})$"}, - {Finance::IbanCountry::Lithuania, "^(LT)([0-9]{2})([0-9]{5})([0-9]{11})$"}, - {Finance::IbanCountry::Luxembourg, "^(LU)([0-9]{2})([0-9]{3})([a-zA-Z0-9]{13})$"}, - {Finance::IbanCountry::Malta, "^(MT)([0-9]{2})([A-Z]{4})([0-9]{5})([a-zA-Z0-9]{18})$"}, - {Finance::IbanCountry::Netherlands, "^(NL)([0-9]{2})([A-Z]{4})([0-9]{10})$"}, - {Finance::IbanCountry::Poland, "^(PL)([0-9]{2})([0-9]{3})([0-9]{4})([0-9]{1})([0-9]{16})$"}, - {Finance::IbanCountry::Portugal, "^(PT)([0-9]{2})([0-9]{4})([0-9]{4})([0-9]{11})([0-9]{2})$"}, - {Finance::IbanCountry::Romania, "^(RO)([0-9]{2})([A-Z]{4})([a-zA-Z0-9]{16})$"}, - {Finance::IbanCountry::Slovakia, "^(SK)([0-9]{2})([0-9]{4})([0-9]{6})([0-9]{10})$"}, - {Finance::IbanCountry::Slovenia, "^(SI)([0-9]{2})([0-9]{2})([0-9]{3})([0-9]{8})([0-9]{2})$"}, - {Finance::IbanCountry::Spain, "^(ES)([0-9]{2})([0-9]{4})([0-9]{4})([0-9]{2})([0-9]{10})$"}, - {Finance::IbanCountry::Sweden, "^(SE)([0-9]{2})([0-9]{3})([0-9]{17})$"}, +const std::unordered_map expectedRegex{ + {IbanCountry::Austria, "^(AT)([0-9]{2})([0-9]{5})([0-9]{11})$"}, + {IbanCountry::Belgium, "^(BE)([0-9]{2})([0-9]{3})([0-9]{7})([0-9]{2})$"}, + {IbanCountry::Bulgaria, "^(BG)([0-9]{2})([A-Z]{4})([0-9]{4})([0-9]{2})([a-zA-Z0-9]{8})$"}, + {IbanCountry::Croatia, "^(HR)([0-9]{2})([0-9]{7})([0-9]{10})$"}, + {IbanCountry::Cyprus, "^(CY)([0-9]{2})([0-9]{3})([0-9]{5})([a-zA-Z0-9]{16})$"}, + {IbanCountry::Czechia, "^(CZ)([0-9]{2})([0-9]{4})([0-9]{6})([0-9]{10})$"}, + {IbanCountry::Denmark, "^(DK)([0-9]{2})([0-9]{4})([0-9]{9})([0-9]{1})$"}, + {IbanCountry::Estonia, "^(EE)([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{11})([0-9]{1})$"}, + {IbanCountry::Finland, "^(FI)([0-9]{2})([0-9]{6})([0-9]{7})([0-9]{1})$"}, + {IbanCountry::France, "^(FR)([0-9]{2})([0-9]{5})([0-9]{5})([a-zA-Z0-9]{11})([0-9]{2})$"}, + {IbanCountry::Germany, "^(DE)([0-9]{2})([0-9]{8})([0-9]{10})$"}, + {IbanCountry::Greece, "^(GR)([0-9]{2})([0-9]{3})([0-9]{4})([a-zA-Z0-9]{16})$"}, + {IbanCountry::Hungary, "^(HU)([0-9]{2})([0-9]{3})([0-9]{4})([0-9]{1})([0-9]{15})([0-9]{1})$"}, + {IbanCountry::Ireland, "^(IE)([0-9]{2})([A-Z]{4})([0-9]{6})([0-9]{8})$"}, + {IbanCountry::Italy, "^(IT)([0-9]{2})([A-Z]{1})([0-9]{5})([0-9]{5})([a-zA-Z0-9]{12})$"}, + {IbanCountry::Latvia, "^(LV)([0-9]{2})([A-Z]{4})([a-zA-Z0-9]{13})$"}, + {IbanCountry::Lithuania, "^(LT)([0-9]{2})([0-9]{5})([0-9]{11})$"}, + {IbanCountry::Luxembourg, "^(LU)([0-9]{2})([0-9]{3})([a-zA-Z0-9]{13})$"}, + {IbanCountry::Malta, "^(MT)([0-9]{2})([A-Z]{4})([0-9]{5})([a-zA-Z0-9]{18})$"}, + {IbanCountry::Netherlands, "^(NL)([0-9]{2})([A-Z]{4})([0-9]{10})$"}, + {IbanCountry::Poland, "^(PL)([0-9]{2})([0-9]{3})([0-9]{4})([0-9]{1})([0-9]{16})$"}, + {IbanCountry::Portugal, "^(PT)([0-9]{2})([0-9]{4})([0-9]{4})([0-9]{11})([0-9]{2})$"}, + {IbanCountry::Romania, "^(RO)([0-9]{2})([A-Z]{4})([a-zA-Z0-9]{16})$"}, + {IbanCountry::Slovakia, "^(SK)([0-9]{2})([0-9]{4})([0-9]{6})([0-9]{10})$"}, + {IbanCountry::Slovenia, "^(SI)([0-9]{2})([0-9]{2})([0-9]{3})([0-9]{8})([0-9]{2})$"}, + {IbanCountry::Spain, "^(ES)([0-9]{2})([0-9]{4})([0-9]{4})([0-9]{2})([0-9]{10})$"}, + {IbanCountry::Sweden, "^(SE)([0-9]{2})([0-9]{3})([0-9]{17})$"}, }; -const std::unordered_map generatedTestName{ - {Finance::IbanCountry::Austria, "shouldGenerateAustriaIban"}, - {Finance::IbanCountry::Belgium, "shouldGenerateBelgiumIban"}, - {Finance::IbanCountry::Bulgaria, "shouldGenerateBulgariaIban"}, - {Finance::IbanCountry::Croatia, "shouldGenerateCroatiaIban"}, - {Finance::IbanCountry::Cyprus, "shouldGenerateCyprusIban"}, - {Finance::IbanCountry::Czechia, "shouldGenerateCzechiaIban"}, - {Finance::IbanCountry::Denmark, "shouldGenerateDenmarkIban"}, - {Finance::IbanCountry::Estonia, "shouldGenerateEstoniaIban"}, - {Finance::IbanCountry::Finland, "shouldGenerateFinlandIban"}, - {Finance::IbanCountry::France, "shouldGenerateFranceIban"}, - {Finance::IbanCountry::Germany, "shouldGenerateGermanyIban"}, - {Finance::IbanCountry::Greece, "shouldGenerateGreeceIban"}, - {Finance::IbanCountry::Hungary, "shouldGenerateHungaryIban"}, - {Finance::IbanCountry::Ireland, "shouldGenerateIrelandIban"}, - {Finance::IbanCountry::Italy, "shouldGenerateItalyIban"}, - {Finance::IbanCountry::Latvia, "shouldGenerateLatviaIban"}, - {Finance::IbanCountry::Lithuania, "shouldGenerateLithuaniaIban"}, - {Finance::IbanCountry::Luxembourg, "shouldGenerateLuxembourgIban"}, - {Finance::IbanCountry::Malta, "shouldGenerateMaltaIban"}, - {Finance::IbanCountry::Netherlands, "shouldGenerateNetherlandsIban"}, - {Finance::IbanCountry::Poland, "shouldGeneratePolandIban"}, - {Finance::IbanCountry::Portugal, "shouldGeneratePortugalIban"}, - {Finance::IbanCountry::Romania, "shouldGenerateRomaniaIban"}, - {Finance::IbanCountry::Slovakia, "shouldGenerateSlovakiaIban"}, - {Finance::IbanCountry::Slovenia, "shouldGenerateSloveniaIban"}, - {Finance::IbanCountry::Spain, "shouldGenerateSpainIban"}, - {Finance::IbanCountry::Sweden, "shouldGenerateSwedenIban"}, +const std::unordered_map generatedTestName{ + {IbanCountry::Austria, "shouldGenerateAustriaIban"}, + {IbanCountry::Belgium, "shouldGenerateBelgiumIban"}, + {IbanCountry::Bulgaria, "shouldGenerateBulgariaIban"}, + {IbanCountry::Croatia, "shouldGenerateCroatiaIban"}, + {IbanCountry::Cyprus, "shouldGenerateCyprusIban"}, + {IbanCountry::Czechia, "shouldGenerateCzechiaIban"}, + {IbanCountry::Denmark, "shouldGenerateDenmarkIban"}, + {IbanCountry::Estonia, "shouldGenerateEstoniaIban"}, + {IbanCountry::Finland, "shouldGenerateFinlandIban"}, + {IbanCountry::France, "shouldGenerateFranceIban"}, + {IbanCountry::Germany, "shouldGenerateGermanyIban"}, + {IbanCountry::Greece, "shouldGenerateGreeceIban"}, + {IbanCountry::Hungary, "shouldGenerateHungaryIban"}, + {IbanCountry::Ireland, "shouldGenerateIrelandIban"}, + {IbanCountry::Italy, "shouldGenerateItalyIban"}, + {IbanCountry::Latvia, "shouldGenerateLatviaIban"}, + {IbanCountry::Lithuania, "shouldGenerateLithuaniaIban"}, + {IbanCountry::Luxembourg, "shouldGenerateLuxembourgIban"}, + {IbanCountry::Malta, "shouldGenerateMaltaIban"}, + {IbanCountry::Netherlands, "shouldGenerateNetherlandsIban"}, + {IbanCountry::Poland, "shouldGeneratePolandIban"}, + {IbanCountry::Portugal, "shouldGeneratePortugalIban"}, + {IbanCountry::Romania, "shouldGenerateRomaniaIban"}, + {IbanCountry::Slovakia, "shouldGenerateSlovakiaIban"}, + {IbanCountry::Slovenia, "shouldGenerateSloveniaIban"}, + {IbanCountry::Spain, "shouldGenerateSpainIban"}, + {IbanCountry::Sweden, "shouldGenerateSwedenIban"}, }; -const std::unordered_map generatedBicTestName{ - {Finance::BicCountry::Poland, "shouldGeneratePolandBic"}, - {Finance::BicCountry::UnitedStates, "shouldGenerateUnitedStatesBic"}, - {Finance::BicCountry::UnitedKingdom, "shouldGenerateUnitedKingdomBic"}, - {Finance::BicCountry::Germany, "shouldGenerateGermanyBic"}, - {Finance::BicCountry::Romania, "shouldGenerateRomaniaBic"}, - {Finance::BicCountry::France, "shouldGenerateFranceBic"}, - {Finance::BicCountry::Italy, "shouldGenerateItalyBic"}, - {Finance::BicCountry::Spain, "shouldGenerateSpainBic"}, - {Finance::BicCountry::Netherlands, "shouldGenerateNetherlandsBic"}, - {Finance::BicCountry::India, "shouldGenerateIndiaBic"}, +const std::unordered_map generatedBicTestName{ + {BicCountry::Poland, "shouldGeneratePolandBic"}, + {BicCountry::UnitedStates, "shouldGenerateUnitedStatesBic"}, + {BicCountry::UnitedKingdom, "shouldGenerateUnitedKingdomBic"}, + {BicCountry::Germany, "shouldGenerateGermanyBic"}, + {BicCountry::Romania, "shouldGenerateRomaniaBic"}, + {BicCountry::France, "shouldGenerateFranceBic"}, + {BicCountry::Italy, "shouldGenerateItalyBic"}, + {BicCountry::Spain, "shouldGenerateSpainBic"}, + {BicCountry::Netherlands, "shouldGenerateNetherlandsBic"}, + {BicCountry::India, "shouldGenerateIndiaBic"}, }; } -class FinanceTest : public TestWithParam +class FinanceTest : public TestWithParam { public: static bool checkIfAllCharactersAreNumeric(const std::string& data) @@ -130,7 +131,7 @@ class FinanceTest : public TestWithParam TEST_F(FinanceTest, shouldGenerateCurrency) { - const auto generatedCurrency = Finance::currency(); + const auto generatedCurrency = currency(); ASSERT_TRUE(std::ranges::any_of(currencies, [generatedCurrency](const Currency& currency) { return checkIfCurrenciesAreEqual(currency, generatedCurrency); })); @@ -138,7 +139,7 @@ TEST_F(FinanceTest, shouldGenerateCurrency) TEST_F(FinanceTest, shouldGenerateCurrencyName) { - const auto generatedCurrencyName = Finance::currencyName(); + const auto generatedCurrencyName = currencyName(); ASSERT_TRUE(std::ranges::any_of(currencies, [generatedCurrencyName](const Currency& currency) { return currency.name == generatedCurrencyName; })); @@ -146,7 +147,7 @@ TEST_F(FinanceTest, shouldGenerateCurrencyName) TEST_F(FinanceTest, shouldGenerateCurrencyCode) { - const auto generatedCurrencyCode = Finance::currencyCode(); + const auto generatedCurrencyCode = currencyCode(); ASSERT_TRUE(std::ranges::any_of(currencies, [generatedCurrencyCode](const Currency& currency) { return currency.code == generatedCurrencyCode; })); @@ -154,7 +155,7 @@ TEST_F(FinanceTest, shouldGenerateCurrencyCode) TEST_F(FinanceTest, shouldGenerateCurrencySymbol) { - const auto generatedCurrencySymbol = Finance::currencySymbol(); + const auto generatedCurrencySymbol = currencySymbol(); ASSERT_TRUE(std::ranges::any_of(currencies, [generatedCurrencySymbol](const Currency& currency) { return currency.symbol == generatedCurrencySymbol; })); @@ -162,7 +163,7 @@ TEST_F(FinanceTest, shouldGenerateCurrencySymbol) TEST_F(FinanceTest, shouldGenerateAccountType) { - const auto generatedAccountType = Finance::accountType(); + const auto generatedAccountType = accountType(); ASSERT_TRUE(std::ranges::any_of(accountTypes, [generatedAccountType](const std::string_view& accountType) { return accountType == generatedAccountType; })); @@ -170,7 +171,7 @@ TEST_F(FinanceTest, shouldGenerateAccountType) TEST_F(FinanceTest, shouldGenerateAmount) { - const auto generatedAmount = Finance::amount(); + const auto generatedAmount = amount(); auto offset = generatedAmount.size(); const auto amountAsFloat = std::stof(generatedAmount, &offset); @@ -197,12 +198,12 @@ TEST_P(FinanceTest, CheckIbanGenerator) { auto ibanCountry = GetParam(); - ASSERT_THAT(Finance::iban(ibanCountry), MatchesRegexCpp(expectedRegex.at(ibanCountry))); + ASSERT_THAT(iban(ibanCountry), MatchesRegexCpp(expectedRegex.at(ibanCountry))); } INSTANTIATE_TEST_SUITE_P(TestIbanGenerator, FinanceTest, ValuesIn(std::views::keys(expectedRegex).begin(), std::views::keys(expectedRegex).end()), - [](const TestParamInfo& paramInfo) + [](const TestParamInfo& paramInfo) { return generatedTestName.at(paramInfo.param); }); TEST_F(FinanceTest, shouldGenerateAmountWithSymbol) @@ -212,7 +213,7 @@ TEST_F(FinanceTest, shouldGenerateAmountWithSymbol) const auto precision = Precision::FourDp; const std::string currencySymbol = "$"; - const auto generatedAmount = Finance::amount(150, 450, precision, currencySymbol); + const auto generatedAmount = amount(150, 450, precision, currencySymbol); const auto amountAsFloat = std::stof(generatedAmount.substr(currencySymbol.size())); @@ -227,130 +228,130 @@ TEST_F(FinanceTest, shouldGenerateAmountWithSymbol) TEST_F(FinanceTest, shouldGenerateIban) { - const auto iban = Finance::iban(); - - ASSERT_TRUE(iban.starts_with("AT") || iban.starts_with("BE") || iban.starts_with("BG") || iban.starts_with("HR") || - iban.starts_with("CY") || iban.starts_with("CZ") || iban.starts_with("DK") || iban.starts_with("EE") || - iban.starts_with("FI") || iban.starts_with("FR") || iban.starts_with("DE") || iban.starts_with("GR") || - iban.starts_with("HU") || iban.starts_with("IE") || iban.starts_with("IT") || iban.starts_with("LV") || - iban.starts_with("LT") || iban.starts_with("LU") || iban.starts_with("MT") || iban.starts_with("NL") || - iban.starts_with("PL") || iban.starts_with("PT") || iban.starts_with("RO") || iban.starts_with("SK") || - iban.starts_with("SI") || iban.starts_with("ES") || iban.starts_with("SE")); + const auto generatedIban = iban(); + + ASSERT_TRUE(generatedIban.starts_with("AT") || generatedIban.starts_with("BE") || generatedIban.starts_with("BG") || generatedIban.starts_with("HR") || + generatedIban.starts_with("CY") || generatedIban.starts_with("CZ") || generatedIban.starts_with("DK") || generatedIban.starts_with("EE") || + generatedIban.starts_with("FI") || generatedIban.starts_with("FR") || generatedIban.starts_with("DE") || generatedIban.starts_with("GR") || + generatedIban.starts_with("HU") || generatedIban.starts_with("IE") || generatedIban.starts_with("IT") || generatedIban.starts_with("LV") || + generatedIban.starts_with("LT") || generatedIban.starts_with("LU") || generatedIban.starts_with("MT") || generatedIban.starts_with("NL") || + generatedIban.starts_with("PL") || generatedIban.starts_with("PT") || generatedIban.starts_with("RO") || generatedIban.starts_with("SK") || + generatedIban.starts_with("SI") || generatedIban.starts_with("ES") || generatedIban.starts_with("SE")); } TEST_F(FinanceTest, shouldGenerateAccountNumber) { - const auto accountNumber = Finance::accountNumber(); + const auto generatedAccountNumber = accountNumber(); - ASSERT_EQ(accountNumber.size(), 8); - ASSERT_TRUE(checkIfAllCharactersAreNumeric(accountNumber)); + ASSERT_EQ(generatedAccountNumber.size(), 8); + ASSERT_TRUE(checkIfAllCharactersAreNumeric(generatedAccountNumber)); } TEST_F(FinanceTest, shouldGenerateAccountNumberWithSpecifiedLength) { const auto accountNumberLength = 26; - const auto accountNumber = Finance::accountNumber(accountNumberLength); + const auto generatedAccountNumber = accountNumber(accountNumberLength); - ASSERT_EQ(accountNumber.size(), accountNumberLength); - ASSERT_TRUE(checkIfAllCharactersAreNumeric(accountNumber)); + ASSERT_EQ(generatedAccountNumber.size(), accountNumberLength); + ASSERT_TRUE(checkIfAllCharactersAreNumeric(generatedAccountNumber)); } TEST_F(FinanceTest, shouldGeneratePinNumber) { - const auto pin = Finance::pin(); + const auto generatedPin = pin(); - ASSERT_EQ(pin.size(), 4); - ASSERT_TRUE(checkIfAllCharactersAreNumeric(pin)); + ASSERT_EQ(generatedPin.size(), 4); + ASSERT_TRUE(checkIfAllCharactersAreNumeric(generatedPin)); } TEST_F(FinanceTest, shouldGeneratePinNumberWithSpecifiedLength) { const auto pinLength = 8; - const auto pin = Finance::pin(pinLength); + const auto generatedPin = pin(pinLength); - ASSERT_EQ(pin.size(), pinLength); - ASSERT_TRUE(checkIfAllCharactersAreNumeric(pin)); + ASSERT_EQ(generatedPin.size(), pinLength); + ASSERT_TRUE(checkIfAllCharactersAreNumeric(generatedPin)); } TEST_F(FinanceTest, shouldGenerateRoutingNumber) { - const auto routingNumber = Finance::routingNumber(); + const auto generatedRoutingNumber = routingNumber(); - ASSERT_EQ(routingNumber.size(), 9); - ASSERT_TRUE(checkIfAllCharactersAreNumeric(routingNumber)); + ASSERT_EQ(generatedRoutingNumber.size(), 9); + ASSERT_TRUE(checkIfAllCharactersAreNumeric(generatedRoutingNumber)); } TEST_F(FinanceTest, shouldGenerateCreditCardNumber) { - const auto creditCardNumber = Finance::creditCardNumber(); + const auto generatedCreditCardNumber = creditCardNumber(); - ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(creditCardNumber)); - ASSERT_TRUE(LuhnCheck::luhnCheck(creditCardNumber)); + ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(generatedCreditCardNumber)); + ASSERT_TRUE(LuhnCheck::luhnCheck(generatedCreditCardNumber)); } TEST_F(FinanceTest, shouldGenerateAmericanExpressCreditCardNumber) { - const auto creditCardNumber = Finance::creditCardNumber(Finance::CreditCardType::AmericanExpress); + const auto generatedCreditCardNumber = creditCardNumber(CreditCardType::AmericanExpress); - ASSERT_TRUE(creditCardNumber.starts_with("34") || creditCardNumber.starts_with("37")); - ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(creditCardNumber)); - ASSERT_TRUE(LuhnCheck::luhnCheck(creditCardNumber)); + ASSERT_TRUE(generatedCreditCardNumber.starts_with("34") || generatedCreditCardNumber.starts_with("37")); + ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(generatedCreditCardNumber)); + ASSERT_TRUE(LuhnCheck::luhnCheck(generatedCreditCardNumber)); } TEST_F(FinanceTest, shouldGenerateDiscoverCreditCardNumber) { - const auto creditCardNumber = Finance::creditCardNumber(Finance::CreditCardType::Discover); - - ASSERT_TRUE(creditCardNumber.starts_with("6011") || creditCardNumber.starts_with("65") || - creditCardNumber.starts_with("644") || creditCardNumber.starts_with("645") || - creditCardNumber.starts_with("646") || creditCardNumber.starts_with("647") || - creditCardNumber.starts_with("648") || creditCardNumber.starts_with("649") || - creditCardNumber.starts_with("6011-62")); - ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(creditCardNumber)); - ASSERT_TRUE(LuhnCheck::luhnCheck(creditCardNumber)); + const auto generatedCreditCardNumber = creditCardNumber(CreditCardType::Discover); + + ASSERT_TRUE(generatedCreditCardNumber.starts_with("6011") || generatedCreditCardNumber.starts_with("65") || + generatedCreditCardNumber.starts_with("644") || generatedCreditCardNumber.starts_with("645") || + generatedCreditCardNumber.starts_with("646") || generatedCreditCardNumber.starts_with("647") || + generatedCreditCardNumber.starts_with("648") || generatedCreditCardNumber.starts_with("649") || + generatedCreditCardNumber.starts_with("6011-62")); + ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(generatedCreditCardNumber)); + ASSERT_TRUE(LuhnCheck::luhnCheck(generatedCreditCardNumber)); } TEST_F(FinanceTest, shouldGenerateMasterCardCreditCardNumber) { - const auto creditCardNumber = Finance::creditCardNumber(Finance::CreditCardType::MasterCard); + const auto generatedCreditCardNumber = creditCardNumber(CreditCardType::MasterCard); - ASSERT_TRUE(creditCardNumber.starts_with("51") || creditCardNumber.starts_with("52") || - creditCardNumber.starts_with("53") || creditCardNumber.starts_with("54") || - creditCardNumber.starts_with("55") || creditCardNumber.starts_with("6771-89")); - ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(creditCardNumber)); - ASSERT_TRUE(LuhnCheck::luhnCheck(creditCardNumber)); + ASSERT_TRUE(generatedCreditCardNumber.starts_with("51") || generatedCreditCardNumber.starts_with("52") || + generatedCreditCardNumber.starts_with("53") || generatedCreditCardNumber.starts_with("54") || + generatedCreditCardNumber.starts_with("55") || generatedCreditCardNumber.starts_with("6771-89")); + ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(generatedCreditCardNumber)); + ASSERT_TRUE(LuhnCheck::luhnCheck(generatedCreditCardNumber)); } TEST_F(FinanceTest, shouldGenerateVisaCreditCardNumber) { - const auto creditCardNumber = Finance::creditCardNumber(Finance::CreditCardType::Visa); + const auto generatedCreditCardNumber = creditCardNumber(CreditCardType::Visa); - ASSERT_TRUE(creditCardNumber.starts_with("4")); - ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(creditCardNumber)); - ASSERT_TRUE(LuhnCheck::luhnCheck(creditCardNumber)); + ASSERT_TRUE(generatedCreditCardNumber.starts_with("4")); + ASSERT_TRUE(checkIfAllCharactersAreCreditCardCharacters(generatedCreditCardNumber)); + ASSERT_TRUE(LuhnCheck::luhnCheck(generatedCreditCardNumber)); } TEST_F(FinanceTest, shouldGenerateCreditCardCvv) { - const auto creditCardCvv = Finance::creditCardCvv(); + const auto generatedCreditCardCvv = creditCardCvv(); - ASSERT_EQ(creditCardCvv.size(), 3); - ASSERT_TRUE(checkIfAllCharactersAreNumeric(creditCardCvv)); + ASSERT_EQ(generatedCreditCardCvv.size(), 3); + ASSERT_TRUE(checkIfAllCharactersAreNumeric(generatedCreditCardCvv)); } TEST_F(FinanceTest, shouldGenerateBitcoinAddress) { - const auto bitcoinAddress = Finance::bitcoinAddress(); + const auto generatedBitcoinAddress = bitcoinAddress(); - ASSERT_GE(bitcoinAddress.size(), 27); - ASSERT_LE(bitcoinAddress.size(), 34); + ASSERT_GE(generatedBitcoinAddress.size(), 27); + ASSERT_LE(generatedBitcoinAddress.size(), 34); const std::string supportedBitcoinAddressCharacters = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz123456789"; - ASSERT_TRUE(bitcoinAddress.starts_with("1") || bitcoinAddress.starts_with("3")); - ASSERT_TRUE(std::ranges::all_of(bitcoinAddress, + ASSERT_TRUE(generatedBitcoinAddress.starts_with("1") || generatedBitcoinAddress.starts_with("3")); + ASSERT_TRUE(std::ranges::all_of(generatedBitcoinAddress, [&supportedBitcoinAddressCharacters](char dataCharacter) { return std::ranges::any_of( @@ -362,16 +363,16 @@ TEST_F(FinanceTest, shouldGenerateBitcoinAddress) TEST_F(FinanceTest, shouldGenerateLitecoinAddress) { - const auto litecoinAddress = Finance::litecoinAddress(); + const auto generatedLitecoinAddress = litecoinAddress(); - ASSERT_GE(litecoinAddress.size(), 27); - ASSERT_LE(litecoinAddress.size(), 34); + ASSERT_GE(generatedLitecoinAddress.size(), 27); + ASSERT_LE(generatedLitecoinAddress.size(), 34); const std::string supportedLitecoinAddressCharacters = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz123456789"; - ASSERT_TRUE(litecoinAddress.starts_with("L") || litecoinAddress.starts_with("M") || - litecoinAddress.starts_with("3")); - ASSERT_TRUE(std::ranges::all_of(litecoinAddress, + ASSERT_TRUE(generatedLitecoinAddress.starts_with("L") || generatedLitecoinAddress.starts_with("M") || + generatedLitecoinAddress.starts_with("3")); + ASSERT_TRUE(std::ranges::all_of(generatedLitecoinAddress, [&supportedLitecoinAddressCharacters](char dataCharacter) { return std::ranges::any_of( @@ -383,12 +384,12 @@ TEST_F(FinanceTest, shouldGenerateLitecoinAddress) TEST_F(FinanceTest, shouldGenerateEthereumAddress) { - const auto ethereumAddress = Finance::ethereumAddress(); + const auto generatedEthereumAddress = ethereumAddress(); - const auto prefix = ethereumAddress.substr(0, 2); - const auto hexNumber = ethereumAddress.substr(2); + const auto prefix = generatedEthereumAddress.substr(0, 2); + const auto hexNumber = generatedEthereumAddress.substr(2); - ASSERT_EQ(ethereumAddress.size(), 42); + ASSERT_EQ(generatedEthereumAddress.size(), 42); ASSERT_EQ(prefix, "0x"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) { return hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); @@ -396,7 +397,7 @@ TEST_F(FinanceTest, shouldGenerateEthereumAddress) TEST_F(FinanceTest, shouldGenerateExpirationDate) { - const auto expirationDate = Finance::creditCardExpirationDate(); + const auto expirationDate = creditCardExpirationDate(); const int tenthPlaceYear = std::stoi(expirationDate.substr(3, 2)); @@ -405,12 +406,12 @@ TEST_F(FinanceTest, shouldGenerateExpirationDate) TEST_F(FinanceTest, shouldGenerateRandomCreditCardTypeName) { - const auto creditCardTypeName = Finance::creditCardType(); + const auto creditCardTypeName = creditCardType(); ASSERT_TRUE(std::find(creditCardNames.begin(), creditCardNames.end(), creditCardTypeName) != creditCardNames.end()); } -class FinanceBicTest : public TestWithParam +class FinanceBicTest : public TestWithParam { }; @@ -418,19 +419,19 @@ TEST_P(FinanceBicTest, CheckBicGenerator) { const auto country = GetParam(); - const auto bic = Finance::bic(country); + const auto generatedBic = bic(country); const auto& bankIdentifiersCodes = bicCountriesCodes.at(country); - ASSERT_TRUE(std::ranges::any_of(bankIdentifiersCodes, [bic](const std::string_view& bankIdentifierCode) - { return bic == bankIdentifierCode; })); + ASSERT_TRUE(std::ranges::any_of(bankIdentifiersCodes, [generatedBic](const std::string_view& bankIdentifierCode) + { return generatedBic == bankIdentifierCode; })); } INSTANTIATE_TEST_SUITE_P(TestBicGenerator, FinanceBicTest, - Values(Finance::BicCountry::Poland, Finance::BicCountry::UnitedStates, - Finance::BicCountry::UnitedKingdom, Finance::BicCountry::Germany, - Finance::BicCountry::Romania, Finance::BicCountry::France, Finance::BicCountry::Italy, - Finance::BicCountry::Spain, Finance::BicCountry::Netherlands, - Finance::BicCountry::India), - [](const TestParamInfo& paramInfo) + Values(BicCountry::Poland, BicCountry::UnitedStates, + BicCountry::UnitedKingdom, BicCountry::Germany, + BicCountry::Romania, BicCountry::France, BicCountry::Italy, + BicCountry::Spain, BicCountry::Netherlands, + BicCountry::India), + [](const TestParamInfo& paramInfo) { return generatedBicTestName.at(paramInfo.param); });