Ignore:
Timestamp:
2016-08-23T01:59:35+02:00 (8 years ago)
Author:
donvip
Message:

update unit test to JOSM 10876

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ElevationProfile/test/unit/org/openstreetmap/josm/plugins/elevation/tests/EleVertexTest.java

    r32775 r32868  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.elevation.tests;
     3
     4import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertNotNull;
     6import static org.junit.Assert.assertTrue;
    37
    48import java.awt.Color;
    59import java.util.List;
    610
    7 import org.openstreetmap.josm.Main;
    8 import org.openstreetmap.josm.data.Preferences;
     11import org.junit.Rule;
     12import org.junit.Test;
    913import org.openstreetmap.josm.data.coor.LatLon;
    1014import org.openstreetmap.josm.plugins.elevation.ColorMap;
    1115import org.openstreetmap.josm.plugins.elevation.grid.EleCoordinate;
    1216import org.openstreetmap.josm.plugins.elevation.grid.EleVertex;
     17import org.openstreetmap.josm.testutils.JOSMTestRules;
    1318
    14 import junit.framework.TestCase;
     19public class EleVertexTest {
    1520
    16 public class EleVertexTest extends TestCase {
     21    private static final double EPS = 1e-10;
    1722
    18     /**
    19      * Setup test.
    20      */
    21     @Override
    22     public void setUp() {
    23         Main.pref = new Preferences();
    24     }
     23    @Rule
     24    public JOSMTestRules rules = new JOSMTestRules().preferences();
    2525
     26    @Test
    2627    public void testDivide() {
    2728        EleCoordinate p1 = new EleCoordinate(30.0, 30.0, 100.0);
     
    3637        // 1st vertex (p1, p2, pN  105m)
    3738        EleVertex v1 = list.get(0);
    38         assertEquals(325 / 3D, v1.getEle());
     39        assertEquals(325 / 3D, v1.getEle(), EPS);
    3940        assertCoorEq(v1, 30D, 30D, 0);
    4041        assertCoorEq(v1, 30D, 35D, 1);
     
    4445        EleVertex v2 = list.get(1);
    4546
    46         assertEquals(335/3D, v2.getEle());
     47        assertEquals(335/3D, v2.getEle(), EPS);
    4748        assertCoorEq(v2, 40D, 35D, 0);
    4849        assertCoorEq(v2, 30D, 35D, 1);
     
    5051    }
    5152
     53    @Test
    5254    public void testSimpleRecurse() {
    5355        EleCoordinate c1 = new EleCoordinate(new LatLon(50.8328, 8.1337), 300);
     
    8991    }*/
    9092
     93    @Test
    9194    public void testColorMap() {
    9295        ColorMap testMap = ColorMap.create("Test", new Color[]{Color.white, Color.black}, new int[]{0, 1000});
     
    111114
    112115    private void assertCoorEq(EleVertex v1, double x, double y, int n) {
    113         assertEquals(x, v1.get(n).getX());
    114         assertEquals(y, v1.get(n).getY());
     116        assertEquals(x, v1.get(n).getX(), EPS);
     117        assertEquals(y, v1.get(n).getY(), EPS);
    115118    }
    116119}
Note: See TracChangeset for help on using the changeset viewer.