Skip to content

Commit 315a328

Browse files
inesfilipesergiofbsilva
authored andcommitted
Added test to match example against regex PCT-6 #resolve (#6)
1 parent 84acd6a commit 315a328

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/main/resources/postal-codes.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"ISO": "",
66
"Format": "BIQQ 1ZZ",
77
"Regex": "^[Bb][Ii][Qq]{2}\\s{0,1}[1][Zz]{2}$",
8-
"Example": "Desconhecido"
8+
"Example": "BiqQ1zZ"
99
},
1010
{
1111
"Note": "U.S. ZIP codes. ZIP codes 006XX for NW PR, 007XX for SE PR, in which XX designates the town or post office and 009XX for the San Juan Metropolitan Area, in which XX designates the area or borough of San Juan. The last four digits identify an area within the post office. For example 00716-2604: 00716-for the east section of the city of Ponce and 2604 for Aceitillo St. in the neighborhood of Los Caobos. US Post office is changing the PR address format to the American one: 1234 No Name Avenue, San Juan, PR 00901.",
@@ -381,7 +381,7 @@
381381
"ISO": "SE",
382382
"Format": "NNNNN (NNN NN)",
383383
"Regex": "^(\\d{5}|\\d{3}\\s\\d{2})$",
384-
"Example": "70040 (700 40)"
384+
"Example": "70040"
385385
},
386386
{
387387
"Note": "Each building has its own unique postcode.",
@@ -445,7 +445,7 @@
445445
"ISO": "SK",
446446
"Format": "NNNNN (NNN NN)",
447447
"Regex": "^(\\d{5}|\\d{3}\\s\\d{2})$",
448-
"Example": "75350 (506 84)"
448+
"Example": "75350"
449449
},
450450
{
451451
"Note": "",
@@ -1069,7 +1069,7 @@
10691069
"ISO": "GB",
10701070
"Format": "A(A)N(A/N)NAA (A[A]N[A/N] NAA)",
10711071
"Regex": "^([A-Za-z]{1,2}\\d([A-Za-z]|\\d)?\\d[A-Za-z]{2}|[A-Za-z]{1,2}\\d([A-Za-z]|\\d)?\\s\\d[A-Za-z]{2})$",
1072-
"Example": "j6Q3we - (j6Q 3we) js6Q3we - (js6Q 3we)"
1072+
"Example": "j6Q3we"
10731073
},
10741074
{
10751075
"Note": "",
@@ -1308,7 +1308,7 @@
13081308
"Country": "Isle of Man",
13091309
"ISO": "IM",
13101310
"Format": "CCN NAA, CCNN NAA",
1311-
"Regex": "^[Ii[Mm]\\d{1,2}\\s\\d\\[A-Z]{2}$",
1311+
"Regex": "^[Ii][Mm]\\d{1,2}\\s\\d[A-Z]{2}$",
13121312
"Example": "IM1 1AJ"
13131313
},
13141314
{

src/test/java/org/fenixedu/PostalCodeValidatorTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ public void testLoadDifferentJsonFile() {
2323
assertEquals(1, PostalCodeValidator.getValidatorMap().size());
2424
}
2525

26+
@Test
27+
public void testExampleRegex() {
28+
PostalCodeValidator.getValidatorMap().values().forEach(p -> {
29+
String country = p.get("ISO").getAsString();
30+
String example = p.get("Example").getAsString();
31+
assertTrue(String.format("Example does not match for country \"%s\"", country), PostalCodeValidator.isValidAreaCode(country, example));
32+
});
33+
}
34+
2635
}

0 commit comments

Comments
 (0)