Skip to content

Commit 7db79a9

Browse files
committed
Added test
1 parent b1cf610 commit 7db79a9

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/main/java/com/mapcode/example/Example.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,41 @@ private static void exampleDecode() throws UnknownTerritoryException {
5555
}
5656

5757
/**
58-
* The second example tries to decode an invalid Mapcode to a point which results
58+
* This second example shows you how to decode a Mapcode to a point, which already includes a
59+
* territory name.
60+
*/
61+
final String mapcode2 = "NLD 49.4V";
62+
try {
63+
final Point p = Mapcode.decode(mapcode2);
64+
LOG.info("Mapcode {} in territory {} represents latitude {}, longitude {}",
65+
mapcode1, territory, p.getLatDeg(), p.getLonDeg());
66+
}
67+
catch (final UnknownMapcodeException ignored) {
68+
LOG.info("This should never happen in this example as the Mapcode is valid.");
69+
}
70+
71+
/**
72+
* The third example tries to decode an invalid Mapcode to a point which results
5973
* in an exception being thrown.
6074
*/
61-
final String mapcode2 = "49.4A";
75+
final String mapcode3 = "49.4A";
6276
try {
63-
final Point p = Mapcode.decode(mapcode2, territory);
77+
final Point p = Mapcode.decode(mapcode3, territory);
6478
LOG.info("Mapcode {} in territory {} represents latitude {}, longitude {}",
65-
mapcode2, territory, p.getLatDeg(), p.getLonDeg());
79+
mapcode3, territory, p.getLatDeg(), p.getLonDeg());
6680
}
6781
catch (final UnknownMapcodeException ignored) {
68-
LOG.info("Mapcode {} in territory {} is invalid, as expected in this example", mapcode2, territory);
82+
LOG.info("Mapcode {} in territory {} is invalid, as expected in this example", mapcode3, territory);
6983
}
7084

7185
/**
72-
* The third example tries to decode a valid international Mapcode without a territory context.
86+
* The fourht example tries to decode a valid international Mapcode without a territory context.
7387
* This will succeed.
7488
*/
75-
final String mapcode3 = "PQ0PF.5M1H";
89+
final String mapcode4 = "PQ0PF.5M1H";
7690
try {
77-
final Point p = Mapcode.decode(mapcode3);
78-
LOG.info("Mapcode {} represents latitude {}, longitude {}", mapcode3, p.getLatDeg(), p.getLonDeg());
91+
final Point p = Mapcode.decode(mapcode4);
92+
LOG.info("Mapcode {} represents latitude {}, longitude {}", mapcode4, p.getLatDeg(), p.getLonDeg());
7993
}
8094
catch (final UnknownMapcodeException ignored) {
8195
LOG.info("This should never happen in this example as the Mapcode is valid.");

0 commit comments

Comments
 (0)