Changeset 10906 in josm for trunk/test


Ignore:
Timestamp:
2016-08-27T17:23:05+02:00 (3 years ago)
Author:
Don-vip
Message:

add more non-regression NMEA unit tests

Location:
trunk/test
Files:
16 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/NmeaReaderTest.java

    r10758 r10906  
    55
    66import java.io.FileInputStream;
     7import java.io.IOException;
    78import java.text.SimpleDateFormat;
    89import java.util.ArrayList;
     
    1213import org.junit.Rule;
    1314import org.junit.Test;
     15import org.openstreetmap.josm.TestUtils;
    1416import org.openstreetmap.josm.data.coor.LatLon;
    1517import org.openstreetmap.josm.data.gpx.GpxConstants;
     18import org.openstreetmap.josm.data.gpx.GpxData;
     19import org.openstreetmap.josm.data.gpx.GpxTrack;
     20import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
    1621import org.openstreetmap.josm.data.gpx.WayPoint;
    17 import org.openstreetmap.josm.io.NmeaReader.NMEA_TYPE;
    1822import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.xml.sax.SAXException;
    1924
    2025import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    21 import nl.jqno.equalsverifier.EqualsVerifier;
    2226
    2327/**
     
    3135    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3236    public JOSMTestRules test = new JOSMTestRules();
    33 
    34     /**
    35      * Unit test of methods {@link NMEA_TYPE#equals} and {@link NMEA_TYPE#hashCode}.
    36      */
    37     @Test
    38     public void testEqualsContract() {
    39         EqualsVerifier.forClass(NMEA_TYPE.class).verify();
    40     }
    4137
    4238    /**
     
    6965        assertEquals(null, wayPoints.get(0).get(GpxConstants.PT_PDOP));
    7066    }
     67
     68    private static void compareWithReference(int ticket, String filename, int numCoor) throws IOException, SAXException {
     69        GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(ticket, filename+".gpx"));
     70        NmeaReader in = new NmeaReader(new FileInputStream(TestUtils.getRegressionDataFile(ticket, filename+".nmea")));
     71        assertEquals(numCoor, in.getNumberOfCoordinates());
     72        assertEquals(0, in.getParserMalformed());
     73        assertEquals(in.data.dataSources, gpx.dataSources);
     74        assertEquals(1, gpx.tracks.size());
     75        assertEquals(1, in.data.tracks.size());
     76        GpxTrack gpxTrack = gpx.tracks.iterator().next();
     77        GpxTrack nmeaTrack = in.data.tracks.iterator().next();
     78        assertEquals(gpxTrack.getBounds(), nmeaTrack.getBounds());
     79        assertEquals(1, gpxTrack.getSegments().size());
     80        assertEquals(1, nmeaTrack.getSegments().size());
     81        GpxTrackSegment gpxSeg = gpxTrack.getSegments().iterator().next();
     82        GpxTrackSegment nmeaSeg = nmeaTrack.getSegments().iterator().next();
     83        assertEquals(gpxSeg.getBounds(), nmeaSeg.getBounds());
     84        assertEquals(numCoor, gpxSeg.getWayPoints().size());
     85        assertEquals(numCoor, nmeaSeg.getWayPoints().size());
     86        WayPoint gpxWpt = gpxSeg.getWayPoints().iterator().next();
     87        WayPoint nmeaWpt = nmeaSeg.getWayPoints().iterator().next();
     88        assertEquals(gpxWpt.getCoor().getRoundedToOsmPrecision(), nmeaWpt.getCoor().getRoundedToOsmPrecision());
     89    }
     90
     91    /**
     92     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/1433">Bug #1433</a>.
     93     * @throws Exception if an error occurs
     94     */
     95    @Test
     96    public void testTicket1433() throws Exception {
     97        compareWithReference(1433, "2008-08-14-16-04-58", 1241);
     98    }
     99
     100    /**
     101     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/1853">Bug #1853</a>.
     102     * @throws Exception if an error occurs
     103     */
     104    @Test
     105    public void testTicket1853() throws Exception {
     106        compareWithReference(1853, "PosData-20081216-115434", 1285);
     107    }
     108
     109    /**
     110     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/2147">Bug #2147</a>.
     111     * @throws Exception if an error occurs
     112     */
     113    @Test
     114    public void testTicket2147() throws Exception {
     115        compareWithReference(2147, "WG20080203171807.log", 487);
     116    }
    71117}
Note: See TracChangeset for help on using the changeset viewer.