Changeset 11259 in josm for trunk/test/unit


Ignore:
Timestamp:
2016-11-16T00:27:08+01:00 (7 years ago)
Author:
Don-vip
Message:

see #10387 - see #12914 - add debug info for failing unit test, remove operator=RFF check as the tag does not exist anymore

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/RightAndLefthandTrafficTest.java

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