Changeset 11045 in josm for trunk/test


Ignore:
Timestamp:
2016-09-23T21:13:02+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #13674 - allow case insensitive lat/lon input + reject more invalid cases

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java

    r10945 r11045  
    204204        assertEquals(10, ll3.getCenter(ll2).lon(), 1e-10);
    205205    }
     206
     207    /**
     208     * Unit test of {@link LatLon#parse} method.
     209     */
     210    @Test
     211    public void testParse() {
     212        assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918° 19.24788°"));
     213        assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("N 49.29918 E 19.24788°"));
     214        assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918° 19.24788°"));
     215        assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("N 49.29918 E 19.24788"));
     216        assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("n 49.29918 e 19.24788"));
     217        assertEquals(new LatLon(-19 - 24.788 / 60, -49 - 29.918 / 60), LatLon.parse("W 49°29.918' S 19°24.788'"));
     218        assertEquals(new LatLon(-19 - 24.788 / 60, -49 - 29.918 / 60), LatLon.parse("w 49°29.918' s 19°24.788'"));
     219        assertEquals(new LatLon(49 + 29. / 60 + 04. / 3600, 19 + 24. / 60 + 43. / 3600), LatLon.parse("N 49°29'04\" E 19°24'43\""));
     220        assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918 N, 19.24788 E"));
     221        assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918 n, 19.24788 e"));
     222        assertEquals(new LatLon(49 + 29. / 60 + 21. / 3600, 19 + 24. / 60 + 38. / 3600), LatLon.parse("49°29'21\" N 19°24'38\" E"));
     223        assertEquals(new LatLon(49 + 29. / 60 + 51. / 3600, 19 + 24. / 60 + 18. / 3600), LatLon.parse("49 29 51, 19 24 18"));
     224        assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLon.parse("49 29, 19 24"));
     225        assertEquals(new LatLon(19 + 24. / 60, 49 + 29. / 60), LatLon.parse("E 49 29, N 19 24"));
     226        assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLon.parse("49° 29; 19° 24"));
     227        assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLon.parse("49° 29; 19° 24"));
     228        assertEquals(new LatLon(49 + 29. / 60, -19 - 24. / 60), LatLon.parse("N 49° 29, W 19° 24"));
     229        assertEquals(new LatLon(-49 - 29.5 / 60, 19 + 24.6 / 60), LatLon.parse("49° 29.5 S, 19° 24.6 E"));
     230        assertEquals(new LatLon(49 + 29.918 / 60, 19 + 15.88 / 60), LatLon.parse("N 49 29.918 E 19 15.88"));
     231        assertEquals(new LatLon(49 + 29.4 / 60, 19 + 24.5 / 60), LatLon.parse("49 29.4 19 24.5"));
     232        assertEquals(new LatLon(-49 - 29.4 / 60, 19 + 24.5 / 60), LatLon.parse("-49 29.4 N -19 24.5 W"));
     233    }
     234
     235    /**
     236     * Unit test of {@link LatLon#parse} method - invalid case 1.
     237     */
     238    @Test(expected = IllegalArgumentException.class)
     239    public void testParseInvalid1() {
     240        LatLon.parse("48°45'S 23°30'S");
     241    }
     242
     243    /**
     244     * Unit test of {@link LatLon#parse} method - invalid case 2.
     245     */
     246    @Test(expected = IllegalArgumentException.class)
     247    public void testParseInvalid2() {
     248        LatLon.parse("47°45'N 24°00'S");
     249    }
    206250}
Note: See TracChangeset for help on using the changeset viewer.