Skip to content

Commit 4c9ec27

Browse files
author
Bernhard Buss
committed
do not shorten NL postcodes
- adapt tests
1 parent f69c707 commit 4c9ec27

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

src/PostalCodes.UnitTests/CountrySpecificPostalCodes/NLPostalCodeManualTests.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,35 @@ namespace PostalCodes.UnitTests.CountrySpecificPostalCodes
66
internal class NLPostalCodeManualTests
77
{
88
[Test]
9-
[TestCase("9992 ZZ", "9991")]
9+
[TestCase("9992 ZZ", "9992ZY")]
1010
[TestCase("9992", "9991")]
11-
[TestCase("1000 ZZ", "0999")]
12-
[TestCase("4000 ZZ", "3999")]
11+
[TestCase("1000", "0999")]
12+
[TestCase("1000 AA", "0999ZZ")]
13+
[TestCase("4000 ZZ", "4000ZY")]
14+
[TestCase("4000", "3999")]
1315
[TestCase("1422", "1421")]
1416
public void Predecessor_ValidInput_ReturnsCorrectPostalCode(string postalCode, string postalCodePredecessor)
1517
{
1618
Assert.AreEqual(postalCodePredecessor, (new NLPostalCode(postalCode)).Predecessor.ToString());
1719
}
1820

1921
[Test]
20-
[TestCase("9992 ZZ", "9993")]
2122
[TestCase("9992", "9993")]
22-
[TestCase("1000 ZZ", "1001")]
23-
[TestCase("4000 ZZ", "4001")]
23+
[TestCase("9992 ZZ", "9993AA")]
24+
[TestCase("9992", "9993")]
25+
[TestCase("1000", "1001")]
26+
[TestCase("1000 ZZ", "1001AA")]
27+
[TestCase("4000", "4001")]
28+
[TestCase("4000 ZZ", "4001AA")]
2429
[TestCase("8999", "9000")]
30+
[TestCase("8999AA", "8999AB")]
2531
public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, string postalCodeSuccessor)
2632
{
2733
Assert.AreEqual(postalCodeSuccessor, (new NLPostalCode(postalCode)).Successor.ToString());
2834
}
2935

3036
[Test]
31-
[TestCase("0000 ZZ")]
37+
[TestCase("0000 AA")]
3238
[TestCase("0000")]
3339
public void Predecessor_FirstInRange_ReturnsNull(string postalCode)
3440
{

src/PostalCodes.UnitTests/Generated/NLPostalCodeTests.gen.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ namespace PostalCodes.UnitTests.Generated
77
internal class NLPostalCodeTests
88
{
99

10-
[TestCase("9999ZZ","9998")]
11-
[TestCase("1000AA","0999")]
10+
[TestCase("9999","9998")]
11+
[TestCase("1000","0999")]
12+
[TestCase("9999ZZ","9999ZY")]
13+
[TestCase("1000AA","0999ZZ")]
1214
public void Predecessor_ValidInput_ReturnsCorrectPostalCode(string postalCode, string postalCodePredecessor)
1315
{
1416
var code = new NLPostalCode(postalCode);
@@ -18,8 +20,10 @@ public void Predecessor_ValidInput_ReturnsCorrectPostalCode(string postalCode, s
1820
Assert.AreEqual(codePredecessor.ToHumanReadableString(), code.Predecessor.ToHumanReadableString());
1921
}
2022

21-
[TestCase("0999ZZ","1000")]
22-
[TestCase("3456JT","3457")]
23+
[TestCase("0999","1000")]
24+
[TestCase("3456","3457")]
25+
[TestCase("0999ZZ","1000AA")]
26+
[TestCase("3456JT","3456JU")]
2327
public void Successor_ValidInput_ReturnsCorrectPostalCode(string postalCode, string postalCodeSuccessor)
2428
{
2529
var code = new NLPostalCode(postalCode);
@@ -48,6 +52,11 @@ public void InvalidCode_ThrowsArgumentException(string postalCode)
4852
Assert.Throws<ArgumentException>(() => new NLPostalCode(postalCode));
4953
}
5054

55+
[TestCase("1234", "1236")]
56+
[TestCase("1234AA", "1236AA")]
57+
[TestCase("1235", "1237AA")]
58+
[TestCase("1235ZY", "1235ZZ")]
59+
[TestCase("1234ZZ", "1235")]
5160
public void CompareTo_ReturnsExpectedSign(string postalCodeBefore, string postalCodeAfter)
5261
{
5362
var b = new NLPostalCode(postalCodeBefore);

src/PostalCodes.UnitTests/PostalCodeFactoryTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ internal class PostalCodeFactoryTests
1111
[TestCase("GB", "A1 9ZZ", "A19ZZ", "GBPostalCode")] // long
1212
[TestCase("PT", "0042", "0042", "PTPostalCode")]
1313
[TestCase("CA", "A9A9A9", "A9A9A9", "CAPostalCode")]
14-
[TestCase("NL", "0024 ZZ", "0024", "NLPostalCode")]
14+
[TestCase("NL", "0024", "0024", "NLPostalCode")] // short NL
15+
[TestCase("NL", "0024 ZZ", "0024ZZ", "NLPostalCode")] // long NL
1516
[TestCase("MT", "PLA1234", "PLA1234", "MTPostalCode")]
1617
[TestCase("??", "004", "004", "DefaultPostalCode")]
1718
public void CreatePostalCode_ReturnsCorrectObjectType(string country, string postalCode, string normalizedPostalCode, string objectTypeName)

src/PostalCodes/Generated/NLPostalCode.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override int GetHashCode ()
4040
RegexShort = new Regex("^[0-9]{4}$", RegexOptions.Compiled),
4141
OutputDefault = "xxxx xx",
4242
OutputShort = "xxxx",
43-
AutoConvertToShort = true,
43+
AutoConvertToShort = false,
4444
ShortExpansionAsLowestInRange = "AA",
4545
ShortExpansionAsHighestInRange = "ZZ",
4646
LeftPaddingCharacter = "0",

src/countries/NL.json

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"LeftPaddingCharacter" : "0",
1616

17-
"AutoConvertToShort" : "true",
17+
"AutoConvertToShort" : "false",
1818
"ShortExpansionAsLowestInRange" : "AA",
1919
"ShortExpansionAsHighestInRange" : "ZZ"
2020
}
@@ -26,13 +26,24 @@
2626
"Valid" : ["1235DF", "5983DH"],
2727
"Invalid" : [ "12j4h", "k3j51l" ],
2828
"Predecessor" : {
29-
"9999ZZ" : "9998",
30-
"1000AA" : "0999"
29+
"9999" : "9998",
30+
"1000" : "0999",
31+
"9999ZZ": "9999ZY",
32+
"1000AA": "0999ZZ"
3133
},
3234
"Successor" : {
33-
"0999ZZ" : "1000",
34-
"3456JT" : "3457"
35+
"0999" : "1000",
36+
"3456" : "3457",
37+
"0999ZZ": "1000AA",
38+
"3456JT": "3456JU"
3539
},
36-
"IsBefore" : {}
40+
"IsBefore" : {
41+
"1234": "1236",
42+
"1234AA": "1234AB",
43+
"1235": "1237AA",
44+
"1234AA": "1236AA",
45+
"1235ZY": "1235ZZ",
46+
"1234ZZ": "1235"
47+
}
3748
}
3849
}

0 commit comments

Comments
 (0)