diff --git a/include/faker-cxx/Person.h b/include/faker-cxx/Person.h index 5abc73788..4b11fd896 100644 --- a/include/faker-cxx/Person.h +++ b/include/faker-cxx/Person.h @@ -135,5 +135,17 @@ class Person * @endcode */ static std::string jobType(); + + /** + * @brief Returns a random hobby. + * + * @returns Hobby. + * + * @code + * Person::hobby() // "Gaming" + * @endcode + */ + + static std::string hobby(); }; } diff --git a/src/modules/person/Person.cpp b/src/modules/person/Person.cpp index 8a4eb8cfb..d682728a9 100644 --- a/src/modules/person/Person.cpp +++ b/src/modules/person/Person.cpp @@ -16,6 +16,7 @@ #include "data/german/GermanFirstNamesFemales.h" #include "data/german/GermanFirstNamesMales.h" #include "data/german/GermanLastNames.h" +#include "data/Hobbies.h" #include "data/indian/IndianFirstNames.h" #include "data/indian/IndianLastNames.h" #include "data/italian/ItalianFirstNamesFemales.h" @@ -179,4 +180,9 @@ std::string Person::prefix(std::optional sex) return Helper::arrayElement(allPrefixes); } } + +std::string Person::hobby() +{ + return Helper::arrayElement(hobbies); +} } diff --git a/src/modules/person/PersonTest.cpp b/src/modules/person/PersonTest.cpp index 034bb2543..dab912bb6 100644 --- a/src/modules/person/PersonTest.cpp +++ b/src/modules/person/PersonTest.cpp @@ -17,6 +17,7 @@ #include "data/german/GermanFirstNamesFemales.h" #include "data/german/GermanFirstNamesMales.h" #include "data/german/GermanLastNames.h" +#include "data/Hobbies.h" #include "data/indian/IndianFirstNames.h" #include "data/indian/IndianLastNames.h" #include "data/italian/ItalianFirstNamesFemales.h" @@ -317,3 +318,11 @@ TEST_F(PersonTest, shouldGenerateFemalePrefix) ASSERT_TRUE(std::ranges::any_of(femalePrefixes, [generatedPrefix](const std::string& prefix) { return prefix == generatedPrefix; })); } + +TEST_F(PersonTest, shouldGenerateHobby) +{ + const auto generatedHobby = Person::hobby(); + + ASSERT_TRUE( + std::ranges::any_of(hobbies, [generatedHobby](const std::string& hobby) { return hobby == generatedHobby; })); +} \ No newline at end of file diff --git a/src/modules/person/data/Hobbies.h b/src/modules/person/data/Hobbies.h new file mode 100644 index 000000000..1ec2838e2 --- /dev/null +++ b/src/modules/person/data/Hobbies.h @@ -0,0 +1,54 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector hobbies = { + "Playing guitar", + "Reading books", + "Hiking", + "Cooking", + "Painting", + "Photography", + "Swimming", + "Gaming", + "Dancing", + "Traveling", + "Bird watching", + "Coding", + "Singing", + "Collecting stamps", + "Fishing", + "Yoga", + "Sculpting", + "Mountain biking", + "Chess", + "Archery", + "Rock climbing", + "Skiing", + "Writing poetry", + "Meditation", + "Solving puzzles", + "Gardening", + "Playing basketball", + "Volunteering", + "Playing board games", + "Astrophotography", + "Camping", + "Model building", + "Astronomy", + "Watching movies", + "Stargazing", + "Playing tennis", + "Cooking ethnic cuisines", + "Woodworking", + "Baking", + "Calligraphy", + "Pottery", + "Karaoke", + "Scuba diving", + "Metal detecting", +}; +} \ No newline at end of file