Changeset 19089 in josm for trunk/test


Ignore:
Timestamp:
2024-05-30T23:44:58+02:00 (6 months ago)
Author:
stoecker
Message:

see #23621 - add unit conversion for length values

File:
1 edited

Legend:

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

    r19056 r19089  
    552552        assertEquals(-1.0, Utils.getStandardDeviation(new double[]{0}));
    553553    }
     554
     555    /**
     556     * Test of {@link Utils#unitToMeter(String)}
     557     */
     558    @Test
     559    void testUnitToMeter() {
     560        assertEquals(1.2, Utils.unitToMeter("1.2"));
     561        assertEquals(1.3, Utils.unitToMeter("  1,3 m "));
     562        assertEquals(1.4, Utils.unitToMeter("1.4m"));
     563        assertEquals(1.5, Utils.unitToMeter("150cm"));
     564        assertEquals(1.6, Utils.unitToMeter("1600.0mm"));
     565        assertEquals(3.048, Utils.unitToMeter("10ft"));
     566        assertEquals(6.096, Utils.unitToMeter("20'"));
     567        assertEquals(2.54, Utils.unitToMeter("100in"));
     568        assertEquals(5.08, Utils.unitToMeter("200\""));
     569        assertEquals(3.0734, Utils.unitToMeter("10ft1in"));
     570        assertEquals(6.1468, Utils.unitToMeter("20'2\""));
     571        assertThrows(IllegalArgumentException.class, () -> Utils.unitToMeter("Hallo"));
     572    }
    554573}
Note: See TracChangeset for help on using the changeset viewer.