Changeset 18494 in josm for trunk/test/unit


Ignore:
Timestamp:
2022-06-15T19:27:05+02:00 (3 years ago)
Author:
taylor.smock
Message:

Fix #22115: Extract methods from LatLon into ILatLon where they are generally applicable

This also removes calls to Node#getCoor where possible, which reduces
the number of memory allocations in SearchCompiler#match, and overall
allocations due to Node#getCoor

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCacheManagerTest.java

    r18037 r18494  
    99import java.util.logging.Logger;
    1010
    11 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    12 
    13 import net.trajano.commons.testing.UtilityClassTestUtil;
    1411import org.apache.commons.jcs3.access.CacheAccess;
    1512import org.apache.commons.jcs3.auxiliary.disk.block.BlockDiskCacheAttributes;
    1613import org.junit.jupiter.api.Test;
    1714import org.junit.jupiter.api.Timeout;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     16
     17import net.trajano.commons.testing.UtilityClassTestUtil;
    1818
    1919/**
     
    5959            CacheAccess<Object, Object> cache = JCSCacheManager.getCache("testUseBigDiskFile", 1, 100, "foobar");
    6060            assertEquals(10*1024,
    61                     ((BlockDiskCacheAttributes) cache.getCacheControl().getAuxCaches()[0].getAuxiliaryCacheAttributes()).getMaxKeySize(),
     61                    ((BlockDiskCacheAttributes) cache.getCacheControl().getAuxCacheList().get(0).getAuxiliaryCacheAttributes()).getMaxKeySize(),
    6262                    "BlockDiskCache use file size to calculate its size");
    6363        }
  • trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java

    r17275 r18494  
    170170    @Test
    171171    void testBearing() {
    172         LatLon c = new LatLon(47.000000, 19.000000);
    173         LatLon e = new LatLon(47.000000, 19.000001);
    174         LatLon n = new LatLon(47.000001, 19.000000);
     172        ILatLon c = new LatLon(47.000000, 19.000000);
     173        ILatLon e = new LatLon(47.000000, 19.000001);
     174        ILatLon n = new LatLon(47.000001, 19.000000);
    175175        assertEquals(0, Math.toDegrees(c.bearing(n)), EPSILON);
    176176        assertEquals(90, Math.toDegrees(c.bearing(e)), EPSILON);
  • trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java

    r18287 r18494  
    2626import org.openstreetmap.josm.data.DataSource;
    2727import org.openstreetmap.josm.data.coor.EastNorth;
     28import org.openstreetmap.josm.data.coor.ILatLon;
    2829import org.openstreetmap.josm.data.coor.LatLon;
    2930import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeEvent;
     
    322323        data.addTrack(track1);
    323324        data.addTrack(track2);
    324         assertEquals(3 * new LatLon(0, 0).greatCircleDistance(new LatLon(1, 1)), data.length(), 1);
     325        assertEquals(3 * new LatLon(0, 0).greatCircleDistance((ILatLon) new LatLon(1, 1)), data.length(), 1);
    325326    }
    326327
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java

    r17275 r18494  
    1414import org.openstreetmap.josm.data.Bounds;
    1515import org.openstreetmap.josm.data.coor.EastNorth;
     16import org.openstreetmap.josm.data.coor.ILatLon;
    1617import org.openstreetmap.josm.data.coor.LatLon;
    1718
     
    171172            LatLon ll2 = p.eastNorth2latlon(en);
    172173            assertTrue(ll2.isValid(), p.toCode() + " at " + ll1 + " is " + ll2);
    173             double dist = ll1.greatCircleDistance(ll2);
     174            double dist = ll1.greatCircleDistance((ILatLon) ll2);
    174175            if (dist > eps) {
    175176                error2 = true;
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/RenderingCLIAreaTest.java

    r17276 r18494  
    1616import org.junit.jupiter.params.provider.MethodSource;
    1717import org.openstreetmap.josm.data.Bounds;
     18import org.openstreetmap.josm.data.coor.ILatLon;
    1819import org.openstreetmap.josm.data.coor.LatLon;
    1920import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    6465                CoreMatchers.is(bFeldberg)});
    6566
    66         LatLon aFeldberg = bFeldberg.getMin();
    67         LatLon aFeldberg200mRight = new LatLon(aFeldberg.lat(), 13.433008399004041);
    68         LatLon aFeldberg150mUp = new LatLon(53.33134745249311, aFeldberg.lon());
     67        ILatLon aFeldberg = bFeldberg.getMin();
     68        ILatLon aFeldberg200mRight = new LatLon(aFeldberg.lat(), 13.433008399004041);
     69        ILatLon aFeldberg150mUp = new LatLon(53.33134745249311, aFeldberg.lon());
    6970        assertThat(aFeldberg.greatCircleDistance(aFeldberg200mRight), isFP(200.0, 0.01));
    7071        assertThat(aFeldberg.greatCircleDistance(aFeldberg150mUp), isFP(150.0, 0.01));
     
    142143    }
    143144
    144     private static String param(LatLon ll) {
     145    private static String param(ILatLon ll) {
    145146        return ll.lon() + "," + ll.lat();
    146147    }
  • trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    r18109 r18494  
    2424import org.openstreetmap.josm.TestUtils;
    2525import org.openstreetmap.josm.data.coor.EastNorth;
     26import org.openstreetmap.josm.data.coor.ILatLon;
    2627import org.openstreetmap.josm.data.coor.LatLon;
    2728import org.openstreetmap.josm.data.osm.DataSet;
     
    503504        ProjectionRegistry.setProjection(projection);
    504505        final double offset = offsetInMeters / projection.getMetersPerUnit();
    505         final LatLon original = new LatLon(lat, lon);
    506 
    507         final LatLon actual = (LatLon) Geometry.getLatLonFrom(original, Math.toRadians(angle), offset);
     506        final ILatLon original = new LatLon(lat, lon);
     507
     508        final ILatLon actual = Geometry.getLatLonFrom(original, Math.toRadians(angle), offset);
    508509        // Due to degree -> radian -> degree conversion, there is a limit to how precise it can be
    509510        assertEquals(offsetInMeters, original.greatCircleDistance(actual), 0.000_000_1);
Note: See TracChangeset for help on using the changeset viewer.