Commit 733bfd47 authored by Caitlin Fischer's avatar Caitlin Fischer Committed by Commit Bot

Added unit tests for FormatPhoneNationallyForDisplay.

This function was added in the below CL.
https://chromium-review.googlesource.com/c/chromium/src/+/1504117

Change-Id: Ic8bd7d02ffcb4662aa1989a3f219b75eb944c2c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1505992
Commit-Queue: Caitlin Fischer <caitlinfischer@google.com>
Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638157}
parent bb1d0e28
......@@ -272,6 +272,37 @@ TEST(PhoneNumberUtilTest, FormatPhoneForResponse) {
i18n::FormatPhoneForResponse("(1) 515-123-1234", "US"));
}
// Tests that phone numbers are correctly formatted in a national format.
TEST(PhoneNumberUtilTest, FormatPhoneNationallyForDisplay) {
// Invalid US and Brazilian numbers are not formatted.
EXPECT_EQ("1234567890",
i18n::FormatPhoneNationallyForDisplay("1234567890", "US"));
EXPECT_EQ("(11) 13333-4444",
i18n::FormatPhoneNationallyForDisplay("(11) 13333-4444", "BR"));
EXPECT_EQ("(11) 13333-4444",
i18n::FormatPhoneNationallyForDisplay("(11) 13333-4444", "IN"));
// Valid US, Canadian, UK, and Brazilian numbers are nationally formatted.
EXPECT_EQ("(202) 444-0000",
i18n::FormatPhoneNationallyForDisplay("2024440000", "US"));
EXPECT_EQ("(202) 444-0000",
i18n::FormatPhoneNationallyForDisplay("+1(202)4440000", "US"));
EXPECT_EQ("(202) 444-0000",
i18n::FormatPhoneNationallyForDisplay("12024440000", "US"));
EXPECT_EQ("(202) 444-0000",
i18n::FormatPhoneNationallyForDisplay("(202)4440000", "US"));
EXPECT_EQ("(202) 444-0000",
i18n::FormatPhoneNationallyForDisplay("202-444-0000", "US"));
EXPECT_EQ("(819) 555-9999",
i18n::FormatPhoneNationallyForDisplay("+1(819)555 9999", "CA"));
EXPECT_EQ("(819) 555-9999",
i18n::FormatPhoneNationallyForDisplay("18195559999", "CA"));
EXPECT_EQ("020 7601 4444",
i18n::FormatPhoneNationallyForDisplay("+4402076014444", "UK"));
EXPECT_EQ("(21) 3883-5600",
i18n::FormatPhoneNationallyForDisplay("2138835600", "BR"));
}
// Tests that the phone numbers are correctly formatted to display to the user.
TEST(PhoneNumberUtilTest, FormatPhoneForDisplay) {
// Invalid number is not formatted.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment