diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index 9c88307e7..b70b815d9 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -3492,6 +3492,10 @@ TEST_F(PhoneNumberUtilTest, ParseNationalNumber) { EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR, phone_util_.Parse("033316005", RegionCode::NZ(), &test_number)); EXPECT_EQ(nz_number, test_number); + // Some fields are not filled in by Parse, but only by ParseAndKeepRawInput. + EXPECT_FALSE(nz_number.has_country_code_source()); + EXPECT_EQ(PhoneNumber::UNSPECIFIED, nz_number.country_code_source()); + // National prefix missing. EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR, phone_util_.Parse("33316005", RegionCode::NZ(), &test_number)); diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/Phonenumber.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/Phonenumber.java index 6ac5b83db..fe88a465c 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/Phonenumber.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/Phonenumber.java @@ -32,11 +32,12 @@ public final class Phonenumber { FROM_NUMBER_WITH_PLUS_SIGN, FROM_NUMBER_WITH_IDD, FROM_NUMBER_WITHOUT_PLUS_SIGN, - FROM_DEFAULT_COUNTRY + FROM_DEFAULT_COUNTRY, + UNSPECIFIED } public PhoneNumber() { - countryCodeSource_ = CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN; + countryCodeSource_ = CountryCodeSource.UNSPECIFIED; } // required int32 country_code = 1; @@ -156,7 +157,7 @@ public final class Phonenumber { } public PhoneNumber clearCountryCodeSource() { hasCountryCodeSource = false; - countryCodeSource_ = CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN; + countryCodeSource_ = CountryCodeSource.UNSPECIFIED; return this; } diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index e4fe0cb9f..8cb798c43 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -2045,6 +2045,10 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { public void testParseNationalNumber() throws Exception { // National prefix attached. assertEquals(NZ_NUMBER, phoneUtil.parse("033316005", RegionCode.NZ)); + // Some fields are not filled in by parse, but only by parseAndKeepRawInput. + assertFalse(NZ_NUMBER.hasCountryCodeSource()); + assertEquals(CountryCodeSource.UNSPECIFIED, NZ_NUMBER.getCountryCodeSource()); + assertEquals(NZ_NUMBER, phoneUtil.parse("33316005", RegionCode.NZ)); // National prefix attached and some formatting present. assertEquals(NZ_NUMBER, phoneUtil.parse("03-331 6005", RegionCode.NZ)); diff --git a/javascript/i18n/phonenumbers/demo-compiled.js b/javascript/i18n/phonenumbers/demo-compiled.js index 1ec1a2408..4c8379c83 100644 --- a/javascript/i18n/phonenumbers/demo-compiled.js +++ b/javascript/i18n/phonenumbers/demo-compiled.js @@ -2,7 +2,7 @@ function ca(a,b){if(b){for(var c=ba,d=a.split("."),e=0;ea||1342177279>>=1)b+=b;return d}});ca("Math.sign",function(a){return a?a:function(a){a=Number(a);return!a||isNaN(a)?a:0c?Math.max(0,a.length+c):c;if(k(a))return k(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?1:ac?Math.max(0,a.length+c):c;if(k(a))return k(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?1:a