Changeset 17752 in josm for trunk/test


Ignore:
Timestamp:
2021-04-12T00:16:06+02:00 (4 years ago)
Author:
simon04
Message:

see #20745 - Avoid heap allocations due to BBox in IPrimitive.getBBox

Cache and return an immutable bounding box.

37.75% in MapCSSTagCheckerPerformanceTest#testCity amount to BBox::new via IPrimitive.getBBox

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java

    r17275 r17752  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    78
     
    3435    void testEqualsContract() {
    3536        TestUtils.assumeWorkingEqualsVerifier();
    36         EqualsVerifier.forClass(BBox.class).usingGetClass()
     37        EqualsVerifier.forClass(BBox.class)
    3738            .suppress(Warning.NONFINAL_FIELDS)
    3839            .verify();
     40    }
     41
     42    /**
     43     * Unit test of {@link BBox#equals} method.
     44     */
     45    @Test
     46    void testEquals() {
     47        BBox box = new BBox(1, 2, 3, 4);
     48        assertEquals(box, box);
     49        assertEquals(box, new BBox(box));
     50        assertEquals(box, box.toImmutable());
     51    }
     52
     53    /**
     54     * Unit test of {@link BBox#toImmutable} method.
     55     */
     56    @Test
     57    void testToImmutable() {
     58        assertThrows(UnsupportedOperationException.class, () -> new BBox(1, 2, 3, 4).toImmutable().add(5, 6));
    3959    }
    4060
Note: See TracChangeset for help on using the changeset viewer.