@Test public void testZipCode() { Assert.assertTrue(FindAddress.isValidZipCode("90000")); Assert.assertTrue(FindAddress.isValidZipCode("01234")); Assert.assertTrue(FindAddress.isValidZipCode("99999-9999")); Assert.assertFalse(FindAddress.isValidZipCode("999999999")); Assert.assertFalse(FindAddress.isValidZipCode("9999-99999")); Assert.assertFalse(FindAddress.isValidZipCode("999999999-")); Assert.assertFalse(FindAddress.isValidZipCode("99999-999a")); Assert.assertFalse(FindAddress.isValidZipCode("99999--9999")); Assert.assertFalse(FindAddress.isValidZipCode("90000o")); Assert.assertFalse(FindAddress.isValidZipCode("90000-")); Assert.assertTrue(FindAddress.isValidZipCode("99000", "AK")); Assert.assertTrue(FindAddress.isValidZipCode("99000", "Alaska")); Assert.assertTrue(FindAddress.isValidZipCode("35000", "AL")); Assert.assertTrue(FindAddress.isValidZipCode("36000", "Alabama")); Assert.assertTrue(FindAddress.isValidZipCode("71000", "AR")); Assert.assertTrue(FindAddress.isValidZipCode("72000", "Arkansas")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "AS")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "American Samoa")); Assert.assertTrue(FindAddress.isValidZipCode("85000", "AZ")); Assert.assertTrue(FindAddress.isValidZipCode("86000", "Arizona")); Assert.assertTrue(FindAddress.isValidZipCode("90000", "CA")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "California")); Assert.assertTrue(FindAddress.isValidZipCode("80000", "CO")); Assert.assertTrue(FindAddress.isValidZipCode("81000", "Colorado")); Assert.assertTrue(FindAddress.isValidZipCode("06000", "CT")); Assert.assertTrue(FindAddress.isValidZipCode("06000", "Connecticut")); Assert.assertTrue(FindAddress.isValidZipCode("20000", "DC")); Assert.assertTrue(FindAddress.isValidZipCode("20000", "District of Columbia")); Assert.assertTrue(FindAddress.isValidZipCode("19000", "DE")); Assert.assertTrue(FindAddress.isValidZipCode("19000", "Delaware")); Assert.assertTrue(FindAddress.isValidZipCode("32000", "FL")); Assert.assertTrue(FindAddress.isValidZipCode("34000", "Florida")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "FM")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "Federated States of Micronesia")); Assert.assertTrue(FindAddress.isValidZipCode("30000", "GA")); Assert.assertTrue(FindAddress.isValidZipCode("31000", "Georgia")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "GU")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "Guam")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "HI")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "Hawaii")); Assert.assertTrue(FindAddress.isValidZipCode("50000", "IA")); Assert.assertTrue(FindAddress.isValidZipCode("52000", "Iowa")); Assert.assertTrue(FindAddress.isValidZipCode("83000", "ID")); Assert.assertTrue(FindAddress.isValidZipCode("83000", "Idaho")); Assert.assertTrue(FindAddress.isValidZipCode("60000", "IL")); Assert.assertTrue(FindAddress.isValidZipCode("62000", "Illinois")); Assert.assertTrue(FindAddress.isValidZipCode("46000", "IN")); Assert.assertTrue(FindAddress.isValidZipCode("47000", "Indiana")); Assert.assertTrue(FindAddress.isValidZipCode("66000", "KS")); Assert.assertTrue(FindAddress.isValidZipCode("67000", "Kansas")); Assert.assertTrue(FindAddress.isValidZipCode("40000", "KY")); Assert.assertTrue(FindAddress.isValidZipCode("42000", "Kentucky")); Assert.assertTrue(FindAddress.isValidZipCode("70000", "LA")); Assert.assertTrue(FindAddress.isValidZipCode("71000", "Louisiana")); Assert.assertTrue(FindAddress.isValidZipCode("01000", "MA")); Assert.assertTrue(FindAddress.isValidZipCode("02000", "Massachusetts")); Assert.assertTrue(FindAddress.isValidZipCode("20000", "MD")); Assert.assertTrue(FindAddress.isValidZipCode("21000", "Maryland")); Assert.assertTrue(FindAddress.isValidZipCode("03000", "ME")); Assert.assertTrue(FindAddress.isValidZipCode("04000", "Maine")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "MH")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "Marshall Islands")); Assert.assertTrue(FindAddress.isValidZipCode("48000", "MI")); Assert.assertTrue(FindAddress.isValidZipCode("49000", "Michigan")); Assert.assertTrue(FindAddress.isValidZipCode("55000", "MN")); Assert.assertTrue(FindAddress.isValidZipCode("56000", "Minnesota")); Assert.assertTrue(FindAddress.isValidZipCode("63000", "MO")); Assert.assertTrue(FindAddress.isValidZipCode("65000", "Missouri")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "MP")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "Northern Mariana Islands")); Assert.assertTrue(FindAddress.isValidZipCode("38000", "MS")); Assert.assertTrue(FindAddress.isValidZipCode("39000", "Mississippi")); Assert.assertTrue(FindAddress.isValidZipCode("55000", "MT")); Assert.assertTrue(FindAddress.isValidZipCode("56000", "Montana")); Assert.assertTrue(FindAddress.isValidZipCode("27000", "NC")); Assert.assertTrue(FindAddress.isValidZipCode("28000", "North Carolina")); Assert.assertTrue(FindAddress.isValidZipCode("58000", "ND")); Assert.assertTrue(FindAddress.isValidZipCode("58000", "North Dakota")); Assert.assertTrue(FindAddress.isValidZipCode("68000", "NE")); Assert.assertTrue(FindAddress.isValidZipCode("69000", "Nebraska")); Assert.assertTrue(FindAddress.isValidZipCode("03000", "NH")); Assert.assertTrue(FindAddress.isValidZipCode("04000", "New Hampshire")); Assert.assertTrue(FindAddress.isValidZipCode("07000", "NJ")); Assert.assertTrue(FindAddress.isValidZipCode("08000", "New Jersey")); Assert.assertTrue(FindAddress.isValidZipCode("87000", "NM")); Assert.assertTrue(FindAddress.isValidZipCode("88000", "New Mexico")); Assert.assertTrue(FindAddress.isValidZipCode("88000", "NV")); Assert.assertTrue(FindAddress.isValidZipCode("89000", "Nevada")); Assert.assertTrue(FindAddress.isValidZipCode("10000", "NY")); Assert.assertTrue(FindAddress.isValidZipCode("14000", "New York")); Assert.assertTrue(FindAddress.isValidZipCode("43000", "OH")); Assert.assertTrue(FindAddress.isValidZipCode("45000", "Ohio")); Assert.assertTrue(FindAddress.isValidZipCode("73000", "OK")); Assert.assertTrue(FindAddress.isValidZipCode("74000", "Oklahoma")); Assert.assertTrue(FindAddress.isValidZipCode("97000", "OR")); Assert.assertTrue(FindAddress.isValidZipCode("97000", "Oregon")); Assert.assertTrue(FindAddress.isValidZipCode("15000", "PA")); Assert.assertTrue(FindAddress.isValidZipCode("19000", "Pennsylvania")); Assert.assertTrue(FindAddress.isValidZipCode("06000", "PR")); Assert.assertTrue(FindAddress.isValidZipCode("06000", "Puerto Rico")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "PW")); Assert.assertTrue(FindAddress.isValidZipCode("96000", "Palau")); Assert.assertTrue(FindAddress.isValidZipCode("02000", "RI")); Assert.assertTrue(FindAddress.isValidZipCode("02000", "Rhode Island")); Assert.assertTrue(FindAddress.isValidZipCode("29000", "SC")); Assert.assertTrue(FindAddress.isValidZipCode("29000", "South Carolina")); Assert.assertTrue(FindAddress.isValidZipCode("57000", "SD")); Assert.assertTrue(FindAddress.isValidZipCode("57000", "South Dakota")); Assert.assertTrue(FindAddress.isValidZipCode("37000", "TN")); Assert.assertTrue(FindAddress.isValidZipCode("38000", "Tennessee")); Assert.assertTrue(FindAddress.isValidZipCode("75000", "TX")); Assert.assertTrue(FindAddress.isValidZipCode("79000", "Texas")); Assert.assertTrue(FindAddress.isValidZipCode("84000", "UT")); Assert.assertTrue(FindAddress.isValidZipCode("84000", "Utah")); Assert.assertTrue(FindAddress.isValidZipCode("22000", "VA")); Assert.assertTrue(FindAddress.isValidZipCode("24000", "Virginia")); Assert.assertTrue(FindAddress.isValidZipCode("06000", "VI")); Assert.assertTrue(FindAddress.isValidZipCode("09000", "Virgin Islands")); Assert.assertTrue(FindAddress.isValidZipCode("05000", "VT")); Assert.assertTrue(FindAddress.isValidZipCode("05000", "Vermont")); Assert.assertTrue(FindAddress.isValidZipCode("98000", "WA")); Assert.assertTrue(FindAddress.isValidZipCode("99000", "Washington")); Assert.assertTrue(FindAddress.isValidZipCode("53000", "WI")); Assert.assertTrue(FindAddress.isValidZipCode("54000", "Wisconsin")); Assert.assertTrue(FindAddress.isValidZipCode("24000", "WV")); Assert.assertTrue(FindAddress.isValidZipCode("26000", "West Virginia")); Assert.assertTrue(FindAddress.isValidZipCode("82000", "WY")); Assert.assertTrue(FindAddress.isValidZipCode("83000", "Wyoming")); }
private static boolean isValidZipCode(String zipCode, MatchResult stateMatch) { if (stateMatch == null) return false; int stateIndex = stateMatch.groupCount(); while (stateIndex > 0) { if (stateMatch.group(stateIndex--) != null) break; } return sZipCodeRe.matcher(zipCode).matches() && sStateZipCodeRanges[stateIndex].matches(zipCode); }
FindAddress { private static boolean isValidZipCode(String zipCode, MatchResult stateMatch) { if (stateMatch == null) return false; int stateIndex = stateMatch.groupCount(); while (stateIndex > 0) { if (stateMatch.group(stateIndex--) != null) break; } return sZipCodeRe.matcher(zipCode).matches() && sStateZipCodeRanges[stateIndex].matches(zipCode); } }
FindAddress { private static boolean isValidZipCode(String zipCode, MatchResult stateMatch) { if (stateMatch == null) return false; int stateIndex = stateMatch.groupCount(); while (stateIndex > 0) { if (stateMatch.group(stateIndex--) != null) break; } return sZipCodeRe.matcher(zipCode).matches() && sStateZipCodeRanges[stateIndex].matches(zipCode); } private  FindAddress(); }
FindAddress { private static boolean isValidZipCode(String zipCode, MatchResult stateMatch) { if (stateMatch == null) return false; int stateIndex = stateMatch.groupCount(); while (stateIndex > 0) { if (stateMatch.group(stateIndex--) != null) break; } return sZipCodeRe.matcher(zipCode).matches() && sStateZipCodeRanges[stateIndex].matches(zipCode); } private  FindAddress(); @VisibleForTesting static MatchResult matchHouseNumber(String content, int offset); @VisibleForTesting static MatchResult matchState(String content, int offset); @VisibleForTesting static boolean isValidZipCode(String zipCode, String state); @VisibleForTesting static boolean isValidZipCode(String zipCode); @VisibleForTesting static boolean isValidLocationName(String location); }
FindAddress { private static boolean isValidZipCode(String zipCode, MatchResult stateMatch) { if (stateMatch == null) return false; int stateIndex = stateMatch.groupCount(); while (stateIndex > 0) { if (stateMatch.group(stateIndex--) != null) break; } return sZipCodeRe.matcher(zipCode).matches() && sStateZipCodeRanges[stateIndex].matches(zipCode); } private  FindAddress(); @VisibleForTesting static MatchResult matchHouseNumber(String content, int offset); @VisibleForTesting static MatchResult matchState(String content, int offset); @VisibleForTesting static boolean isValidZipCode(String zipCode, String state); @VisibleForTesting static boolean isValidZipCode(String zipCode); @VisibleForTesting static boolean isValidLocationName(String location);  }