Skip to content

Commit

Permalink
Added test in PhoneTest.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
jessleathe authored Feb 8, 2024
1 parent ad7cadb commit 128645d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/modules/phone/PhoneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,18 @@ TEST_F(PhoneTest, ManufacturerGeneration)
[generatedManufacturer](const std::string& manufacturer)
{ return manufacturer == generatedManufacturer; }));
}

TEST_F(PhoneTest, AreaCodeExtraction){
for(const auto& phoneNumber : faker::phoneNumbers){
std::string extracedAreCode = Phone::areaCode(phoneNumber);

//Verify that the rxtracted area code starts with a '+' and is followed by digits only
if(!extractedAreaCode.empty()){
EXPECT_EQ(extractedAreaCode[0], '+');

for(size_t i = 1; i < extractedAreaCode.size(); i++){
EXPECT_TRUE(std::isdigit(extractedAreaCode[i])) << "Failed at phone number: " << phoneNumber;
}
}
}
}

0 comments on commit 128645d

Please sign in to comment.