Skip to content

Commit

Permalink
Work in progress updating SPACE test implementations to current (2023…
Browse files Browse the repository at this point in the history
…-06-28) specifications. Tuning tdwg/bdq#48 AMENDMENT_COUNTRYCODE_STANDARDIZED to pass DataID: 265, matching numeric counntry codes with non-standard leading zeroes.
  • Loading branch information
chicoreus committed Jun 29, 2023
1 parent e2b7d54 commit d02680f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,21 @@ public static String lookupCode2FromCodeName(String countryCodeOrName) {
done = true;
}
}
} else if (countryCodeOrName.matches("^0[0-9]+")) {
country = lookupCountryFromCode(countryCodeOrName.replaceAll("^0+", ""));
if (country!=null) {
// provided string is a numeric country code with leading zeroes
List<String> values = codes.get(country);
Iterator<String> iv = values.iterator();
boolean done = false;
while (iv.hasNext()&&!done) {
String v = iv.next();
if (v.matches("^[A-Z][A-Z]$" )) {
result = v;
done = true;
}
}
}
} else if (codes.containsKey(countryCodeOrName)) {
// provided string is a country name
List<String> values = codes.get(countryCodeOrName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public void testCountryCodeFindCode2() {
assertNull(CountryLookup.lookupCode2FromCodeName(""));
assertEquals("UG",CountryLookup.lookupCode2FromCodeName("UGA"));
assertEquals("UG",CountryLookup.lookupCode2FromCodeName("Uganda"));
assertEquals("AF",CountryLookup.lookupCode2FromCodeName("4"));
assertEquals("AF",CountryLookup.lookupCode2FromCodeName("004"));
}


Expand Down

0 comments on commit d02680f

Please sign in to comment.