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

Last change on this file since 11647 was 11324, checked in by Don-vip, 7 years ago

findbugs

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