source: josm/trunk/test/unit/org/openstreetmap/josm/tools/RightAndLefthandTrafficTest.java@ 16182

Last change on this file since 16182 was 16182, checked in by simon04, 5 years ago

Fix typos in Javadoc

  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.Assert.fail;
5
6import org.junit.Rule;
7import org.junit.Test;
8import org.openstreetmap.josm.data.coor.LatLon;
9import org.openstreetmap.josm.testutils.JOSMTestRules;
10
11import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
12import net.trajano.commons.testing.UtilityClassTestUtil;
13
14/**
15 * Unit tests of {@link RightAndLefthandTraffic} class.
16 */
17public class RightAndLefthandTrafficTest {
18 /**
19 * Test rules.
20 */
21 @Rule
22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
23 public JOSMTestRules rules = new JOSMTestRules().projection().rlTraffic();
24
25 /**
26 * Tests that {@code RightAndLefthandTraffic} satisfies utility class criteria.
27 * @throws ReflectiveOperationException if an error occurs
28 */
29 @Test
30 public void testUtilityClass() throws ReflectiveOperationException {
31 UtilityClassTestUtil.assertUtilityClassWellDefined(RightAndLefthandTraffic.class);
32 }
33
34 /**
35 * Test of {@link RightAndLefthandTraffic#isRightHandTraffic} method.
36 */
37 @Test
38 public void testIsRightHandTraffic() {
39 check(true, "Paris", 48.8567, 2.3508);
40 check(true, "Berlin", 52.5167, 13.383);
41 check(true, "New York", 40.7127, -74.0059);
42 check(true, "Papeete", -17.5419, -149.5617);
43 check(true, "Guantanamo", 19.912, -75.209);
44 check(true, "Guadeloupe", 16.243, -61.533);
45 check(true, "Martinique", 14.604, -61.069);
46 check(true, "Madagascar", -20.119, 46.316);
47 check(true, "Shangai", 31.196, 121.36);
48 check(true, "Gibraltar", 36.141244, -5.347369);
49 check(true, "British Indian Ocean Territory", -7.3, 72.4);
50
51 check(false, "London", 51.507222, -0.1275);
52 check(false, "Valetta (Malta)", 35.897778, 14.5125);
53 check(false, "Jersey", 49.19, -2.11);
54 check(false, "Isle of Man", 54.25, -4.5);
55 check(false, "Dublin (Ireland)", 53.347778, -6.259722);
56 check(false, "Guernsey", 49.45, -2.6);
57 check(false, "Nicosia (Cyprus)", 35.166667, 33.366667);
58 check(false, "Georgetown (Guyana)", 6.8, -58.166667);
59 check(false, "Paramaribo (Suriname)", 5.866667, -55.166667);
60 check(false, "Anguilla", 18.22723, -63.04899);
61 check(false, "Antigua and Barbuda", 17.05, -61.8);
62 check(false, "Bahamas", 24.25, -76);
63 check(false, "Barbados", 13.166667, -59.55);
64 check(false, "British Virgin Islands", 18.5, -64.5);
65 check(false, "Cayman Islands", 19.5, -80.5);
66 check(false, "Dominica", 15.416667, -61.333333);
67 check(false, "Grenada", 12.116667, -61.666667);
68 check(false, "Jamaica", 18, -77);
69 check(false, "Montserrat", 16.75, -62.2);
70 check(false, "Saint Kitts and Nevis", 17.333333, -62.75);
71 check(false, "Saint Lucia", 13.883333, -60.966667);
72 check(false, "Saint Vincent and the Grenadines", 13.25, -61.2);
73 check(false, "Trinidad and Tobago", 11.249285, -60.652557);
74 check(false, "Turks and Caicos Islands", 21.75, -71.583333);
75 check(false, "United States Virgin Islands", 18.35, -64.933333);
76 check(false, "Bermuda", 32.333333, -64.75);
77 check(false, "Falkland Islands", -51.683333, -59.166667);
78 check(false, "Saint Helena, Ascension and Tristan da Cunha", -15.933, -5.717);
79 check(false, "South Georgia and the South Sandwich Islands", -54.25, -36.75);
80 check(false, "Maldives", 3.2, 73.22);
81 check(false, "Mauritius", -20.2, 57.5);
82 check(false, "Seychelles", -4.583333, 55.666667);
83 check(false, "Bangladesh", 23.8, 90.3);
84 check(false, "Bhutan", 27.417, 90.435);
85 check(false, "Brunei", 4.5, 114.666667);
86 check(false, "East Timor", -8.833333, 125.916667);
87 check(false, "Hong Kong", 22.3, 114.2);
88 check(false, "Indonesia", -5, 120);
89 check(false, "India", 21, 78);
90 check(false, "Japan", 35, 136);
91 check(false, "Macau", 22.166667, 113.55);
92 check(false, "Malaysia", 2.5, 112.5);
93 check(false, "Nepal", 28.166667, 84.25);
94 check(false, "Pakistan", 30, 70);
95 check(false, "Singapore", 1.3, 103.8);
96 check(false, "Sri Lanka", 7, 81);
97 check(false, "Thailand", 15.4, 101.3);
98 check(false, "Botswana", -24.658333, 25.908333);
99 check(false, "Kenya", 1, 38);
100 check(false, "Lesotho", -29.6, 28.3);
101 check(false, "Malawi", -13.5, 34);
102 check(false, "Mauritius", -20.2, 57.5);
103 check(false, "Mozambique", -18.25, 35);
104 check(false, "Namibia", -22, 17);
105 check(false, "South Africa", -30, 25);
106 check(false, "Swaziland", -26.5, 31.5);
107 check(false, "Tanzania", -6.307, 34.854);
108 check(false, "Uganda", 1, 32);
109 check(false, "Zambia", -15, 30);
110 check(false, "Zimbabwe", -20, 30);
111 check(false, "Australia", -27, 133);
112 check(false, "Christmas Island", -10.483333, 105.633333);
113 check(false, "Cocos (Keeling) Islands", -12.116667, 96.9);
114 check(false, "Cook Islands", -21.233333, -159.766667);
115 check(false, "Fiji", -18, 179);
116 check(false, "Kiribati", 1.416667, 173);
117 check(false, "Nauru", -0.533333, 166.933333);
118 check(false, "New Zealand", -42, 174);
119 check(false, "Niue", -19.05, -169.916667);
120 check(false, "Norfolk Island", -29.033333, 167.95);
121 check(false, "Papua New Guinea", -6, 147);
122 check(false, "Pitcairn Islands", -25.066667, -130.1);
123 check(false, "Solomon Islands", -8, 159);
124 check(false, "Samoa", -13.583333, -172.333333);
125 check(false, "Tokelau", -9.166667, -171.833333);
126 check(false, "Tonga", -20, -175);
127 check(false, "Tuvalu", -8, 178);
128 }
129
130 private static void check(boolean expected, String name, double lat, double lon) {
131 boolean actual = RightAndLefthandTraffic.isRightHandTraffic(new LatLon(lat, lon));
132 if (actual != expected) {
133 fail(name);
134 }
135 }
136}
Note: See TracBrowser for help on using the repository browser.