Skip to content

Commit

Permalink
Update location_test.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
charan-003 authored Nov 16, 2024
1 parent 2266661 commit 45086d3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/modules/location_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <string_view>
#include <vector>
#include <unordered_set>

#include "gtest/gtest.h"

Expand Down Expand Up @@ -1138,5 +1139,24 @@ TEST_F(LocationTest, shouldGeneratepalestineStreetAddress)
{ return generatedStreetAddress.find(streetName) != std::string::npos; }));
}

TEST(LocationTest, ContinentFunction)
{
std::unordered_set<std::string_view> 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");
}

0 comments on commit 45086d3

Please sign in to comment.