1 /* 2 * Copyright (C) 2013 The Libphonenumber Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.i18n.phonenumbers; 18 19 import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; 20 21 /** 22 * Unit tests for ShortNumberInfo.java 23 * 24 * @author Shaopeng Jia 25 */ 26 public class ShortNumberInfoTest extends TestMetadataTestCase { 27 private static final ShortNumberInfo shortInfo = ShortNumberInfo.getInstance(); 28 testIsPossibleShortNumber()29 public void testIsPossibleShortNumber() { 30 PhoneNumber possibleNumber = new PhoneNumber(); 31 possibleNumber.setCountryCode(33).setNationalNumber(123456L); 32 assertTrue(shortInfo.isPossibleShortNumber(possibleNumber)); 33 assertTrue( 34 shortInfo.isPossibleShortNumberForRegion(parse("123456", RegionCode.FR), RegionCode.FR)); 35 36 PhoneNumber impossibleNumber = new PhoneNumber(); 37 impossibleNumber.setCountryCode(33).setNationalNumber(9L); 38 assertFalse(shortInfo.isPossibleShortNumber(impossibleNumber)); 39 40 // Note that GB and GG share the country calling code 44, and that this number is possible but 41 // not valid. 42 assertTrue(shortInfo.isPossibleShortNumber( 43 new PhoneNumber().setCountryCode(44).setNationalNumber(11001L))); 44 } 45 testIsValidShortNumber()46 public void testIsValidShortNumber() { 47 assertTrue(shortInfo.isValidShortNumber( 48 new PhoneNumber().setCountryCode(33).setNationalNumber(1010L))); 49 assertTrue(shortInfo.isValidShortNumberForRegion(parse("1010", RegionCode.FR), RegionCode.FR)); 50 assertFalse(shortInfo.isValidShortNumber( 51 new PhoneNumber().setCountryCode(33).setNationalNumber(123456L))); 52 assertFalse( 53 shortInfo.isValidShortNumberForRegion(parse("123456", RegionCode.FR), RegionCode.FR)); 54 55 // Note that GB and GG share the country calling code 44. 56 assertTrue(shortInfo.isValidShortNumber( 57 new PhoneNumber().setCountryCode(44).setNationalNumber(18001L))); 58 } 59 testIsCarrierSpecific()60 public void testIsCarrierSpecific() { 61 PhoneNumber carrierSpecificNumber = new PhoneNumber(); 62 carrierSpecificNumber.setCountryCode(1).setNationalNumber(33669L); 63 assertTrue(shortInfo.isCarrierSpecific(carrierSpecificNumber)); 64 assertTrue( 65 shortInfo.isCarrierSpecificForRegion(parse("33669", RegionCode.US), RegionCode.US)); 66 67 PhoneNumber notCarrierSpecificNumber = new PhoneNumber(); 68 notCarrierSpecificNumber.setCountryCode(1).setNationalNumber(911L); 69 assertFalse(shortInfo.isCarrierSpecific(notCarrierSpecificNumber)); 70 assertFalse( 71 shortInfo.isCarrierSpecificForRegion(parse("911", RegionCode.US), RegionCode.US)); 72 73 PhoneNumber carrierSpecificNumberForSomeRegion = new PhoneNumber(); 74 carrierSpecificNumberForSomeRegion.setCountryCode(1).setNationalNumber(211L); 75 assertTrue(shortInfo.isCarrierSpecific(carrierSpecificNumberForSomeRegion)); 76 assertTrue( 77 shortInfo.isCarrierSpecificForRegion(carrierSpecificNumberForSomeRegion, RegionCode.US)); 78 assertFalse( 79 shortInfo.isCarrierSpecificForRegion(carrierSpecificNumberForSomeRegion, RegionCode.BB)); 80 } 81 testIsSmsService()82 public void testIsSmsService() { 83 PhoneNumber smsServiceNumberForSomeRegion = new PhoneNumber(); 84 smsServiceNumberForSomeRegion.setCountryCode(1).setNationalNumber(21234L); 85 assertTrue(shortInfo.isSmsServiceForRegion(smsServiceNumberForSomeRegion, RegionCode.US)); 86 assertFalse(shortInfo.isSmsServiceForRegion(smsServiceNumberForSomeRegion, RegionCode.BB)); 87 } 88 testGetExpectedCost()89 public void testGetExpectedCost() { 90 String premiumRateExample = shortInfo.getExampleShortNumberForCost(RegionCode.FR, 91 ShortNumberInfo.ShortNumberCost.PREMIUM_RATE); 92 assertEquals(ShortNumberInfo.ShortNumberCost.PREMIUM_RATE, shortInfo.getExpectedCostForRegion( 93 parse(premiumRateExample, RegionCode.FR), RegionCode.FR)); 94 PhoneNumber premiumRateNumber = new PhoneNumber(); 95 premiumRateNumber.setCountryCode(33).setNationalNumber(Integer.parseInt(premiumRateExample)); 96 assertEquals(ShortNumberInfo.ShortNumberCost.PREMIUM_RATE, 97 shortInfo.getExpectedCost(premiumRateNumber)); 98 99 String standardRateExample = shortInfo.getExampleShortNumberForCost(RegionCode.FR, 100 ShortNumberInfo.ShortNumberCost.STANDARD_RATE); 101 assertEquals(ShortNumberInfo.ShortNumberCost.STANDARD_RATE, shortInfo.getExpectedCostForRegion( 102 parse(standardRateExample, RegionCode.FR), RegionCode.FR)); 103 PhoneNumber standardRateNumber = new PhoneNumber(); 104 standardRateNumber.setCountryCode(33).setNationalNumber(Integer.parseInt(standardRateExample)); 105 assertEquals(ShortNumberInfo.ShortNumberCost.STANDARD_RATE, 106 shortInfo.getExpectedCost(standardRateNumber)); 107 108 String tollFreeExample = shortInfo.getExampleShortNumberForCost(RegionCode.FR, 109 ShortNumberInfo.ShortNumberCost.TOLL_FREE); 110 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 111 shortInfo.getExpectedCostForRegion(parse(tollFreeExample, RegionCode.FR), RegionCode.FR)); 112 PhoneNumber tollFreeNumber = new PhoneNumber(); 113 tollFreeNumber.setCountryCode(33).setNationalNumber(Integer.parseInt(tollFreeExample)); 114 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 115 shortInfo.getExpectedCost(tollFreeNumber)); 116 117 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 118 shortInfo.getExpectedCostForRegion(parse("12345", RegionCode.FR), RegionCode.FR)); 119 PhoneNumber unknownCostNumber = new PhoneNumber(); 120 unknownCostNumber.setCountryCode(33).setNationalNumber(12345L); 121 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 122 shortInfo.getExpectedCost(unknownCostNumber)); 123 124 // Test that an invalid number may nevertheless have a cost other than UNKNOWN_COST. 125 assertFalse( 126 shortInfo.isValidShortNumberForRegion(parse("116123", RegionCode.FR), RegionCode.FR)); 127 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 128 shortInfo.getExpectedCostForRegion(parse("116123", RegionCode.FR), RegionCode.FR)); 129 PhoneNumber invalidNumber = new PhoneNumber(); 130 invalidNumber.setCountryCode(33).setNationalNumber(116123L); 131 assertFalse(shortInfo.isValidShortNumber(invalidNumber)); 132 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 133 shortInfo.getExpectedCost(invalidNumber)); 134 135 // Test a nonexistent country code. 136 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 137 shortInfo.getExpectedCostForRegion(parse("911", RegionCode.US), RegionCode.ZZ)); 138 unknownCostNumber.clear(); 139 unknownCostNumber.setCountryCode(123).setNationalNumber(911L); 140 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 141 shortInfo.getExpectedCost(unknownCostNumber)); 142 } 143 testGetExpectedCostForSharedCountryCallingCode()144 public void testGetExpectedCostForSharedCountryCallingCode() { 145 // Test some numbers which have different costs in countries sharing the same country calling 146 // code. In Australia, 1234 is premium-rate, 1194 is standard-rate, and 733 is toll-free. These 147 // are not known to be valid numbers in the Christmas Islands. 148 String ambiguousPremiumRateString = "1234"; 149 PhoneNumber ambiguousPremiumRateNumber = 150 new PhoneNumber().setCountryCode(61).setNationalNumber(1234L); 151 String ambiguousStandardRateString = "1194"; 152 PhoneNumber ambiguousStandardRateNumber = 153 new PhoneNumber().setCountryCode(61).setNationalNumber(1194L); 154 String ambiguousTollFreeString = "733"; 155 PhoneNumber ambiguousTollFreeNumber = 156 new PhoneNumber().setCountryCode(61).setNationalNumber(733L); 157 158 assertTrue(shortInfo.isValidShortNumber(ambiguousPremiumRateNumber)); 159 assertTrue(shortInfo.isValidShortNumber(ambiguousStandardRateNumber)); 160 assertTrue(shortInfo.isValidShortNumber(ambiguousTollFreeNumber)); 161 162 assertTrue(shortInfo.isValidShortNumberForRegion( 163 parse(ambiguousPremiumRateString, RegionCode.AU), RegionCode.AU)); 164 assertEquals(ShortNumberInfo.ShortNumberCost.PREMIUM_RATE, shortInfo.getExpectedCostForRegion( 165 parse(ambiguousPremiumRateString, RegionCode.AU), RegionCode.AU)); 166 assertFalse(shortInfo.isValidShortNumberForRegion( 167 parse(ambiguousPremiumRateString, RegionCode.CX), RegionCode.CX)); 168 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, shortInfo.getExpectedCostForRegion( 169 parse(ambiguousPremiumRateString, RegionCode.CX), RegionCode.CX)); 170 // PREMIUM_RATE takes precedence over UNKNOWN_COST. 171 assertEquals(ShortNumberInfo.ShortNumberCost.PREMIUM_RATE, 172 shortInfo.getExpectedCost(ambiguousPremiumRateNumber)); 173 174 assertTrue(shortInfo.isValidShortNumberForRegion( 175 parse(ambiguousStandardRateString, RegionCode.AU), RegionCode.AU)); 176 assertEquals(ShortNumberInfo.ShortNumberCost.STANDARD_RATE, shortInfo.getExpectedCostForRegion( 177 parse(ambiguousStandardRateString, RegionCode.AU), RegionCode.AU)); 178 assertFalse(shortInfo.isValidShortNumberForRegion( 179 parse(ambiguousStandardRateString, RegionCode.CX), RegionCode.CX)); 180 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, shortInfo.getExpectedCostForRegion( 181 parse(ambiguousStandardRateString, RegionCode.CX), RegionCode.CX)); 182 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 183 shortInfo.getExpectedCost(ambiguousStandardRateNumber)); 184 185 assertTrue(shortInfo.isValidShortNumberForRegion(parse(ambiguousTollFreeString, RegionCode.AU), 186 RegionCode.AU)); 187 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, shortInfo.getExpectedCostForRegion( 188 parse(ambiguousTollFreeString, RegionCode.AU), RegionCode.AU)); 189 assertFalse(shortInfo.isValidShortNumberForRegion(parse(ambiguousTollFreeString, RegionCode.CX), 190 RegionCode.CX)); 191 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, shortInfo.getExpectedCostForRegion( 192 parse(ambiguousTollFreeString, RegionCode.CX), RegionCode.CX)); 193 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 194 shortInfo.getExpectedCost(ambiguousTollFreeNumber)); 195 } 196 testExampleShortNumberPresence()197 public void testExampleShortNumberPresence() { 198 assertFalse(shortInfo.getExampleShortNumber(RegionCode.AD).isEmpty()); 199 assertFalse(shortInfo.getExampleShortNumber(RegionCode.FR).isEmpty()); 200 assertTrue(shortInfo.getExampleShortNumber(RegionCode.UN001).isEmpty()); 201 assertTrue(shortInfo.getExampleShortNumber(null).isEmpty()); 202 } 203 testConnectsToEmergencyNumber_US()204 public void testConnectsToEmergencyNumber_US() { 205 assertTrue(shortInfo.connectsToEmergencyNumber("911", RegionCode.US)); 206 assertTrue(shortInfo.connectsToEmergencyNumber("112", RegionCode.US)); 207 assertFalse(shortInfo.connectsToEmergencyNumber("999", RegionCode.US)); 208 } 209 testConnectsToEmergencyNumberLongNumber_US()210 public void testConnectsToEmergencyNumberLongNumber_US() { 211 assertTrue(shortInfo.connectsToEmergencyNumber("9116666666", RegionCode.US)); 212 assertTrue(shortInfo.connectsToEmergencyNumber("1126666666", RegionCode.US)); 213 assertFalse(shortInfo.connectsToEmergencyNumber("9996666666", RegionCode.US)); 214 } 215 testConnectsToEmergencyNumberWithFormatting_US()216 public void testConnectsToEmergencyNumberWithFormatting_US() { 217 assertTrue(shortInfo.connectsToEmergencyNumber("9-1-1", RegionCode.US)); 218 assertTrue(shortInfo.connectsToEmergencyNumber("1-1-2", RegionCode.US)); 219 assertFalse(shortInfo.connectsToEmergencyNumber("9-9-9", RegionCode.US)); 220 } 221 testConnectsToEmergencyNumberWithPlusSign_US()222 public void testConnectsToEmergencyNumberWithPlusSign_US() { 223 assertFalse(shortInfo.connectsToEmergencyNumber("+911", RegionCode.US)); 224 assertFalse(shortInfo.connectsToEmergencyNumber("\uFF0B911", RegionCode.US)); 225 assertFalse(shortInfo.connectsToEmergencyNumber(" +911", RegionCode.US)); 226 assertFalse(shortInfo.connectsToEmergencyNumber("+112", RegionCode.US)); 227 assertFalse(shortInfo.connectsToEmergencyNumber("+999", RegionCode.US)); 228 } 229 testConnectsToEmergencyNumber_BR()230 public void testConnectsToEmergencyNumber_BR() { 231 assertTrue(shortInfo.connectsToEmergencyNumber("911", RegionCode.BR)); 232 assertTrue(shortInfo.connectsToEmergencyNumber("190", RegionCode.BR)); 233 assertFalse(shortInfo.connectsToEmergencyNumber("999", RegionCode.BR)); 234 } 235 testConnectsToEmergencyNumberLongNumber_BR()236 public void testConnectsToEmergencyNumberLongNumber_BR() { 237 // Brazilian emergency numbers don't work when additional digits are appended. 238 assertFalse(shortInfo.connectsToEmergencyNumber("9111", RegionCode.BR)); 239 assertFalse(shortInfo.connectsToEmergencyNumber("1900", RegionCode.BR)); 240 assertFalse(shortInfo.connectsToEmergencyNumber("9996", RegionCode.BR)); 241 } 242 testConnectsToEmergencyNumber_CL()243 public void testConnectsToEmergencyNumber_CL() { 244 assertTrue(shortInfo.connectsToEmergencyNumber("131", RegionCode.CL)); 245 assertTrue(shortInfo.connectsToEmergencyNumber("133", RegionCode.CL)); 246 } 247 testConnectsToEmergencyNumberLongNumber_CL()248 public void testConnectsToEmergencyNumberLongNumber_CL() { 249 // Chilean emergency numbers don't work when additional digits are appended. 250 assertFalse(shortInfo.connectsToEmergencyNumber("1313", RegionCode.CL)); 251 assertFalse(shortInfo.connectsToEmergencyNumber("1330", RegionCode.CL)); 252 } 253 testConnectsToEmergencyNumber_AO()254 public void testConnectsToEmergencyNumber_AO() { 255 // Angola doesn't have any metadata for emergency numbers in the test metadata. 256 assertFalse(shortInfo.connectsToEmergencyNumber("911", RegionCode.AO)); 257 assertFalse(shortInfo.connectsToEmergencyNumber("222123456", RegionCode.AO)); 258 assertFalse(shortInfo.connectsToEmergencyNumber("923123456", RegionCode.AO)); 259 } 260 testConnectsToEmergencyNumber_ZW()261 public void testConnectsToEmergencyNumber_ZW() { 262 // Zimbabwe doesn't have any metadata in the test metadata. 263 assertFalse(shortInfo.connectsToEmergencyNumber("911", RegionCode.ZW)); 264 assertFalse(shortInfo.connectsToEmergencyNumber("01312345", RegionCode.ZW)); 265 assertFalse(shortInfo.connectsToEmergencyNumber("0711234567", RegionCode.ZW)); 266 } 267 testIsEmergencyNumber_US()268 public void testIsEmergencyNumber_US() { 269 assertTrue(shortInfo.isEmergencyNumber("911", RegionCode.US)); 270 assertTrue(shortInfo.isEmergencyNumber("112", RegionCode.US)); 271 assertFalse(shortInfo.isEmergencyNumber("999", RegionCode.US)); 272 } 273 testIsEmergencyNumberLongNumber_US()274 public void testIsEmergencyNumberLongNumber_US() { 275 assertFalse(shortInfo.isEmergencyNumber("9116666666", RegionCode.US)); 276 assertFalse(shortInfo.isEmergencyNumber("1126666666", RegionCode.US)); 277 assertFalse(shortInfo.isEmergencyNumber("9996666666", RegionCode.US)); 278 } 279 testIsEmergencyNumberWithFormatting_US()280 public void testIsEmergencyNumberWithFormatting_US() { 281 assertTrue(shortInfo.isEmergencyNumber("9-1-1", RegionCode.US)); 282 assertTrue(shortInfo.isEmergencyNumber("*911", RegionCode.US)); 283 assertTrue(shortInfo.isEmergencyNumber("1-1-2", RegionCode.US)); 284 assertTrue(shortInfo.isEmergencyNumber("*112", RegionCode.US)); 285 assertFalse(shortInfo.isEmergencyNumber("9-9-9", RegionCode.US)); 286 assertFalse(shortInfo.isEmergencyNumber("*999", RegionCode.US)); 287 } 288 testIsEmergencyNumberWithPlusSign_US()289 public void testIsEmergencyNumberWithPlusSign_US() { 290 assertFalse(shortInfo.isEmergencyNumber("+911", RegionCode.US)); 291 assertFalse(shortInfo.isEmergencyNumber("\uFF0B911", RegionCode.US)); 292 assertFalse(shortInfo.isEmergencyNumber(" +911", RegionCode.US)); 293 assertFalse(shortInfo.isEmergencyNumber("+112", RegionCode.US)); 294 assertFalse(shortInfo.isEmergencyNumber("+999", RegionCode.US)); 295 } 296 testIsEmergencyNumber_BR()297 public void testIsEmergencyNumber_BR() { 298 assertTrue(shortInfo.isEmergencyNumber("911", RegionCode.BR)); 299 assertTrue(shortInfo.isEmergencyNumber("190", RegionCode.BR)); 300 assertFalse(shortInfo.isEmergencyNumber("999", RegionCode.BR)); 301 } 302 testIsEmergencyNumberLongNumber_BR()303 public void testIsEmergencyNumberLongNumber_BR() { 304 assertFalse(shortInfo.isEmergencyNumber("9111", RegionCode.BR)); 305 assertFalse(shortInfo.isEmergencyNumber("1900", RegionCode.BR)); 306 assertFalse(shortInfo.isEmergencyNumber("9996", RegionCode.BR)); 307 } 308 testIsEmergencyNumber_AO()309 public void testIsEmergencyNumber_AO() { 310 // Angola doesn't have any metadata for emergency numbers in the test metadata. 311 assertFalse(shortInfo.isEmergencyNumber("911", RegionCode.AO)); 312 assertFalse(shortInfo.isEmergencyNumber("222123456", RegionCode.AO)); 313 assertFalse(shortInfo.isEmergencyNumber("923123456", RegionCode.AO)); 314 } 315 testIsEmergencyNumber_ZW()316 public void testIsEmergencyNumber_ZW() { 317 // Zimbabwe doesn't have any metadata in the test metadata. 318 assertFalse(shortInfo.isEmergencyNumber("911", RegionCode.ZW)); 319 assertFalse(shortInfo.isEmergencyNumber("01312345", RegionCode.ZW)); 320 assertFalse(shortInfo.isEmergencyNumber("0711234567", RegionCode.ZW)); 321 } 322 testEmergencyNumberForSharedCountryCallingCode()323 public void testEmergencyNumberForSharedCountryCallingCode() { 324 // Test the emergency number 112, which is valid in both Australia and the Christmas Islands. 325 assertTrue(shortInfo.isEmergencyNumber("112", RegionCode.AU)); 326 assertTrue(shortInfo.isValidShortNumberForRegion(parse("112", RegionCode.AU), RegionCode.AU)); 327 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 328 shortInfo.getExpectedCostForRegion(parse("112", RegionCode.AU), RegionCode.AU)); 329 assertTrue(shortInfo.isEmergencyNumber("112", RegionCode.CX)); 330 assertTrue(shortInfo.isValidShortNumberForRegion(parse("112", RegionCode.CX), RegionCode.CX)); 331 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 332 shortInfo.getExpectedCostForRegion(parse("112", RegionCode.CX), RegionCode.CX)); 333 PhoneNumber sharedEmergencyNumber = 334 new PhoneNumber().setCountryCode(61).setNationalNumber(112L); 335 assertTrue(shortInfo.isValidShortNumber(sharedEmergencyNumber)); 336 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 337 shortInfo.getExpectedCost(sharedEmergencyNumber)); 338 } 339 testOverlappingNANPANumber()340 public void testOverlappingNANPANumber() { 341 // 211 is an emergency number in Barbados, while it is a toll-free information line in Canada 342 // and the USA. 343 assertTrue(shortInfo.isEmergencyNumber("211", RegionCode.BB)); 344 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 345 shortInfo.getExpectedCostForRegion(parse("211", RegionCode.BB), RegionCode.BB)); 346 assertFalse(shortInfo.isEmergencyNumber("211", RegionCode.US)); 347 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 348 shortInfo.getExpectedCostForRegion(parse("211", RegionCode.US), RegionCode.US)); 349 assertFalse(shortInfo.isEmergencyNumber("211", RegionCode.CA)); 350 assertEquals(ShortNumberInfo.ShortNumberCost.TOLL_FREE, 351 shortInfo.getExpectedCostForRegion(parse("211", RegionCode.CA), RegionCode.CA)); 352 } 353 testCountryCallingCodeIsNotIgnored()354 public void testCountryCallingCodeIsNotIgnored() { 355 // +46 is the country calling code for Sweden (SE), and 40404 is a valid short number in the US. 356 assertFalse(shortInfo.isPossibleShortNumberForRegion( 357 parse("+4640404", RegionCode.SE), RegionCode.US)); 358 assertFalse(shortInfo.isValidShortNumberForRegion( 359 parse("+4640404", RegionCode.SE), RegionCode.US)); 360 assertEquals(ShortNumberInfo.ShortNumberCost.UNKNOWN_COST, 361 shortInfo.getExpectedCostForRegion( 362 parse("+4640404", RegionCode.SE), RegionCode.US)); 363 } 364 parse(String number, String regionCode)365 private PhoneNumber parse(String number, String regionCode) { 366 try { 367 return phoneUtil.parse(number, regionCode); 368 } catch (NumberParseException e) { 369 throw new AssertionError( 370 "Test input data should always parse correctly: " + number + " (" + regionCode + ")", e); 371 } 372 } 373 } 374