Changeset 15925 in josm


Ignore:
Timestamp:
2020-02-24T21:48:16+01:00 (5 weeks ago)
Author:
simon04
Message:

fix #18759 - AssertionError on invalid MapCSS zoom range

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r15920 r15925  
    725725
    726726        public static Range fromLevel(int a, int b) {
    727             if (a > b)
    728                 throw new AssertionError();
     727            // for input validation in Range constructor below
    729728            double lower = 0;
    730729            double upper = Double.POSITIVE_INFINITY;
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java

    r15735 r15925  
    44import static org.junit.Assert.assertEquals;
    55import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertNotNull;
    67import static org.junit.Assert.assertNull;
    78import static org.junit.Assert.assertTrue;
     
    626627        assertTrue(sheet.getErrors().toString(), sheet.getErrors().isEmpty());
    627628    }
     629
     630    /**
     631     * Test parsing zoom expressions
     632     * @throws ParseException if a parsing error occurs
     633     */
     634    @Test
     635    public void testZoom() throws ParseException {
     636        assertNotNull(getParser("|z12").zoom());
     637        assertNotNull(getParser("|z12-").zoom());
     638        assertNotNull(getParser("|z-12").zoom());
     639        assertNotNull(getParser("|z12-16").zoom());
     640    }
     641
     642    /**
     643     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/18759">Bug #18759</a>.
     644     * @throws ParseException if a parsing error occurs
     645     */
     646    @Test(expected = IllegalArgumentException.class)
     647    public void testZoomIAE() throws ParseException {
     648        assertNotNull(getParser("|z16-15").zoom());
     649    }
    628650}
Note: See TracChangeset for help on using the changeset viewer.