diff --git a/include/faker-cxx/Crypto.h b/include/faker-cxx/Crypto.h index 6947be8b6..6319b4355 100644 --- a/include/faker-cxx/Crypto.h +++ b/include/faker-cxx/Crypto.h @@ -15,7 +15,7 @@ class Crypto * * @code * Crypto::sha256("hello world") // "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" - * Crypto::sha256() // Random hash of random word + * Crypto::sha256() // Random hash of random * @endcode */ static std::string sha256(std::optional = std::nullopt); diff --git a/include/faker-cxx/Word.h b/include/faker-cxx/Word.h index fe1e49e3d..0e12d522b 100644 --- a/include/faker-cxx/Word.h +++ b/include/faker-cxx/Word.h @@ -4,143 +4,139 @@ #include #include -namespace faker +namespace faker::word { -class Word -{ -public: - /** - * @brief Returns a random word. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Random sample word. - * - * @code - * Word::sample() // "protection" - * Word::sample(5) // "spell" - * @endcode - */ - static std::string_view sample(std::optional length = std::nullopt); +/** + * @brief Returns a random . + * + * @param length The expected length of the . + * If no with given length will be found, it will return a random . + * + * @returns Random sample word. + * + * @code + * word::sample() // "protection" + * word::sample(5) // "spell" + * @endcode + */ +std::string_view sample(std::optional length = std::nullopt); - /** - * @brief Returns a string containing a number of space separated random words. - * - * @param numberOfWords The number of words to generate. - * - * @returns Random words separated with spaces. - * - * @code - * Word::words() // "protection" - * Word::words(5) // "before hourly patiently dribble equal" - * @endcode - */ - static std::string words(unsigned numberOfWords = 1); +/** + * @brief Returns a string containing a number of space separated random words. + * + * @param numberOfWords The number of words to generate. + * + * @returns Random words separated with spaces. + * + * @code + * word::words() // "protection" + * word::words(5) // "before hourly patiently dribble equal" + * @endcode + */ +std::string words(unsigned numberOfWords = 1); - /** - * @brief Returns a random adjective. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Adjective. - * - * @code - * Word::adjective() // "complete" - * Word::adjective(3) // "bad" - * @endcode - */ - static std::string_view adjective(std::optional length = std::nullopt); +/** + * @brief Returns a random adjective. + * + * @param length The expected length of the word. + * If no word with given length will be found, it will return a random word. + * + * @returns Adjective. + * + * @code + * word::adjective() // "complete" + * word::adjective(3) // "bad" + * @endcode + */ +std::string_view adjective(std::optional length = std::nullopt); - /** - * @brief Returns a random adverb. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Adverb. - * - * @code - * Word::adverb() // "deliberately" - * Word::adverb(5) // "almost" - * @endcode - */ - static std::string_view adverb(std::optional length = std::nullopt); +/** + * @brief Returns a random adverb. + * + * @param length The expected length of the word. + * If no word with given length will be found, it will return a random word. + * + * @returns Adverb. + * + * @code + * word::adverb() // "deliberately" + * word::adverb(5) // "almost" + * @endcode + */ +std::string_view adverb(std::optional length = std::nullopt); - /** - * @brief Returns a random conjunction. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Conjunction. - * - * @code - * Word::conjunction() // "because" - * Word::conjunction(6) // "indeed" - * @endcode - */ - static std::string_view conjunction(std::optional length = std::nullopt); +/** + * @brief Returns a random conjunction. + * + * @param length The expected length of the word. + * If no word with given length will be found, it will return a random word. + * + * @returns Conjunction. + * + * @code + * word::conjunction() // "because" + * word::conjunction(6) // "indeed" + * @endcode + */ +std::string_view conjunction(std::optional length = std::nullopt); - /** - * @brief Returns a random interjection. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Interjection. - * - * @code - * Word::interjection() // "psst" - * Word::interjection(4) // "yuck" - * @endcode - */ - static std::string_view interjection(std::optional length = std::nullopt); +/** + * @brief Returns a random interjection. + * + * @param length The expected length of the word. + * If no word with given length will be found, it will return a random word. + * + * @returns Interjection. + * + * @code + * word::interjection() // "psst" + * word::interjection(4) // "yuck" + * @endcode + */ +std::string_view interjection(std::optional length = std::nullopt); - /** - * @brief Returns a random noun. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Noun. - * - * @code - * Word::noun() // "pudding" - * Word::noun(8) // "distance" - * @endcode - */ - static std::string_view noun(std::optional length = std::nullopt); +/** + * @brief Returns a random noun. + * + * @param length The expected length of the word. + * If no word with given length will be found, it will return a random word. + * + * @returns Noun. + * + * @code + * word::noun() // "pudding" + * word::noun(8) // "distance" + * @endcode + */ +std::string_view noun(std::optional length = std::nullopt); - /** - * @brief Returns a random preposition. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Preposition. - * - * @code - * Word::preposition() // "besides" - * Word::preposition(4) // "from" - * @endcode - */ - static std::string_view preposition(std::optional length = std::nullopt); +/** + * @brief Returns a random preposition. + * + * @param length The expected length of the word. + * If no word with given length will be found, it will return a random word. + * + * @returns Preposition. + * + * @code + * word::preposition() // "besides" + * word::preposition(4) // "from" + * @endcode + */ +std::string_view preposition(std::optional length = std::nullopt); - /** - * @brief Returns a random verb. - * - * @param length The expected length of the word. - * If no word with given length will be found, it will return a random word. - * - * @returns Verb. - * - * @code - * Word::verb() // "override" - * Word::verb(9) // "stabilise" - * @endcode - */ - static std::string_view verb(std::optional length = std::nullopt); -}; +/** + * @brief Returns a random verb. + * + * @param length The expected length of the word. + * If no word with given length will be found, it will return a random word. + * + * @returns Verb. + * + * @code + * word::verb() // "override" + * word::verb(9) // "stabilise" + * @endcode + */ +std::string_view verb(std::optional length = std::nullopt); } diff --git a/src/modules/crypto/Crypto.cpp b/src/modules/crypto/Crypto.cpp index e1e293017..ea4e4dc6c 100644 --- a/src/modules/crypto/Crypto.cpp +++ b/src/modules/crypto/Crypto.cpp @@ -106,7 +106,7 @@ std::string Crypto::sha256(std::optional data) std::string orgData; if (!data.has_value() || data->empty()) { - orgData = Word::sample(); + orgData = word::sample(); } else { @@ -126,7 +126,7 @@ std::string Crypto::md5(std::optional data) std::string orgData; if (!data.has_value() || data->empty()) { - orgData = Word::sample(); + orgData = word::sample(); } else { diff --git a/src/modules/git/Git.cpp b/src/modules/git/Git.cpp index e997ad6b2..df6c19e0c 100644 --- a/src/modules/git/Git.cpp +++ b/src/modules/git/Git.cpp @@ -23,12 +23,12 @@ std::string Git::branch(unsigned maxIssueNum) switch (Number::integer(1, 3)) { case 1: - return FormatHelper::format("{}-{}", Word::verb(), Word::noun()); + return FormatHelper::format("{}-{}", word::verb(), word::noun()); case 2: - return FormatHelper::format("{}-{}-{}", Word::verb(), Word::adjective(), Word::noun()); + return FormatHelper::format("{}-{}-{}", word::verb(), word::adjective(), word::noun()); default: - return FormatHelper::format("{}-{}-{}-{}", Number::integer(unsigned(1), maxIssueNum), Word::verb(), - Word::adjective(), Word::noun()); + return FormatHelper::format("{}-{}-{}-{}", Number::integer(unsigned(1), maxIssueNum), word::verb(), + word::adjective(), word::noun()); } } @@ -114,13 +114,13 @@ std::string Git::commitMessage() switch (Number::integer(1, 4)) { case 1: - return FormatHelper::format("{} {}", Word::verb(), Word::noun()); + return FormatHelper::format("{} {}", word::verb(), word::noun()); case 2: - return FormatHelper::format("{} {} {}", Word::verb(), Word::adjective(), Word::noun()); + return FormatHelper::format("{} {} {}", word::verb(), word::adjective(), word::noun()); case 3: - return FormatHelper::format("{} {} {}", Word::verb(), Word::noun(), Word::adverb()); + return FormatHelper::format("{} {} {}", word::verb(), word::noun(), word::adverb()); default: - return FormatHelper::format("{} {} {} {}", Word::verb(), Word::adjective(), Word::noun(), Word::adverb()); + return FormatHelper::format("{} {} {} {}", word::verb(), word::adjective(), word::noun(), word::adverb()); } } diff --git a/src/modules/internet/Internet.cpp b/src/modules/internet/Internet.cpp index 015f29622..a64d91c01 100644 --- a/src/modules/internet/Internet.cpp +++ b/src/modules/internet/Internet.cpp @@ -328,7 +328,7 @@ std::string Internet::domainName() std::string Internet::domainWord() { - return StringHelper::toLower(FormatHelper::format("{}-{}", Word::adjective(), Word::noun())); + return StringHelper::toLower(FormatHelper::format("{}-{}", word::adjective(), word::noun())); } std::string_view Internet::domainSuffix() @@ -350,7 +350,7 @@ std::string Internet::anonymousUsername(unsigned maxLength) const auto nounLength = maxLength - adjectiveLength; - return FormatHelper::format("{}{}", Word::adjective(adjectiveLength), Word::noun(nounLength)); + return FormatHelper::format("{}{}", word::adjective(adjectiveLength), word::noun(nounLength)); } } diff --git a/src/modules/person/Person.cpp b/src/modules/person/Person.cpp index cda04a598..c930bf58d 100644 --- a/src/modules/person/Person.cpp +++ b/src/modules/person/Person.cpp @@ -327,7 +327,7 @@ std::string Person::bio() const std::unordered_map> dataGeneratorsMapping{ {"bio_part", []() { return Helper::arrayElement(bioParts); }}, {"bio_supporter", []() { return Helper::arrayElement(bioSupporters); }}, - {"noun", []() { return Word::noun(); }}, + {"noun", []() { return word::noun(); }}, {"emoji", []() { return Internet::emoji(); }}}; return FormatHelper::fillTokenValues(randomBioFormat, dataGeneratorsMapping); diff --git a/src/modules/system/System.cpp b/src/modules/system/System.cpp index 46b9ee9b9..be257a896 100644 --- a/src/modules/system/System.cpp +++ b/src/modules/system/System.cpp @@ -44,7 +44,7 @@ std::string_view extension(std::string_view mimeType) std::string System::fileName(const FileOptions& options) { - std::string baseName = Word::words(); + std::string baseName = word::words(); std::string extensionsStr; if (options.extensionCount > 0) diff --git a/src/modules/word/Word.cpp b/src/modules/word/Word.cpp index 937e79179..5a226418c 100644 --- a/src/modules/word/Word.cpp +++ b/src/modules/word/Word.cpp @@ -5,13 +5,14 @@ #include #include #include +#include #include #include "../../common/StringHelper.h" #include "data/All.h" #include "faker-cxx/Helper.h" -namespace faker +namespace faker::word { template auto sortedSizeArrayElement(std::optional length, It start, It end) -> decltype(*std::declval()) @@ -44,12 +45,12 @@ auto sortedSizeArrayElement(std::optional length, It start, It end } } -std::string_view Word::sample(std::optional length) +std::string_view sample(std::optional length) { return sortedSizeArrayElement(length, _allWords.cbegin(), _allWords.cend()); } -std::string Word::words(unsigned numberOfWords) +std::string words(unsigned numberOfWords) { if (numberOfWords == 0) { @@ -98,37 +99,37 @@ std::string Word::words(unsigned numberOfWords) return combined_words; } -std::string_view Word::adjective(std::optional length) +std::string_view adjective(std::optional length) { return sortedSizeArrayElement(length, _adjectives_sorted.cbegin(), _adjectives_sorted.cend()); } -std::string_view Word::adverb(std::optional length) +std::string_view adverb(std::optional length) { return sortedSizeArrayElement(length, _adverbs_sorted.cbegin(), _adverbs_sorted.cend()); } -std::string_view Word::conjunction(std::optional length) +std::string_view conjunction(std::optional length) { return sortedSizeArrayElement(length, _conjunctions_sorted.cbegin(), _conjunctions_sorted.cend()); } -std::string_view Word::interjection(std::optional length) +std::string_view interjection(std::optional length) { return sortedSizeArrayElement(length, _interjections_sorted.cbegin(), _interjections_sorted.cend()); } -std::string_view Word::noun(std::optional length) +std::string_view noun(std::optional length) { return sortedSizeArrayElement(length, _nouns_sorted.cbegin(), _nouns_sorted.cend()); } -std::string_view Word::preposition(std::optional length) +std::string_view preposition(std::optional length) { return sortedSizeArrayElement(length, _prepositions_sorted.cbegin(), _prepositions_sorted.cend()); } -std::string_view Word::verb(std::optional length) +std::string_view verb(std::optional length) { return sortedSizeArrayElement(length, _verbs_sorted.cbegin(), _verbs_sorted.cend()); } diff --git a/src/modules/word/data/Adjectives.h b/src/modules/word/data/Adjectives.h index b97ccb71e..815615f47 100644 --- a/src/modules/word/data/Adjectives.h +++ b/src/modules/word/data/Adjectives.h @@ -3,7 +3,7 @@ #include #include -namespace faker +namespace faker::word { const std::array adjectives = {"abandoned", "able", diff --git a/src/modules/word/data/Adverbs.h b/src/modules/word/data/Adverbs.h index 1446c3be1..4a933fc36 100644 --- a/src/modules/word/data/Adverbs.h +++ b/src/modules/word/data/Adverbs.h @@ -3,7 +3,7 @@ #include #include -namespace faker +namespace faker::word { const std::array adverbs = { "abnormally", diff --git a/src/modules/word/data/All.h b/src/modules/word/data/All.h index 671c45b69..a0aa95ffe 100644 --- a/src/modules/word/data/All.h +++ b/src/modules/word/data/All.h @@ -8,7 +8,7 @@ #include "Prepositions.h" #include "Verbs.h" -namespace faker +namespace faker::word { // https://tristanbrindle.com/posts/a-more-useful-compile-time-quicksort @@ -182,4 +182,4 @@ const auto _verbs_sorted = []() quick_sort(sorted.begin(), sorted.end(), [](const auto& lhs, const auto& rhs) { return lhs.size() < rhs.size(); }); return sorted; }(); -} \ No newline at end of file +} diff --git a/src/modules/word/data/Conjunctions.h b/src/modules/word/data/Conjunctions.h index 3d6caa19a..be900fe27 100644 --- a/src/modules/word/data/Conjunctions.h +++ b/src/modules/word/data/Conjunctions.h @@ -3,7 +3,7 @@ #include #include -namespace faker +namespace faker::word { const std::array conjunctions = { "after", "although", "and", "as", "because", "before", "but", "consequently", diff --git a/src/modules/word/data/Interjections.h b/src/modules/word/data/Interjections.h index 98a6b4288..56c15fdd3 100644 --- a/src/modules/word/data/Interjections.h +++ b/src/modules/word/data/Interjections.h @@ -3,7 +3,7 @@ #include #include -namespace faker +namespace faker::word { const std::array interjections = { "yuck", "oh", "phooey", "blah", "boo", "whoa", "yowza", "huzzah", "boohoo", "fooey", "geez", "pfft", diff --git a/src/modules/word/data/Nouns.h b/src/modules/word/data/Nouns.h index 45f5d239b..62f03f503 100644 --- a/src/modules/word/data/Nouns.h +++ b/src/modules/word/data/Nouns.h @@ -3,7 +3,7 @@ #include #include -namespace faker +namespace faker::word { const std::array nouns = {"ATM", "CD", diff --git a/src/modules/word/data/Prepositions.h b/src/modules/word/data/Prepositions.h index a8400a7a3..e77ca7a4b 100644 --- a/src/modules/word/data/Prepositions.h +++ b/src/modules/word/data/Prepositions.h @@ -3,7 +3,7 @@ #include #include -namespace faker +namespace faker::word { const std::array prepositions = { "a", diff --git a/src/modules/word/data/Verbs.h b/src/modules/word/data/Verbs.h index 23f55bde2..b509ab059 100644 --- a/src/modules/word/data/Verbs.h +++ b/src/modules/word/data/Verbs.h @@ -3,7 +3,7 @@ #include #include -namespace faker +namespace faker::word { const std::array verbs = {"abandon", "abase", diff --git a/tests/modules/internet/InternetTest.cpp b/tests/modules/internet/InternetTest.cpp index 472b6bd48..c518f83b0 100644 --- a/tests/modules/internet/InternetTest.cpp +++ b/tests/modules/internet/InternetTest.cpp @@ -59,7 +59,7 @@ class InternetTest : public Test public: InternetTest() { - sortedAdjectivesDescendingBySize.assign(adjectives.cbegin(), adjectives.cend()); + sortedAdjectivesDescendingBySize.assign(word::adjectives.cbegin(), word::adjectives.cend()); std::sort(sortedAdjectivesDescendingBySize.begin(), sortedAdjectivesDescendingBySize.end(), [](const std::string& first, const std::string& second) { return first.size() > second.size(); }); } @@ -83,7 +83,7 @@ class InternetTest : public Test const auto generatedNoun = domainWord.substr(foundAdjective->size() + 1); - ASSERT_TRUE(std::ranges::any_of(nouns, + ASSERT_TRUE(std::ranges::any_of(word::nouns, [generatedNoun](const std::string_view& noun) { if (generatedNoun.size() != noun.size()) diff --git a/tests/modules/person/PersonTest.cpp b/tests/modules/person/PersonTest.cpp index 9b70e011a..6009406ca 100644 --- a/tests/modules/person/PersonTest.cpp +++ b/tests/modules/person/PersonTest.cpp @@ -776,7 +776,7 @@ bool checkTokenFormat(const std::string& bio) { // In this case the bio is in the format {noun} {bio_supporter} so check that the value is present // in the bio_part vector. - if (std::find(nouns.begin(), nouns.end(), std::string{matches[1]}) != nouns.end() && + if (std::find(word::nouns.begin(), word::nouns.end(), std::string{matches[1]}) != word::nouns.end() && std::find(bioSupporters.begin(), bioSupporters.end(), std::string{matches[2]}) != bioSupporters.end()) return true; } @@ -785,7 +785,7 @@ bool checkTokenFormat(const std::string& bio) { // In this case the bio is in the format {noun} {bio_supporter} {emoji} so check that the value is present // in the bio_part vector. - if (std::find(nouns.begin(), nouns.end(), std::string{matches[1]}) != nouns.end() && + if (std::find(word::nouns.begin(), word::nouns.end(), std::string{matches[1]}) != word::nouns.end() && std::find(bioSupporters.begin(), bioSupporters.end(), std::string{matches[2]}) != bioSupporters.end() && Internet::checkIfEmojiIsValid(std::string{matches[3]})) return true; @@ -795,7 +795,7 @@ bool checkTokenFormat(const std::string& bio) { // In this case the bio is in the format {noun} {bio_supporter}, {bio_part} so check that the value is // present in the bio_part vector. - if (std::find(nouns.begin(), nouns.end(), std::string{matches[1]}) != nouns.end() && + if (std::find(word::nouns.begin(), word::nouns.end(), std::string{matches[1]}) != word::nouns.end() && std::find(bioSupporters.begin(), bioSupporters.end(), std::string{matches[2]}) != bioSupporters.end() && std::find(bioParts.begin(), bioParts.end(), std::string{matches[3]}) != bioParts.end()) return true; @@ -805,7 +805,7 @@ bool checkTokenFormat(const std::string& bio) { // In this case the bio is in the format {noun} {bio_supporter}, {bio_part} {emoji} so check that the value // is present in the bio_part vector. - if (std::find(nouns.begin(), nouns.end(), std::string{matches[1]}) != nouns.end() && + if (std::find(word::nouns.begin(), word::nouns.end(), std::string{matches[1]}) != word::nouns.end() && std::find(bioSupporters.begin(), bioSupporters.end(), std::string{matches[2]}) != bioSupporters.end() && std::find(bioParts.begin(), bioParts.end(), std::string{matches[3]}) != bioParts.end() && Internet::checkIfEmojiIsValid(std::string{matches[4]})) diff --git a/tests/modules/word/WordTest.cpp b/tests/modules/word/WordTest.cpp index 0b5c4d2db..df4b946ae 100644 --- a/tests/modules/word/WordTest.cpp +++ b/tests/modules/word/WordTest.cpp @@ -15,8 +15,8 @@ #include "word/data/Prepositions.h" #include "word/data/Verbs.h" +using namespace faker::word; using namespace ::testing; -using namespace faker; class WordTest : public Test { @@ -37,7 +37,7 @@ class WordTest : public Test TEST_F(WordTest, shouldGenerateAdjective) { - const auto generatedAdjective = Word::adjective(); + const auto generatedAdjective = adjective(); ASSERT_TRUE(std::ranges::any_of(adjectives, [generatedAdjective](const std::string_view& word) { return word == generatedAdjective; })); @@ -45,7 +45,7 @@ TEST_F(WordTest, shouldGenerateAdjective) TEST_F(WordTest, shouldGenerateAdjectiveWithExistingLength) { - const auto generatedAdjective = Word::adjective(5); + const auto generatedAdjective = adjective(5); ASSERT_TRUE(std::ranges::any_of(adjectives, [generatedAdjective](const std::string_view& word) { return word == generatedAdjective; })); @@ -53,7 +53,7 @@ TEST_F(WordTest, shouldGenerateAdjectiveWithExistingLength) TEST_F(WordTest, shouldGenerateAdjectiveWithNonExistingLength) { - const auto generatedAdjective = Word::adjective(100); + const auto generatedAdjective = adjective(100); ASSERT_TRUE(std::ranges::any_of(adjectives, [generatedAdjective](const std::string_view& word) { return word == generatedAdjective; })); @@ -61,7 +61,7 @@ TEST_F(WordTest, shouldGenerateAdjectiveWithNonExistingLength) TEST_F(WordTest, shouldGenerateAdverb) { - const auto generatedAdverb = Word::adverb(); + const auto generatedAdverb = adverb(); ASSERT_TRUE(std::ranges::any_of(adverbs, [generatedAdverb](const std::string_view& word) { return word == generatedAdverb; })); @@ -69,7 +69,7 @@ TEST_F(WordTest, shouldGenerateAdverb) TEST_F(WordTest, shouldGenerateAdverbWithExistingLength) { - const auto generatedAdverb = Word::adverb(5); + const auto generatedAdverb = adverb(5); ASSERT_TRUE(std::ranges::any_of(adverbs, [generatedAdverb](const std::string_view& word) { return word == generatedAdverb; })); @@ -77,7 +77,7 @@ TEST_F(WordTest, shouldGenerateAdverbWithExistingLength) TEST_F(WordTest, shouldGenerateAdverbWithNonExistingLength) { - const auto generatedAdverb = Word::adverb(100); + const auto generatedAdverb = adverb(100); ASSERT_TRUE(std::ranges::any_of(adverbs, [generatedAdverb](const std::string_view& word) { return word == generatedAdverb; })); @@ -85,7 +85,7 @@ TEST_F(WordTest, shouldGenerateAdverbWithNonExistingLength) TEST_F(WordTest, shouldGenerateConjunction) { - const auto generatedConjunction = Word::conjunction(); + const auto generatedConjunction = conjunction(); ASSERT_TRUE(std::ranges::any_of(conjunctions, [generatedConjunction](const std::string_view& word) { return word == generatedConjunction; })); @@ -93,7 +93,7 @@ TEST_F(WordTest, shouldGenerateConjunction) TEST_F(WordTest, shouldGenerateConjunctionWithExistingLength) { - const auto generatedConjunction = Word::conjunction(5); + const auto generatedConjunction = conjunction(5); ASSERT_TRUE(std::ranges::any_of(conjunctions, [generatedConjunction](const std::string_view& word) { return word == generatedConjunction; })); @@ -101,7 +101,7 @@ TEST_F(WordTest, shouldGenerateConjunctionWithExistingLength) TEST_F(WordTest, shouldGenerateConjunctionWithNonExistingLength) { - const auto generatedConjunction = Word::conjunction(100); + const auto generatedConjunction = conjunction(100); ASSERT_TRUE(std::ranges::any_of(conjunctions, [generatedConjunction](const std::string_view& word) { return word == generatedConjunction; })); @@ -109,7 +109,7 @@ TEST_F(WordTest, shouldGenerateConjunctionWithNonExistingLength) TEST_F(WordTest, shouldGenerateInterjection) { - const auto generatedInterjection = Word::interjection(); + const auto generatedInterjection = interjection(); ASSERT_TRUE(std::ranges::any_of(interjections, [generatedInterjection](const std::string_view& word) { return word == generatedInterjection; })); @@ -117,7 +117,7 @@ TEST_F(WordTest, shouldGenerateInterjection) TEST_F(WordTest, shouldGenerateInterjectionWithExistingLength) { - const auto generatedInterjection = Word::interjection(5); + const auto generatedInterjection = interjection(5); ASSERT_TRUE(std::ranges::any_of(interjections, [generatedInterjection](const std::string_view& word) { return word == generatedInterjection; })); @@ -125,7 +125,7 @@ TEST_F(WordTest, shouldGenerateInterjectionWithExistingLength) TEST_F(WordTest, shouldGenerateInterjectionWithNonExistingLength) { - const auto generatedInterjection = Word::interjection(100); + const auto generatedInterjection = interjection(100); ASSERT_TRUE(std::ranges::any_of(interjections, [generatedInterjection](const std::string_view& word) { return word == generatedInterjection; })); @@ -133,7 +133,7 @@ TEST_F(WordTest, shouldGenerateInterjectionWithNonExistingLength) TEST_F(WordTest, shouldGenerateNoun) { - const auto generatedNoun = Word::noun(); + const auto generatedNoun = noun(); ASSERT_TRUE( std::ranges::any_of(nouns, [generatedNoun](const std::string_view& word) { return word == generatedNoun; })); @@ -141,7 +141,7 @@ TEST_F(WordTest, shouldGenerateNoun) TEST_F(WordTest, shouldGenerateNounWithExistingLength) { - const auto generatedNoun = Word::noun(5); + const auto generatedNoun = noun(5); ASSERT_TRUE( std::ranges::any_of(nouns, [generatedNoun](const std::string_view& word) { return word == generatedNoun; })); @@ -149,7 +149,7 @@ TEST_F(WordTest, shouldGenerateNounWithExistingLength) TEST_F(WordTest, shouldGenerateNounWithNonExistingLength) { - const auto generatedNoun = Word::noun(100); + const auto generatedNoun = noun(100); ASSERT_TRUE( std::ranges::any_of(nouns, [generatedNoun](const std::string_view& word) { return word == generatedNoun; })); @@ -157,7 +157,7 @@ TEST_F(WordTest, shouldGenerateNounWithNonExistingLength) TEST_F(WordTest, shouldGeneratePreposition) { - const auto generatedPreposition = Word::preposition(); + const auto generatedPreposition = preposition(); ASSERT_TRUE(std::ranges::any_of(prepositions, [generatedPreposition](const std::string_view& word) { return word == generatedPreposition; })); @@ -165,7 +165,7 @@ TEST_F(WordTest, shouldGeneratePreposition) TEST_F(WordTest, shouldGeneratePrepositionWithExistingLength) { - const auto generatedPreposition = Word::preposition(5); + const auto generatedPreposition = preposition(5); ASSERT_TRUE(std::ranges::any_of(prepositions, [generatedPreposition](const std::string_view& word) { return word == generatedPreposition; })); @@ -173,7 +173,7 @@ TEST_F(WordTest, shouldGeneratePrepositionWithExistingLength) TEST_F(WordTest, shouldGeneratePrepositionWithNonExistingLength) { - const auto generatedPreposition = Word::preposition(100); + const auto generatedPreposition = preposition(100); ASSERT_TRUE(std::ranges::any_of(prepositions, [generatedPreposition](const std::string_view& word) { return word == generatedPreposition; })); @@ -181,7 +181,7 @@ TEST_F(WordTest, shouldGeneratePrepositionWithNonExistingLength) TEST_F(WordTest, shouldGenerateVerb) { - const auto generatedVerb = Word::verb(); + const auto generatedVerb = verb(); ASSERT_TRUE( std::ranges::any_of(verbs, [generatedVerb](const std::string_view& word) { return word == generatedVerb; })); @@ -189,7 +189,7 @@ TEST_F(WordTest, shouldGenerateVerb) TEST_F(WordTest, shouldGenerateVerbWithExistingLength) { - const auto generatedVerb = Word::verb(5); + const auto generatedVerb = verb(5); ASSERT_TRUE( std::ranges::any_of(verbs, [generatedVerb](const std::string_view& word) { return word == generatedVerb; })); @@ -197,7 +197,7 @@ TEST_F(WordTest, shouldGenerateVerbWithExistingLength) TEST_F(WordTest, shouldGenerateVerbWithNonExistingLength) { - const auto generatedVerb = Word::verb(100); + const auto generatedVerb = verb(100); ASSERT_TRUE( std::ranges::any_of(verbs, [generatedVerb](const std::string_view& word) { return word == generatedVerb; })); @@ -205,7 +205,7 @@ TEST_F(WordTest, shouldGenerateVerbWithNonExistingLength) TEST_F(WordTest, shouldGenerateSample) { - const auto generatedSample = Word::sample(); + const auto generatedSample = sample(); ASSERT_TRUE( std::ranges::any_of(allWords, [generatedSample](const std::string& word) { return word == generatedSample; })); @@ -213,7 +213,7 @@ TEST_F(WordTest, shouldGenerateSample) TEST_F(WordTest, shouldGenerateSampleWithExistingLength) { - const auto generatedSample = Word::sample(5); + const auto generatedSample = sample(5); ASSERT_TRUE( std::ranges::any_of(allWords, [generatedSample](const std::string& word) { return word == generatedSample; })); @@ -221,7 +221,7 @@ TEST_F(WordTest, shouldGenerateSampleWithExistingLength) TEST_F(WordTest, shouldGenerateSampleWithNonExistingLength) { - const auto generatedSample = Word::sample(100); + const auto generatedSample = sample(100); ASSERT_TRUE( std::ranges::any_of(allWords, [generatedSample](const std::string& word) { return word == generatedSample; })); @@ -229,10 +229,11 @@ TEST_F(WordTest, shouldGenerateSampleWithNonExistingLength) TEST_F(WordTest, shouldGenerateWords) { - const auto generatedWords = Word::words(5); + const auto generatedWords = words(5); - const auto separatedWords = StringHelper::split(generatedWords, " "); + const auto separatedWords = faker::StringHelper::split(generatedWords, " "); ASSERT_TRUE(std::ranges::all_of(separatedWords, [this](const std::string& separatedWord) { return std::ranges::find(allWords, separatedWord) != allWords.end(); })); } +