diff --git a/cpp/src/phonenumbers/phonenumberutil.cc b/cpp/src/phonenumbers/phonenumberutil.cc index c9359297c..d09415e6a 100644 --- a/cpp/src/phonenumbers/phonenumberutil.cc +++ b/cpp/src/phonenumbers/phonenumberutil.cc @@ -610,12 +610,12 @@ class PhoneNumberRegExpsAndMappings { // example, in China mobile numbers start with a carrier indicator, and beyond // that are geographically assigned: this carrier indicator is not considered // to be an area code. - set geo_mobile_countries_without_mobile_area_codes_; + std::set geo_mobile_countries_without_mobile_area_codes_; // Set of country calling codes that have geographically assigned mobile // numbers. This may not be complete; we add calling codes case by case, as we // find geographical mobile numbers or hear from user reports. - set geo_mobile_countries_; + std::set geo_mobile_countries_; // Pattern that makes it easy to distinguish whether a region has a single // international dialing prefix or not. If a region has a single international @@ -750,11 +750,12 @@ PhoneNumberUtil::PhoneNumberUtil() : logger_(Logger::set_logger_impl(new NullLogger())), matcher_api_(new RegexBasedMatcher()), reg_exps_(new PhoneNumberRegExpsAndMappings), - country_calling_code_to_region_code_map_(new vector()), - nanpa_regions_(new set()), - region_to_metadata_map_(new map()), + country_calling_code_to_region_code_map_( + new std::vector()), + nanpa_regions_(new std::set()), + region_to_metadata_map_(new std::map()), country_code_to_non_geographical_metadata_map_( - new map) { + new std::map) { Logger::set_logger_impl(logger_.get()); // TODO: Update the java version to put the contents of the init // method inside the constructor as well to keep both in sync. @@ -765,7 +766,7 @@ PhoneNumberUtil::PhoneNumberUtil() } // Storing data in a temporary map to make it easier to find other regions // that share a country calling code when inserting data. - std::map* > country_calling_code_to_region_map; + std::map* > country_calling_code_to_region_map; for (RepeatedPtrField::const_iterator it = metadata_collection.metadata().begin(); it != metadata_collection.metadata().end(); @@ -782,7 +783,7 @@ PhoneNumberUtil::PhoneNumberUtil() } else { region_to_metadata_map_->insert(std::make_pair(region_code, *it)); } - std::map* >::iterator calling_code_in_map = + std::map* >::iterator calling_code_in_map = country_calling_code_to_region_map.find(country_calling_code); if (calling_code_in_map != country_calling_code_to_region_map.end()) { if (it->main_country_for_code()) { @@ -817,9 +818,9 @@ PhoneNumberUtil::~PhoneNumberUtil() { country_calling_code_to_region_code_map_->end()); } -void PhoneNumberUtil::GetSupportedRegions(set* regions) const { +void PhoneNumberUtil::GetSupportedRegions(std::set* regions) const { DCHECK(regions); - for (map::const_iterator it = + for (std::map::const_iterator it = region_to_metadata_map_->begin(); it != region_to_metadata_map_->end(); ++it) { regions->insert(it->first); @@ -827,15 +828,25 @@ void PhoneNumberUtil::GetSupportedRegions(set* regions) const { } void PhoneNumberUtil::GetSupportedGlobalNetworkCallingCodes( - set* calling_codes) const { + std::set* calling_codes) const { DCHECK(calling_codes); - for (map::const_iterator it = + for (std::map::const_iterator it = country_code_to_non_geographical_metadata_map_->begin(); it != country_code_to_non_geographical_metadata_map_->end(); ++it) { calling_codes->insert(it->first); } } +void PhoneNumberUtil::GetSupportedCallingCodes( + std::set* calling_codes) const { + DCHECK(calling_codes); + for (std::vector::const_iterator it = + country_calling_code_to_region_code_map_->begin(); + it != country_calling_code_to_region_code_map_->end(); ++it) { + calling_codes->insert(it->first); + } +} + void PhoneNumberUtil::GetSupportedTypesForRegion( const string& region_code, std::set* types) const { @@ -968,7 +979,7 @@ bool PhoneNumberUtil::HasValidCountryCallingCode( // if the region code is invalid or unknown. const PhoneMetadata* PhoneNumberUtil::GetMetadataForRegion( const string& region_code) const { - map::const_iterator it = + std::map::const_iterator it = region_to_metadata_map_->find(region_code); if (it != region_to_metadata_map_->end()) { return &it->second; @@ -978,7 +989,7 @@ const PhoneMetadata* PhoneNumberUtil::GetMetadataForRegion( const PhoneMetadata* PhoneNumberUtil::GetMetadataForNonGeographicalRegion( int country_calling_code) const { - map::const_iterator it = + std::map::const_iterator it = country_code_to_non_geographical_metadata_map_->find( country_calling_code); if (it != country_code_to_non_geographical_metadata_map_->end()) { @@ -1736,7 +1747,7 @@ bool PhoneNumberUtil::IsNANPACountry(const string& region_code) const { // the case of no region code being found, region_codes will be left empty. void PhoneNumberUtil::GetRegionCodesForCountryCallingCode( int country_calling_code, - list* region_codes) const { + std::list* region_codes) const { DCHECK(region_codes); // Create a IntRegionsPair with the country_code passed in, and use it to // locate the pair with the same country_code in the sorted vector. @@ -1761,7 +1772,7 @@ void PhoneNumberUtil::GetRegionCodeForCountryCode( int country_calling_code, string* region_code) const { DCHECK(region_code); - list region_codes; + std::list region_codes; GetRegionCodesForCountryCallingCode(country_calling_code, ®ion_codes); *region_code = (region_codes.size() > 0) ? @@ -1772,7 +1783,7 @@ void PhoneNumberUtil::GetRegionCodeForNumber(const PhoneNumber& number, string* region_code) const { DCHECK(region_code); int country_calling_code = number.country_code(); - list region_codes; + std::list region_codes; GetRegionCodesForCountryCallingCode(country_calling_code, ®ion_codes); if (region_codes.size() == 0) { string number_string; @@ -1791,12 +1802,12 @@ void PhoneNumberUtil::GetRegionCodeForNumber(const PhoneNumber& number, } void PhoneNumberUtil::GetRegionCodeForNumberFromRegionList( - const PhoneNumber& number, const list& region_codes, + const PhoneNumber& number, const std::list& region_codes, string* region_code) const { DCHECK(region_code); string national_number; GetNationalSignificantNumber(number, &national_number); - for (list::const_iterator it = region_codes.begin(); + for (std::list::const_iterator it = region_codes.begin(); it != region_codes.end(); ++it) { // Metadata cannot be NULL because the region codes come from the country // calling code map. @@ -1925,9 +1936,9 @@ bool PhoneNumberUtil::GetExampleNumberForType( PhoneNumberUtil::PhoneNumberType type, PhoneNumber* number) const { DCHECK(number); - set regions; + std::set regions; GetSupportedRegions(®ions); - for (set::const_iterator it = regions.begin(); + for (std::set::const_iterator it = regions.begin(); it != regions.end(); ++it) { if (GetExampleNumberForType(*it, type, number)) { return true; @@ -1935,9 +1946,9 @@ bool PhoneNumberUtil::GetExampleNumberForType( } // If there wasn't an example number for a region, try the non-geographical // entities. - set global_network_calling_codes; + std::set global_network_calling_codes; GetSupportedGlobalNetworkCallingCodes(&global_network_calling_codes); - for (set::const_iterator it = global_network_calling_codes.begin(); + for (std::set::const_iterator it = global_network_calling_codes.begin(); it != global_network_calling_codes.end(); ++it) { int country_calling_code = *it; const PhoneMetadata* metadata = @@ -2568,7 +2579,7 @@ int PhoneNumberUtil::GetLengthOfNationalDestinationCode( void PhoneNumberUtil::GetCountryMobileToken(int country_calling_code, string* mobile_token) const { DCHECK(mobile_token); - map::iterator it = reg_exps_->mobile_token_mappings_.find( + std::map::iterator it = reg_exps_->mobile_token_mappings_.find( country_calling_code); if (it != reg_exps_->mobile_token_mappings_.end()) { *mobile_token = it->second; diff --git a/cpp/src/phonenumbers/phonenumberutil.h b/cpp/src/phonenumbers/phonenumberutil.h index ad83738f4..12e4ec7e6 100644 --- a/cpp/src/phonenumbers/phonenumberutil.h +++ b/cpp/src/phonenumbers/phonenumberutil.h @@ -35,14 +35,8 @@ class TelephoneNumber; namespace i18n { namespace phonenumbers { -using std::list; -using std::map; -using std::pair; -using std::set; -using std::string; -using std::vector; - using google::protobuf::RepeatedPtrField; +using std::string; class AsYouTypeFormatter; class Logger; @@ -177,6 +171,12 @@ class PhoneNumberUtil : public Singleton { void GetSupportedGlobalNetworkCallingCodes( std::set* calling_codes) const; + // Returns all country calling codes the library has metadata for, covering + // both non-geographical entities (global network calling codes) and those + // used for geographical entities. This could be used to populate a drop-down + // box of country calling codes for a phone-number widget, for instance. + void GetSupportedCallingCodes(std::set* calling_codes) const; + // Returns the types for a given region which the library has metadata for. // Will not include FIXED_LINE_OR_MOBILE (if numbers for this non-geographical // entity could be classified as FIXED_LINE_OR_MOBILE, both FIXED_LINE and @@ -478,7 +478,7 @@ class PhoneNumberUtil : public Singleton { // is left unchanged. void GetRegionCodesForCountryCallingCode( int country_calling_code, - list* region_codes) const; + std::list* region_codes) const; // Checks if this is a region under the North American Numbering Plan // Administration (NANPA). @@ -746,7 +746,7 @@ class PhoneNumberUtil : public Singleton { private: scoped_ptr logger_; - typedef pair*> IntRegionsPair; + typedef std::pair*> IntRegionsPair; // The minimum and maximum length of the national significant number. static const size_t kMinLengthForNsn = 2; @@ -787,20 +787,21 @@ class PhoneNumberUtil : public Singleton { // country calling code 7. Under this map, 1 is mapped to region code "US" and // 7 is mapped to region code "RU". This is implemented as a sorted vector to // achieve better performance. - scoped_ptr > country_calling_code_to_region_code_map_; + scoped_ptr > + country_calling_code_to_region_code_map_; // The set of regions that share country calling code 1. - scoped_ptr > nanpa_regions_; + scoped_ptr > nanpa_regions_; static const int kNanpaCountryCode = 1; // A mapping from a region code to a PhoneMetadata for that region. - scoped_ptr > region_to_metadata_map_; + scoped_ptr > region_to_metadata_map_; // A mapping from a country calling code for a non-geographical entity to the // PhoneMetadata for that country calling code. Examples of the country // calling codes include 800 (International Toll Free Service) and 808 // (International Shared Cost Service). - scoped_ptr > + scoped_ptr > country_code_to_non_geographical_metadata_map_; PhoneNumberUtil(); @@ -898,7 +899,7 @@ class PhoneNumberUtil : public Singleton { void GetRegionCodeForNumberFromRegionList( const PhoneNumber& number, - const list& region_codes, + const std::list& region_codes, string* region_code) const; // Strips the IDD from the start of the number if present. Helper function diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index b70b815d9..84632c7ab 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -125,18 +125,18 @@ TEST_F(PhoneNumberUtilTest, ContainsOnlyValidDigits) { } TEST_F(PhoneNumberUtilTest, GetSupportedRegions) { - set regions; + std::set regions; phone_util_.GetSupportedRegions(®ions); EXPECT_GT(regions.size(), 0U); } TEST_F(PhoneNumberUtilTest, GetSupportedGlobalNetworkCallingCodes) { - set calling_codes; + std::set calling_codes; phone_util_.GetSupportedGlobalNetworkCallingCodes(&calling_codes); EXPECT_GT(calling_codes.size(), 0U); - for (set::const_iterator it = calling_codes.begin(); + for (std::set::const_iterator it = calling_codes.begin(); it != calling_codes.end(); ++it) { EXPECT_GT(*it, 0); string region_code; @@ -145,6 +145,29 @@ TEST_F(PhoneNumberUtilTest, GetSupportedGlobalNetworkCallingCodes) { } } +TEST_F(PhoneNumberUtilTest, GetSupportedCallingCodes) { + std::set calling_codes; + + phone_util_.GetSupportedCallingCodes(&calling_codes); + EXPECT_GT(calling_codes.size(), 0U); + for (std::set::const_iterator it = calling_codes.begin(); + it != calling_codes.end(); ++it) { + EXPECT_GT(*it, 0); + string region_code; + phone_util_.GetRegionCodeForCountryCode(*it, ®ion_code); + EXPECT_NE(RegionCode::ZZ(), region_code); + } + std::set supported_global_network_calling_codes; + phone_util_.GetSupportedGlobalNetworkCallingCodes( + &supported_global_network_calling_codes); + // There should be more than just the global network calling codes in this + // set. + EXPECT_GT(calling_codes.size(), + supported_global_network_calling_codes.size()); + // But they should be included. Testing one of them. + EXPECT_NE(calling_codes.find(979), calling_codes.end()); +} + TEST_F(PhoneNumberUtilTest, GetSupportedTypesForRegion) { std::set types; phone_util_.GetSupportedTypesForRegion(RegionCode::BR(), &types); @@ -182,7 +205,7 @@ TEST_F(PhoneNumberUtilTest, GetSupportedTypesForNonGeoEntity) { } TEST_F(PhoneNumberUtilTest, GetRegionCodesForCountryCallingCode) { - list regions; + std::list regions; phone_util_.GetRegionCodesForCountryCallingCode(1, ®ions); EXPECT_TRUE(find(regions.begin(), regions.end(), RegionCode::US()) diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 4f608673c..d36673333 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -970,6 +970,19 @@ public class PhoneNumberUtil { return Collections.unmodifiableSet(countryCodesForNonGeographicalRegion); } + /** + * Returns all country calling codes the library has metadata for, covering both non-geographical + * entities (global network calling codes) and those used for geographical entities. This could be + * used to populate a drop-down box of country calling codes for a phone-number widget, for + * instance. + * + * @return an unordered set of the country calling codes for every geographical and + * non-geographical entity the library supports + */ + public Set getSupportedCallingCodes() { + return Collections.unmodifiableSet(countryCallingCodeToRegionCodeMap.keySet()); + } + /** * Returns true if there is any possible number data set for a particular PhoneNumberDesc. */ diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index ee09103bf..cc5e325a0 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -129,6 +129,19 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { } } + public void testGetSupportedCallingCodes() { + Set callingCodes = phoneUtil.getSupportedCallingCodes(); + assertTrue(callingCodes.size() > 0); + for (int callingCode : callingCodes) { + assertTrue(callingCode > 0); + assertTrue(phoneUtil.getRegionCodeForCountryCode(callingCode) != RegionCode.ZZ); + } + // There should be more than just the global network calling codes in this set. + assertTrue(callingCodes.size() > phoneUtil.getSupportedGlobalNetworkCallingCodes().size()); + // But they should be included. Testing one of them. + assertTrue(callingCodes.contains(979)); + } + public void testGetInstanceLoadBadMetadata() { assertNull(phoneUtil.getMetadataForRegion("No Such Region")); assertNull(phoneUtil.getMetadataForNonGeographicalRegion(-1)); diff --git a/javascript/i18n/phonenumbers/demo-compiled.js b/javascript/i18n/phonenumbers/demo-compiled.js index b100160bd..929356813 100644 --- a/javascript/i18n/phonenumbers/demo-compiled.js +++ b/javascript/i18n/phonenumbers/demo-compiled.js @@ -1,15 +1,16 @@ -(function(){for(var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},k="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,m=["String","prototype","repeat"],ba=0;baa||1342177279>>=1)b+=b;return c};fa!=ea&&null!=fa&&aa(k,da,{configurable:!0,writable:!0,value:fa}); -function ga(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; -else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function n(a){return"string"==typeof a}function p(a,b){function c(){}c.prototype=b.prototype;a.ca=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.na=function(a,c,f){for(var d=Array(arguments.length-2),e=2;ec?Math.max(0,a.length+c):c;if(n(a))return n(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?1:aa||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:aa.length?!1:N(eb,a)}function mb(a){return N(cb,a)?O(a,Wa):O(a,L)}function nb(a){var b=mb(a.toString());D(a);a.a(b)}function ob(a){return!!a&&(1!=z(a,9)||-1!=w(a,9)[0])} -function O(a,b){for(var c=new C,d,e=a.length,f=0;f=e)a=c;else if(d=d.substring(0,e),d=O(d,L),d.length)if(g=g.clone(),La(g,4),d=[g],g=y(b,1),c=Q(b),g in J){a=S(a,g,T(g));if(e=yb(d,c))d=e.clone(),e=y(e,4),0b?2:f[f.length-1]=f&&f<=e;++f)if(d=parseInt(c.substring(0,f),10),d in J)return b.a(c.substring(f)),d;return 0} -function Jb(a,b,c,d,e,f){if(!b.length)return 0;b=new C(b);var g;c&&(g=u(c,11));null==g&&(g="NonMatch");var h=b.toString();if(h.length)if(M.test(h))h=h.replace(M,""),D(b),b.a(mb(h)),g=1;else{h=new RegExp(g);nb(b);g=b.toString();if(g.search(h))g=!1;else{var h=g.match(h)[0].length,l=g.substring(h).match(Za);l&&null!=l[1]&&0=b.b.length)throw Error("Phone number too short after IDD");if(a=Ib(b, -d))return v(f,1,a),a;throw Error("Invalid country calling code");}if(c&&(g=y(c,10),h=""+g,l=b.toString(),!l.lastIndexOf(h,0)&&(h=new C(l.substring(h.length)),l=u(c,1),l=new RegExp(y(l,2)),Kb(h,c,null),h=h.toString(),!N(l,b.toString())&&N(l,h)||3==Gb(a,b.toString(),c,-1))))return d.a(h),e&&v(f,6,10),v(f,1,g),g;v(f,1,0);return 0} -function Kb(a,b,c){var d=a.toString(),e=d.length,f=u(b,15);if(e&&null!=f&&f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){var f=new RegExp(y(u(b,1),2)),h=N(f,d),l=e.length-1;b=u(b,16);if(null!=b&&b.length&&null!=e[l]&&e[l].length){if(d=d.replace(g,b),!h||N(f,d))c&&0g.b.length)throw Error("The string supplied is too short to be a phone number");b&&(c=new C,e=new C(g.toString()),Kb(e,b,c),2!=Gb(a,e.toString(),b,-1)&&(g=e,d&&0d)throw Error("The string supplied is too short to be a phone number");if(17a.length?!1:N($a,a)}function hb(a){return N(Ya,a)?O(a,Ra):O(a,L)}function ib(a){var b=hb(a.toString());D(a);a.a(b)}function lb(a){return!!a&&(1!=z(a,9)||-1!=w(a,9)[0])} +function O(a,b){for(var c=new C,d,e=a.length,f=0;f=e)a=c;else if(d=d.substring(0,e),d=O(d,L),d.length)if(g=g.clone(),Ga(g,4),d=[g],g=y(b,1),c=Q(b),g in J){a=S(a,g,T(g));if(e=tb(d,c))d=e.clone(),e=y(e,4),0b?2:f[f.length-1]=f&&f<=e;++f)if(d=parseInt(c.substring(0,f),10),d in J)return b.a(c.substring(f)),d;return 0} +function Eb(a,b,c,d,e,f){if(!b.length)return 0;b=new C(b);var g;c&&(g=u(c,11));null==g&&(g="NonMatch");var h=b.toString();if(h.length)if(M.test(h))h=h.replace(M,""),D(b),b.a(hb(h)),g=1;else{h=new RegExp(g);ib(b);g=b.toString();if(g.search(h))g=!1;else{var h=g.match(h)[0].length,l=g.substring(h).match(Ua);l&&null!=l[1]&&0=b.b.length)throw Error("Phone number too short after IDD");if(a=Db(b, +d))return v(f,1,a),a;throw Error("Invalid country calling code");}if(c&&(g=y(c,10),h=""+g,l=b.toString(),!l.lastIndexOf(h,0)&&(h=new C(l.substring(h.length)),l=u(c,1),l=new RegExp(y(l,2)),Fb(h,c,null),h=h.toString(),!N(l,b.toString())&&N(l,h)||3==Bb(a,b.toString(),c,-1))))return d.a(h),e&&v(f,6,10),v(f,1,g),g;v(f,1,0);return 0} +function Fb(a,b,c){var d=a.toString(),e=d.length,f=u(b,15);if(e&&null!=f&&f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){var f=new RegExp(y(u(b,1),2)),h=N(f,d),l=e.length-1;b=u(b,16);if(null!=b&&b.length&&null!=e[l]&&e[l].length){if(d=d.replace(g,b),!h||N(f,d))c&&0g.b.length)throw Error("The string supplied is too short to be a phone number");b&&(c=new C,e=new C(g.toString()),Fb(e,b,c),2!=Bb(a,e.toString(),b,-1)&&(g=e,d&&0d)throw Error("The string supplied is too short to be a phone number");if(17} the country calling codes for every - * non-geographical entity the library supports. + * non-geographical entity the library supports. */ i18n.phonenumbers.PhoneNumberUtil.prototype. getSupportedGlobalNetworkCallingCodes = function() { @@ -1356,6 +1355,23 @@ i18n.phonenumbers.PhoneNumberUtil.prototype. }; +/** + * Returns all country calling codes the library has metadata for, covering + * both non-geographical entities (global network calling codes) and those used + * for geographical entities. This could be used to populate a drop-down box of + * country calling codes for a phone-number widget, for instance. + * + * @return {!Array.} the country calling codes for every geographical + * and non-geographical entity the library supports. + */ +i18n.phonenumbers.PhoneNumberUtil.prototype.getSupportedCallingCodes = + function() { + return goog.array.join( + this.getSupportedGlobalNetworkCallingCodes(), + Object.keys(i18n.phonenumbers.metadata.countryCodeToRegionCodeMap)); +}; + + /** * Returns true if there is any possibleLength data set for a particular * PhoneNumberDesc. diff --git a/javascript/i18n/phonenumbers/phonenumberutil_test.js b/javascript/i18n/phonenumbers/phonenumberutil_test.js index df7c4e281..89cd8e513 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil_test.js +++ b/javascript/i18n/phonenumbers/phonenumberutil_test.js @@ -443,6 +443,23 @@ function testGetSupportedGlobalNetworkCallingCodes() { }); } +function testGetSupportedCallingCodes() { + assertTrue(phoneUtil.getSupportedCallingCodes().length > 0); + goog.array.forEach( + phoneUtil.getSupportedCallingCodes(), + function(callingCode) { + assertTrue(callingCode > 0); + assertFalse(phoneUtil.getRegionCodeForCountryCode(callingCode) + == RegionCode.ZZ); + }); + // There should be more than just the global network calling codes in this set. + assertTrue(phoneUtil.getSupportedCallingCodes().length > + phoneUtil.getSupportedGlobalNetworkCallingCodes().length); + // But they should be included. Testing one of them. + assertTrue(goog.array.contains( + phoneUtil.getSupportedGlobalNetworkCallingCodes(), 979)); +} + function testGetSupportedTypesForRegion() { var PNT = i18n.phonenumbers.PhoneNumberType; var types = phoneUtil.getSupportedTypesForRegion(RegionCode.BR); diff --git a/pending_code_changes.txt b/pending_code_changes.txt index 1e001990a..f63dfd12e 100644 --- a/pending_code_changes.txt +++ b/pending_code_changes.txt @@ -1,4 +1,7 @@ Code changes: + - New method getSupportedCallingCodes() API to return all the calling codes + that the library considers valid, both for geographical and non-geographical + entities. - Added isSmsServiceForRegion(PhoneNumber, RegionCode) API in C++ and Java short number info libraries. An SMS service is where the primary or only intended usage is to receive and/or send text messages (SMSs). This includes @@ -18,3 +21,6 @@ Code changes: - isPossibleNumber - isAlphaNumber - normalizeDigitsOnly & normalizeDiallableCharsOnly + - [C++ only] Removing most of the "using std::*" statements in + phonenumberutil.h file, leaving only using std::string. Changing the .cc and + test files to prefix "std::" where this was missing. diff --git a/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar b/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar index 828af831a..e7caaa9d0 100644 Binary files a/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar and b/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar differ diff --git a/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar b/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar index 4c7836004..ef69533e6 100644 Binary files a/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar and b/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar differ