From 18ec6ddbb68d1701eb0cb4e56005a7a455af932e Mon Sep 17 00:00:00 2001 From: charan-003 <85248228+charan-003@users.noreply.github.com> Date: Sat, 16 Nov 2024 07:58:59 -0700 Subject: [PATCH] Update location_test.cpp added test cases for continents --- tests/modules/location_test.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/modules/location_test.cpp b/tests/modules/location_test.cpp index 96e32b3c..cf65dacd 100644 --- a/tests/modules/location_test.cpp +++ b/tests/modules/location_test.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "gtest/gtest.h" @@ -1138,5 +1139,24 @@ TEST_F(LocationTest, shouldGeneratepalestineStreetAddress) { return generatedStreetAddress.find(streetName) != std::string::npos; })); } +TEST(LocationTest, ContinentFunction) +{ + std::unordered_set validContinents = { + "Africa", "Antarctica", "Asia", "Europe", "North America", "Oceania", "South America"}; + for (int i = 0; i < 100; ++i) + { + std::string_view continent = faker::location::continent(); + ASSERT_TRUE(validContinents.count(continent)) << "Invalid continent: " << continent; + } +} +TEST(LocationTest, SpecificCountryMappings) +{ + const auto& testCountryToContinent = faker::location::countryToContinent; + + EXPECT_EQ(testCountryToContinent.at("Brazil"), "South America"); + EXPECT_EQ(testCountryToContinent.at("India"), "Asia"); + EXPECT_EQ(testCountryToContinent.at("United States"), "North America"); + EXPECT_EQ(testCountryToContinent.at("France"), "Europe"); +}