diff --git a/include/faker-cxx/String.h b/include/faker-cxx/String.h index f8ae6478c..41b5822cc 100644 --- a/include/faker-cxx/String.h +++ b/include/faker-cxx/String.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "RandomGenerator.h" #include "types/Hex.h" @@ -27,16 +27,16 @@ struct CharCount }; /** - * A std::unordered_map where user can specify the count required for specific chars + * A std::map where user can specify the count required for specific chars */ -using GuaranteeMap = std::unordered_map; +using GuaranteeMap = std::map; /** * @brief Checks if the given guarantee map is valid for given targetCharacters and length. * * @returns a bool. * - * @param guarantee A std::unordered_map that maps the count range of specific characters required + * @param guarantee A std::map that maps the count range of specific characters required * @param targetCharacters A std::string consisting of all chars available for that string generating function * @param length The number of characters to generate. * @@ -54,7 +54,7 @@ bool isValidGuarantee(GuaranteeMap& guarantee, std::set& targetCharacters, * * @returns least required std::string * - * @param guarantee A std::unordered_map which stores the guarantee specified by the user + * @param guarantee A std::map which stores the guarantee specified by the user * * @code * GuaranteeMap guarantee { {'0',{3,10}},{'a',{6,8}} }; // "000aaaaaa" diff --git a/src/modules/internet/Internet.cpp b/src/modules/internet/Internet.cpp index 12f5effb6..c2c0a5f2a 100644 --- a/src/modules/internet/Internet.cpp +++ b/src/modules/internet/Internet.cpp @@ -8,7 +8,7 @@ #include "common/FormatHelper.h" #include "common/StringHelper.h" -#include "modules/string/data/Characters.h" +#include "modules/string/StringData.h" #include "InternetData.h" #include "faker-cxx/Helper.h" #include "faker-cxx/Person.h" @@ -126,22 +126,22 @@ std::string Internet::password(int length, const PasswordOptions& options) if (options.upperLetters) { - characters += faker::upperCharacters; + characters += faker::string::upperCharacters; } if (options.lowerLetters) { - characters += faker::lowerCharacters; + characters += faker::string::lowerCharacters; } if (options.numbers) { - characters += faker::numericCharacters; + characters += faker::string::numericCharacters; } if (options.symbols) { - characters += faker::symbolCharacters; + characters += faker::string::symbolCharacters; } std::string password; diff --git a/src/modules/string/String.cpp b/src/modules/string/String.cpp index b92df5199..e275dac66 100644 --- a/src/modules/string/String.cpp +++ b/src/modules/string/String.cpp @@ -4,8 +4,10 @@ #include #include #include +#include +#include -#include "data/Characters.h" +#include "StringData.h" #include "faker-cxx/Helper.h" #include "faker-cxx/Number.h" @@ -13,35 +15,35 @@ namespace faker { namespace { -const std::unordered_map stringCasingToAlphaCharactersMapping{ - {StringCasing::Lower, lowerCharacters}, - {StringCasing::Upper, upperCharacters}, - {StringCasing::Mixed, mixedAlphaCharacters}, +const std::map stringCasingToAlphaCharactersMapping{ + {StringCasing::Lower, string::lowerCharacters}, + {StringCasing::Upper, string::upperCharacters}, + {StringCasing::Mixed, string::mixedAlphaCharacters}, }; -const std::unordered_map stringCasingToAlphanumericCharactersMapping{ - {StringCasing::Lower, lowerAlphanumericCharacters}, - {StringCasing::Upper, upperAlphanumericCharacters}, - {StringCasing::Mixed, mixedAlphanumericCharacters}, +const std::map stringCasingToAlphanumericCharactersMapping{ + {StringCasing::Lower, string::lowerAlphanumericCharacters}, + {StringCasing::Upper, string::upperAlphanumericCharacters}, + {StringCasing::Mixed, string::mixedAlphanumericCharacters}, }; -const std::unordered_map hexCasingToCharactersMapping{ - {HexCasing::Lower, hexLowerCharacters}, - {HexCasing::Upper, hexUpperCharacters}, +const std::map hexCasingToCharactersMapping{ + {HexCasing::Lower, string::hexLowerCharacters}, + {HexCasing::Upper, string::hexUpperCharacters}, }; -const std::unordered_map hexPrefixToStringMapping{ +const std::map hexPrefixToStringMapping{ {HexPrefix::ZeroX, "0x"}, {HexPrefix::Hash, "#"}, {HexPrefix::None, ""}, }; -const std::unordered_map> stringCasingToAlphaCharSetMapping{ - {StringCasing::Lower, lowerCharSet}, - {StringCasing::Upper, upperCharSet}, - {StringCasing::Mixed, mixedAlphaCharSet}, +const std::map> stringCasingToAlphaCharSetMapping{ + {StringCasing::Lower, string::lowerCharSet}, + {StringCasing::Upper, string::upperCharSet}, + {StringCasing::Mixed, string::mixedAlphaCharSet}, }; -const std::unordered_map> hexCasingToCharSetMapping{ - {HexCasing::Lower, hexLowerCharSet}, - {HexCasing::Upper, hexUpperCharSet}, +const std::map> hexCasingToCharSetMapping{ + {HexCasing::Lower, string::hexLowerCharSet}, + {HexCasing::Upper, string::hexUpperCharSet}, }; } @@ -52,8 +54,10 @@ bool isValidGuarantee(GuaranteeMap& guarantee, std::set& targetCharacters, for (auto& it : guarantee) { // if a char in guarantee is not in char set, it is an invalid guarantee - if (targetCharacters.find(it.first) == targetCharacters.end()) + if (std::find(targetCharacters.begin(), targetCharacters.end(), it.first) == targetCharacters.end()) + { return false; + } atleastCountSum += it.second.atLeastCount; atmostCountSum += it.second.atMostCount; } @@ -131,7 +135,7 @@ std::string String::sample(unsigned int length) std::string String::sample(GuaranteeMap&& guarantee, unsigned int length) { - auto targetCharacters = utf16CharSet; + auto targetCharacters = string::utf16CharSet; // throw if guarantee is invalid if (!isValidGuarantee(guarantee, targetCharacters, length)) { @@ -228,7 +232,7 @@ std::string String::alphanumeric(unsigned int length, StringCasing casing, const std::string String::alphanumeric(GuaranteeMap&& guarantee, unsigned length, StringCasing casing) { - auto targetCharacters = digitSet; + auto targetCharacters = string::digitSet; auto charSet = stringCasingToAlphaCharSetMapping.at(casing); targetCharacters.merge(charSet); // throw if guarantee is invalid @@ -247,11 +251,11 @@ std::string String::numeric(unsigned int length, bool allowLeadingZeros) { if (i == 0 && allowLeadingZeros) { - alphanumeric += Helper::arrayElement(numericCharacters); + alphanumeric += Helper::arrayElement(string::numericCharacters); } else { - alphanumeric += Helper::arrayElement(numericCharactersWithoutZero); + alphanumeric += Helper::arrayElement(string::numericCharactersWithoutZero); } } @@ -269,7 +273,7 @@ std::string String::numeric(GuaranteeMap&& guarantee, const unsigned length, boo throw std::invalid_argument{"Invalid guarantee."}; } } - auto targetCharacters = digitSet; + auto targetCharacters = string::digitSet; // throw if guarantee is invalid if (!isValidGuarantee(guarantee, targetCharacters, length)) { diff --git a/src/modules/string/StringData.h b/src/modules/string/StringData.h new file mode 100644 index 000000000..d599a0ac0 --- /dev/null +++ b/src/modules/string/StringData.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +namespace faker::string { + +static const std::string upperCharacters{"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; +static const std::string lowerCharacters{"abcdefghijklmnopqrstuvwxyz"}; +static const std::string numericCharactersWithoutZero{"123456789"}; +static const std::string numericCharacters{"0123456789"}; +static const std::string mixedAlphaCharacters{upperCharacters + lowerCharacters}; +static const std::string lowerAlphanumericCharacters{lowerCharacters + numericCharacters}; +static const std::string upperAlphanumericCharacters{upperCharacters + numericCharacters}; +static const std::string mixedAlphanumericCharacters{upperCharacters + lowerCharacters + numericCharacters}; +static const std::string hexUpperCharacters{"0123456789ABCDEF"}; +static const std::string hexLowerCharacters{"0123456789abcdef"}; +static const std::string symbolCharacters{"~`!@#$%^&*()_-+={[}]|:;\"'<,>.?/"}; + +static const std::set lowerCharSet{ + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', +}; + +static const std::set upperCharSet{ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', +}; + +static const std::set mixedAlphaCharSet{ + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', + 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', +}; + +static const std::set hexUpperCharSet{ + 'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' +}; + +static const std::set hexLowerCharSet{ + 'a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' +}; + +static const std::set digitSet{ + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' +}; + +static const std::set utf16CharSet{ + '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', + 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', + 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', +}; +} diff --git a/src/modules/string/data/Characters.h b/src/modules/string/data/Characters.h deleted file mode 100644 index b16fadfd1..000000000 --- a/src/modules/string/data/Characters.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::string upperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -const std::string lowerCharacters = "abcdefghijklmnopqrstuvwxyz"; -const std::string numericCharactersWithoutZero = "123456789"; -const std::string numericCharacters = "0123456789"; -const std::string mixedAlphaCharacters = upperCharacters + lowerCharacters; -const std::string lowerAlphanumericCharacters = lowerCharacters + numericCharacters; -const std::string upperAlphanumericCharacters = upperCharacters + numericCharacters; -const std::string mixedAlphanumericCharacters = upperCharacters + lowerCharacters + numericCharacters; -const std::string hexUpperCharacters = "0123456789ABCDEF"; -const std::string hexLowerCharacters = "0123456789abcdef"; -const std::string symbolCharacters = "~`!@#$%^&*()_-+={[}]|:;\"'<,>.?/"; - -const std::set lowerCharSet{ - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', -}; -const std::set upperCharSet{ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', -}; -const std::set mixedAlphaCharSet{ - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', - 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', -}; -const std::set hexUpperCharSet{'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; -const std::set hexLowerCharSet{'a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; -const std::set digitSet{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; -const std::set utf16CharSet{ - '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', - 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', - 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', -}; -} diff --git a/tests/modules/color/ColorTest.cpp b/tests/modules/color/ColorTest.cpp index bdccebe80..ee38ab69c 100644 --- a/tests/modules/color/ColorTest.cpp +++ b/tests/modules/color/ColorTest.cpp @@ -7,7 +7,7 @@ #include "color/ColorData.h" #include "common/StringHelper.h" -#include "string/data/Characters.h" +#include "string/StringData.h" using namespace ::testing; using namespace faker; @@ -73,7 +73,7 @@ TEST_F(ColorTest, shouldGenerateHexColorWithoutAlpha) ASSERT_EQ(hexadecimal.size(), 7); ASSERT_EQ(prefix, "#"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) - { return hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); } TEST_F(ColorTest, shouldGenerateHexColorWithAlpha) @@ -86,7 +86,7 @@ TEST_F(ColorTest, shouldGenerateHexColorWithAlpha) ASSERT_EQ(hexadecimal.size(), 10); ASSERT_EQ(prefix, "0x"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) - { return hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); } TEST_F(ColorTest, shouldGenerateHslWithoutAlpha) diff --git a/tests/modules/commerce/CommerceTest.cpp b/tests/modules/commerce/CommerceTest.cpp index b70176e00..364411252 100644 --- a/tests/modules/commerce/CommerceTest.cpp +++ b/tests/modules/commerce/CommerceTest.cpp @@ -6,7 +6,7 @@ #include "commerce/CommerceData.h" #include "common/StringHelper.h" -#include "string/data/Characters.h" +#include "string/StringData.h" using namespace ::testing; using namespace faker; @@ -47,7 +47,7 @@ TEST_F(CommerceTest, shouldGenerateSku) ASSERT_TRUE(std::ranges::all_of(sku, [](char skuCharacter) { - return std::ranges::any_of(numericCharacters, + return std::ranges::any_of(string::numericCharacters, [skuCharacter](char numericCharacter) { return skuCharacter == numericCharacter; }); })); @@ -63,7 +63,7 @@ TEST_F(CommerceTest, shouldGenerateSkuWithSpecifiedLength) ASSERT_TRUE(std::ranges::all_of(sku, [](char skuCharacter) { - return std::ranges::any_of(numericCharacters, + return std::ranges::any_of(string::numericCharacters, [skuCharacter](char numericCharacter) { return skuCharacter == numericCharacter; }); })); @@ -279,7 +279,7 @@ TEST_F(CommerceTest, shouldGenerateDiscountCode) [](char generatedDiscountCodeCharacter) { return std::ranges::any_of( - upperAlphanumericCharacters, + string::upperAlphanumericCharacters, [generatedDiscountCodeCharacter](char upperAlphanumericCharacter) { return upperAlphanumericCharacter == generatedDiscountCodeCharacter; }); })); @@ -310,7 +310,7 @@ TEST_F(CommerceTest, shouldGenerateOrderNumber) TEST_F(CommerceTest, shouldGenerateOrderStatus) { const auto generatedOrderStatus = Commerce::orderStatus(); - + ASSERT_TRUE(std::ranges::any_of(orderStatuses, [generatedOrderStatus](const std::string_view& orderStatus) { return orderStatus == generatedOrderStatus; })); } diff --git a/tests/modules/database/DatabaseTest.cpp b/tests/modules/database/DatabaseTest.cpp index 8f91ffa95..4bf40462c 100644 --- a/tests/modules/database/DatabaseTest.cpp +++ b/tests/modules/database/DatabaseTest.cpp @@ -5,7 +5,7 @@ #include "gtest/gtest.h" #include "database/DatabaseData.h" -#include "string/data/Characters.h" +#include "string/StringData.h" using namespace ::testing; using namespace faker; @@ -53,5 +53,5 @@ TEST_F(DatabaseTest, shouldGenerateMongoDbObjectId) ASSERT_EQ(mongoDbObjectId.size(), 24); ASSERT_TRUE(std::ranges::any_of(mongoDbObjectId, [](char hexNumberCharacter) - { return hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); } diff --git a/tests/modules/finance/FinanceTest.cpp b/tests/modules/finance/FinanceTest.cpp index c960f8d21..74514802f 100644 --- a/tests/modules/finance/FinanceTest.cpp +++ b/tests/modules/finance/FinanceTest.cpp @@ -11,7 +11,7 @@ #include "common/StringHelper.h" #include "finance/FinanceData.h" #include "gmock/gmock.h" -#include "string/data/Characters.h" +#include "string/StringData.h" using namespace ::testing; using namespace faker; @@ -101,7 +101,7 @@ class FinanceTest : public TestWithParam return std::ranges::all_of(data, [](char dataCharacter) { - return std::ranges::any_of(numericCharacters, + return std::ranges::any_of(string::numericCharacters, [dataCharacter](char numericCharacter) { return numericCharacter == dataCharacter; }); }); @@ -388,7 +388,7 @@ TEST_F(FinanceTest, shouldGenerateEthereumAddress) ASSERT_EQ(ethereumAddress.size(), 42); ASSERT_EQ(prefix, "0x"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) - { return hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); } TEST_F(FinanceTest, shouldGenerateExpirationDate) diff --git a/tests/modules/internet/InternetTest.cpp b/tests/modules/internet/InternetTest.cpp index 042063252..cbed96904 100644 --- a/tests/modules/internet/InternetTest.cpp +++ b/tests/modules/internet/InternetTest.cpp @@ -12,7 +12,7 @@ #include "person/data/england/EnglishLastNames.h" #include "person/data/romania/RomanianFirstNames.h" #include "person/data/romania/RomanianLastNames.h" -#include "string/data/Characters.h" +#include "string/StringData.h" #include "word/data/Adjectives.h" #include "word/data/Nouns.h" #include "internet/InternetData.h" @@ -649,7 +649,7 @@ TEST_F(InternetTest, shouldGenerateIpv6) { return std::ranges::all_of( generatedIpv6Part, [](char hexCharacter) - { return hexLowerCharacters.find(hexCharacter) != std::string::npos; }); + { return string::hexLowerCharacters.find(hexCharacter) != std::string::npos; }); })); } diff --git a/tests/modules/location/LocationTest.cpp b/tests/modules/location/LocationTest.cpp index 8fd2e83db..97a8edc38 100644 --- a/tests/modules/location/LocationTest.cpp +++ b/tests/modules/location/LocationTest.cpp @@ -22,7 +22,7 @@ #include "person/data/spain/SpanishLastNames.h" #include "person/data/ukraine/UkrainianFirstNames.h" #include "person/data/ukraine/UkrainianLastNames.h" -#include "string/data/Characters.h" +#include "string/StringData.h" using namespace ::testing; using namespace faker; @@ -115,7 +115,7 @@ class LocationTest : public TestWithParam return std::ranges::all_of(data, [](char dataCharacter) { - return std::ranges::any_of(numericCharacters, + return std::ranges::any_of(string::numericCharacters, [dataCharacter](char numericCharacter) { return numericCharacter == dataCharacter; }); }); @@ -123,7 +123,7 @@ class LocationTest : public TestWithParam static bool checkIfCharacterIsNumeric(char character) { - return std::ranges::any_of(numericCharacters, + return std::ranges::any_of(string::numericCharacters, [character](char numericCharacter) { return numericCharacter == character; }); } }; diff --git a/tests/modules/string/StringTest.cpp b/tests/modules/string/StringTest.cpp index cc6e852fc..e4ac0c7f3 100644 --- a/tests/modules/string/StringTest.cpp +++ b/tests/modules/string/StringTest.cpp @@ -6,7 +6,7 @@ #include "gtest/gtest.h" -#include "string/data/Characters.h" +#include "string/StringData.h" #include "faker-cxx/RandomGenerator.h" using namespace ::testing; @@ -384,7 +384,7 @@ TEST_F(StringTest, shouldGenerateDefaultApha) ASSERT_EQ(alpha.size(), 1); ASSERT_TRUE( - std::ranges::any_of(mixedAlphaCharacters, [alpha](char mixedCharacter) { return alpha[0] == mixedCharacter; })); + std::ranges::any_of(string::mixedAlphaCharacters, [alpha](char mixedCharacter) { return alpha[0] == mixedCharacter; })); } TEST_F(StringTest, shouldGenerateMixedAlpha) @@ -397,7 +397,7 @@ TEST_F(StringTest, shouldGenerateMixedAlpha) ASSERT_TRUE(std::ranges::all_of(alpha, [](char alphaCharacter) { - return std::ranges::any_of(mixedAlphaCharacters, + return std::ranges::any_of(string::mixedAlphaCharacters, [alphaCharacter](char mixedCharacter) { return mixedCharacter == alphaCharacter; }); })); @@ -413,7 +413,7 @@ TEST_F(StringTest, shouldGenerateUpperAlpha) ASSERT_TRUE(std::ranges::all_of(alpha, [](char alphaCharacter) { - return std::ranges::any_of(upperCharacters, + return std::ranges::any_of(string::upperCharacters, [alphaCharacter](char upperCharacter) { return upperCharacter == alphaCharacter; }); })); @@ -429,7 +429,7 @@ TEST_F(StringTest, shouldGenerateLowerAlpha) ASSERT_TRUE(std::ranges::all_of(alpha, [](char alphaCharacter) { - return std::ranges::any_of(lowerCharacters, + return std::ranges::any_of(string::lowerCharacters, [alphaCharacter](char lowerCharacter) { return lowerCharacter == alphaCharacter; }); })); @@ -452,7 +452,7 @@ TEST_F(StringTest, shouldGenerateMixedAlphaWithGuarantee) ASSERT_TRUE(std::ranges::all_of(alpha, [](char alphaCharacter) { - return std::ranges::any_of(mixedAlphaCharacters, + return std::ranges::any_of(string::mixedAlphaCharacters, [alphaCharacter](char mixedCharacter) { return mixedCharacter == alphaCharacter; }); })); @@ -485,7 +485,7 @@ TEST_F(StringTest, shouldGenerateLowerAlphaWithGuarantee) ASSERT_TRUE(std::ranges::all_of(alpha, [](char alphaCharacter) { - return std::ranges::any_of(lowerCharSet, + return std::ranges::any_of(string::lowerCharSet, [alphaCharacter](char lowerCharacter) { return lowerCharacter == alphaCharacter; }); })); @@ -518,7 +518,7 @@ TEST_F(StringTest, shouldGenerateUpperAlphaWithGuarantee) ASSERT_TRUE(std::ranges::all_of(alpha, [](char alphaCharacter) { - return std::ranges::any_of(upperCharSet, + return std::ranges::any_of(string::upperCharSet, [alphaCharacter](char lowerCharacter) { return lowerCharacter == alphaCharacter; }); })); @@ -588,7 +588,7 @@ TEST_F(StringTest, shouldGenerateDefaultAphanumeric) const auto alphanumeric = String::alphanumeric(); ASSERT_EQ(alphanumeric.size(), 1); - ASSERT_TRUE(std::ranges::any_of(mixedAlphanumericCharacters, + ASSERT_TRUE(std::ranges::any_of(string::mixedAlphanumericCharacters, [alphanumeric](char mixedCharacter) { return alphanumeric[0] == mixedCharacter; })); } @@ -603,7 +603,7 @@ TEST_F(StringTest, shouldGenerateMixedAlphanumeric) [](char alphanumericCharacter) { return std::ranges::any_of( - mixedAlphanumericCharacters, + string::mixedAlphanumericCharacters, [alphanumericCharacter](char mixedAlphanumericCharacter) { return alphanumericCharacter == mixedAlphanumericCharacter; }); })); @@ -620,7 +620,7 @@ TEST_F(StringTest, shouldGenerateUpperAlphanumeric) [](char alphanumericCharacter) { return std::ranges::any_of( - upperAlphanumericCharacters, + string::upperAlphanumericCharacters, [alphanumericCharacter](char upperAlphanumericCharacter) { return upperAlphanumericCharacter == alphanumericCharacter; }); })); @@ -637,7 +637,7 @@ TEST_F(StringTest, shouldGenerateLowerAlphanumeric) [](char alphanumericCharacter) { return std::ranges::any_of( - lowerAlphanumericCharacters, + string::lowerAlphanumericCharacters, [alphanumericCharacter](char lowerAlphanumericCharacter) { return lowerAlphanumericCharacter == alphanumericCharacter; }); })); @@ -661,7 +661,7 @@ TEST_F(StringTest, shouldGenerateMixedAlphanumericWithGuarantee) alphanumeric, [](char alphanumericCharacter) { - return std::ranges::any_of(mixedAlphanumericCharacters, [alphanumericCharacter](char mixedCharacter) + return std::ranges::any_of(string::mixedAlphanumericCharacters, [alphanumericCharacter](char mixedCharacter) { return mixedCharacter == alphanumericCharacter; }); })); auto count_1 = std::ranges::count(alphanumeric, '1'); @@ -695,7 +695,7 @@ TEST_F(StringTest, shouldGenerateLowerAlphanumericWithGuarantee) alphanumeric, [](char alphanumericCharacter) { - return std::ranges::any_of(lowerAlphanumericCharacters, [alphanumericCharacter](char lowerCharacter) + return std::ranges::any_of(string::lowerAlphanumericCharacters, [alphanumericCharacter](char lowerCharacter) { return lowerCharacter == alphanumericCharacter; }); })); auto count_k = std::ranges::count(alphanumeric, 'k'); @@ -729,7 +729,7 @@ TEST_F(StringTest, shouldGenerateUpperAlphanumericWithGuarantee) alphanumeric, [](char alphanumericCharacter) { - return std::ranges::any_of(upperAlphanumericCharacters, [alphanumericCharacter](char lowerCharacter) + return std::ranges::any_of(string::upperAlphanumericCharacters, [alphanumericCharacter](char lowerCharacter) { return lowerCharacter == alphanumericCharacter; }); })); auto count_7 = std::ranges::count(alphanumeric, '7'); @@ -818,13 +818,13 @@ TEST_F(StringTest, shouldGenerateNumericWithoutLeadingZeros) const auto numericWithPossibleZeroCharacters = numeric.substr(1); ASSERT_EQ(numeric.size(), numericLength); - ASSERT_TRUE(std::ranges::any_of(numericCharactersWithoutZero, [nonZeroCharacter](char numericCharacter) + ASSERT_TRUE(std::ranges::any_of(string::numericCharactersWithoutZero, [nonZeroCharacter](char numericCharacter) { return nonZeroCharacter == numericCharacter; })); ASSERT_TRUE(std::ranges::all_of(numericWithPossibleZeroCharacters, [](char numericCharacterWithPossibleZero) { return std::ranges::any_of( - numericCharacters, [numericCharacterWithPossibleZero](char numericCharacter) + string::numericCharacters, [numericCharacterWithPossibleZero](char numericCharacter) { return numericCharacterWithPossibleZero == numericCharacter; }); })); } @@ -897,13 +897,13 @@ TEST_F(StringTest, shouldGenerateNumericWithoutLeadingZerosWithGuarantee1) const auto numericWithPossibleZeroCharacters = numeric.substr(1); ASSERT_EQ(numeric.size(), numericLength); - ASSERT_TRUE(std::ranges::any_of(numericCharactersWithoutZero, [nonZeroCharacter](char numericCharacter) + ASSERT_TRUE(std::ranges::any_of(string::numericCharactersWithoutZero, [nonZeroCharacter](char numericCharacter) { return nonZeroCharacter == numericCharacter; })); ASSERT_TRUE(std::ranges::all_of( numericWithPossibleZeroCharacters, [](char numericCharacterWithPossibleZero) { - return std::ranges::any_of(numericCharacters, [numericCharacterWithPossibleZero](char numericCharacter) + return std::ranges::any_of(string::numericCharacters, [numericCharacterWithPossibleZero](char numericCharacter) { return numericCharacterWithPossibleZero == numericCharacter; }); })); auto count_0 = std::ranges::count(numeric, '0'); @@ -928,13 +928,13 @@ TEST_F(StringTest, shouldGenerateNumericWithoutLeadingZerosWithGuarantee2) const auto numericWithPossibleZeroCharacters = numeric.substr(1); ASSERT_EQ(numeric.size(), numericLength); - ASSERT_TRUE(std::ranges::any_of(numericCharactersWithoutZero, [nonZeroCharacter](char numericCharacter) + ASSERT_TRUE(std::ranges::any_of(string::numericCharactersWithoutZero, [nonZeroCharacter](char numericCharacter) { return nonZeroCharacter == numericCharacter; })); ASSERT_TRUE(std::ranges::all_of( numericWithPossibleZeroCharacters, [](char numericCharacterWithPossibleZero) { - return std::ranges::any_of(numericCharacters, [numericCharacterWithPossibleZero](char numericCharacter) + return std::ranges::any_of(string::numericCharacters, [numericCharacterWithPossibleZero](char numericCharacter) { return numericCharacterWithPossibleZero == numericCharacter; }); })); auto count_0 = std::ranges::count(numeric, '0'); @@ -995,7 +995,7 @@ TEST_F(StringTest, shouldGenerateHexadecimal) ASSERT_EQ(hexadecimal.size(), hexadecimalLength + 2); ASSERT_EQ(prefix, "0x"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) - { return hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); } TEST_F(StringTest, shouldGenerateHexadecimalWithHashPrefix) @@ -1010,7 +1010,7 @@ TEST_F(StringTest, shouldGenerateHexadecimalWithHashPrefix) ASSERT_EQ(hexadecimal.size(), hexadecimalLength + 1); ASSERT_EQ(prefix, "#"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [](char hexNumberCharacter) - { return hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); } TEST_F(StringTest, shouldGenerateHexadecimalWithoutPrefix) @@ -1021,7 +1021,7 @@ TEST_F(StringTest, shouldGenerateHexadecimalWithoutPrefix) ASSERT_EQ(hexadecimal.size(), hexadecimalLength); ASSERT_TRUE(std::ranges::any_of(hexadecimal, [](char hexNumberCharacter) - { return hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); } TEST_F(StringTest, shouldGenerateHexadecimalWithGuarantee1) @@ -1042,7 +1042,7 @@ TEST_F(StringTest, shouldGenerateHexadecimalWithGuarantee1) ASSERT_EQ(hexNumber.size(), hexadecimalLength); ASSERT_EQ(prefix, "0x"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) - { return hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexLowerCharacters.find(hexNumberCharacter) != std::string::npos; })); auto count_a = std::ranges::count(hexNumber, 'a'); auto count_f = std::ranges::count(hexNumber, 'f'); @@ -1068,7 +1068,7 @@ TEST_F(StringTest, shouldGenerateHexadecimalWithGuarantee2) ASSERT_EQ(hexNumber.size(), hexadecimalLength); ASSERT_EQ(prefix, "0x"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) - { return hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); auto count_A = std::ranges::count(hexNumber, 'A'); auto count_F = std::ranges::count(hexNumber, 'F'); @@ -1098,7 +1098,7 @@ TEST_F(StringTest, shouldGenerateHexadecimalWithGuarantee3) ASSERT_EQ(hexNumber.size(), hexadecimalLength); ASSERT_EQ(prefix, "0x"); ASSERT_TRUE(std::ranges::any_of(hexNumber, [hexNumber](char hexNumberCharacter) - { return hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); + { return string::hexUpperCharacters.find(hexNumberCharacter) != std::string::npos; })); auto count_0 = std::ranges::count(hexNumber, '0'); auto count_1 = std::ranges::count(hexNumber, '1');