diff --git a/include/faker-cxx/Weather.h b/include/faker-cxx/Weather.h index 8358c2884..2cfcca31b 100644 --- a/include/faker-cxx/Weather.h +++ b/include/faker-cxx/Weather.h @@ -2,20 +2,16 @@ #include -namespace faker +namespace faker::weather { -class Weather -{ -public: - /** - * @brief Generated a random weather description - * - * @return String_View A random weather description - * - * @code - * Weather::description(); // "Sunny" - * @endcode - */ - static std::string_view weatherDescription(); -}; +/** + * @brief Generated a random weather description + * + * @return A random weather description + * + * @code + * weather::weatherDescription(); // "Sunny" + * @endcode + */ +std::string_view weatherDescription(); } diff --git a/src/modules/weather/Weather.cpp b/src/modules/weather/Weather.cpp index 848fab0b2..1ded67c30 100644 --- a/src/modules/weather/Weather.cpp +++ b/src/modules/weather/Weather.cpp @@ -5,9 +5,9 @@ #include "faker-cxx/Helper.h" #include "WeatherData.h" -namespace faker +namespace faker::weather { -std::string_view Weather::weatherDescription() +std::string_view weatherDescription() { return Helper::arrayElement(weatherDescriptions); } diff --git a/src/modules/weather/WeatherData.h b/src/modules/weather/WeatherData.h index 3a061a2ef..365a5b88c 100644 --- a/src/modules/weather/WeatherData.h +++ b/src/modules/weather/WeatherData.h @@ -3,14 +3,24 @@ #include #include -namespace faker +namespace faker::weather { const auto weatherDescriptions = std::to_array({ - "clear sky", "few clouds", "scattered clouds", - "broken clouds", "shower rain", "rainy", - "thunderstorm", "snowy", "misty", - "smoky", "haze", "sunny", - "cloudy", "windy", "dark", + "clear sky", + "few clouds", + "scattered clouds", + "broken clouds", + "shower rain", + "rainy", + "thunderstorm", + "snowy", + "misty", + "smoky", + "haze", + "sunny", + "cloudy", + "windy", + "dark", "foggy", }); diff --git a/tests/modules/weather/WeatherTest.cpp b/tests/modules/weather/WeatherTest.cpp index 8cebce9c3..a1e865331 100644 --- a/tests/modules/weather/WeatherTest.cpp +++ b/tests/modules/weather/WeatherTest.cpp @@ -8,7 +8,7 @@ #include "weather/WeatherData.h" using namespace ::testing; -using namespace faker; +using namespace faker::weather; class WeatherTest : public Test { @@ -17,7 +17,7 @@ class WeatherTest : public Test TEST_F(WeatherTest, shouldGenerateWeatherDescription) { - const std::string_view generatedWeatherDescription = Weather::weatherDescription(); + const std::string_view generatedWeatherDescription = weatherDescription(); ASSERT_TRUE(std::ranges::any_of(weatherDescriptions, [generatedWeatherDescription](const std::string_view& weatherDescription)