|
|
|
@ -85,6 +85,12 @@ class PhoneNumberMatcherTest : public testing::Test { |
|
|
|
return PhoneNumberMatcher::IsLatinLetter(letter); |
|
|
|
} |
|
|
|
|
|
|
|
bool ContainsMoreThanOneSlashInNationalNumber( |
|
|
|
const PhoneNumber& phone_number, const string& candidate) { |
|
|
|
return PhoneNumberMatcher::ContainsMoreThanOneSlashInNationalNumber( |
|
|
|
phone_number, candidate, phone_util_); |
|
|
|
} |
|
|
|
|
|
|
|
bool ExtractMatch(const string& text, PhoneNumberMatch* match) { |
|
|
|
return matcher_.ExtractMatch(text, offset_, match); |
|
|
|
} |
|
|
|
@ -324,6 +330,52 @@ class PhoneNumberMatcherTest : public testing::Test { |
|
|
|
int offset_; |
|
|
|
}; |
|
|
|
|
|
|
|
TEST_F(PhoneNumberMatcherTest, ContainsMoreThanOneSlashInNationalNumber) { |
|
|
|
// A date should return true.
|
|
|
|
PhoneNumber number; |
|
|
|
number.set_country_code(1); |
|
|
|
number.set_country_code_source(PhoneNumber::FROM_DEFAULT_COUNTRY); |
|
|
|
string candidate = "1/05/2013"; |
|
|
|
EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate)); |
|
|
|
|
|
|
|
// Here, the country code source thinks it started with a country calling
|
|
|
|
// code, but this is not the same as the part before the slash, so it's still
|
|
|
|
// true.
|
|
|
|
number.Clear(); |
|
|
|
number.set_country_code(274); |
|
|
|
number.set_country_code_source(PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN); |
|
|
|
candidate = "27/4/2013"; |
|
|
|
EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate)); |
|
|
|
|
|
|
|
// Now it should be false, because the first slash is after the country
|
|
|
|
// calling code.
|
|
|
|
number.Clear(); |
|
|
|
number.set_country_code(49); |
|
|
|
number.set_country_code_source(PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN); |
|
|
|
candidate = "49/69/2013"; |
|
|
|
EXPECT_FALSE(ContainsMoreThanOneSlashInNationalNumber(number, candidate)); |
|
|
|
|
|
|
|
number.Clear(); |
|
|
|
number.set_country_code(49); |
|
|
|
number.set_country_code_source(PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN); |
|
|
|
candidate = "+49/69/2013"; |
|
|
|
EXPECT_FALSE(ContainsMoreThanOneSlashInNationalNumber(number, candidate)); |
|
|
|
|
|
|
|
candidate = "+ 49/69/2013"; |
|
|
|
EXPECT_FALSE(ContainsMoreThanOneSlashInNationalNumber(number, candidate)); |
|
|
|
|
|
|
|
candidate = "+ 49/69/20/13"; |
|
|
|
EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate)); |
|
|
|
|
|
|
|
// Here, the first group is not assumed to be the country calling code, even
|
|
|
|
// though it is the same as it, so this should return true.
|
|
|
|
number.Clear(); |
|
|
|
number.set_country_code(49); |
|
|
|
number.set_country_code_source(PhoneNumber::FROM_DEFAULT_COUNTRY); |
|
|
|
candidate = "49/69/2013"; |
|
|
|
EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate)); |
|
|
|
} |
|
|
|
|
|
|
|
// See PhoneNumberUtilTest::ParseNationalNumber.
|
|
|
|
TEST_F(PhoneNumberMatcherTest, FindNationalNumber) { |
|
|
|
// Same cases as in ParseNationalNumber.
|
|
|
|
|