Changeset 12422 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-06-22T01:07:31+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #14924 - fix NPE when reading NMEA files starting with a (0,0) coordinate followed by a VTG sentence

File:
1 edited

Legend:

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

    r12421 r12422  
    7676        assertEquals(numCoor, in.getNumberOfCoordinates());
    7777        assertEquals(0, in.getParserMalformed());
    78         assertEquals(in.data.dataSources, gpx.dataSources);
     78        assertEquals(gpx.dataSources, in.data.dataSources);
    7979        assertEquals(1, gpx.tracks.size());
    8080        assertEquals(1, in.data.tracks.size());
     
    8282        GpxTrack nmeaTrack = in.data.tracks.iterator().next();
    8383        assertEquals(gpxTrack.getBounds(), nmeaTrack.getBounds());
    84         assertEquals(1, gpxTrack.getSegments().size());
    85         assertEquals(1, nmeaTrack.getSegments().size());
    86         GpxTrackSegment gpxSeg = gpxTrack.getSegments().iterator().next();
    87         GpxTrackSegment nmeaSeg = nmeaTrack.getSegments().iterator().next();
    88         assertEquals(gpxSeg.getBounds(), nmeaSeg.getBounds());
    89         assertEquals(numCoor, gpxSeg.getWayPoints().size());
    90         assertEquals(numCoor, nmeaSeg.getWayPoints().size());
    91         WayPoint gpxWpt = gpxSeg.getWayPoints().iterator().next();
    92         WayPoint nmeaWpt = nmeaSeg.getWayPoints().iterator().next();
    93         assertEquals(gpxWpt.getCoor().getRoundedToOsmPrecision(), nmeaWpt.getCoor().getRoundedToOsmPrecision());
     84        int nTracks = gpxTrack.getSegments().size();
     85        assertEquals(nTracks, nmeaTrack.getSegments().size());
     86        if (nTracks > 0) {
     87            GpxTrackSegment gpxSeg = gpxTrack.getSegments().iterator().next();
     88            GpxTrackSegment nmeaSeg = nmeaTrack.getSegments().iterator().next();
     89            assertEquals(gpxSeg.getBounds(), nmeaSeg.getBounds());
     90            assertEquals(numCoor, gpxSeg.getWayPoints().size());
     91            assertEquals(numCoor, nmeaSeg.getWayPoints().size());
     92            WayPoint gpxWpt = gpxSeg.getWayPoints().iterator().next();
     93            WayPoint nmeaWpt = nmeaSeg.getWayPoints().iterator().next();
     94            assertEquals(gpxWpt.getCoor().getRoundedToOsmPrecision(), nmeaWpt.getCoor().getRoundedToOsmPrecision());
     95        }
    9496    }
    9597
     
    133135        compareWithReference(2147, "WG20080203171807.log", 487);
    134136    }
     137
     138    /**
     139     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14924">Bug #14924</a>.
     140     * @throws Exception if an error occurs
     141     */
     142    @Test
     143    public void testTicket14924() throws Exception {
     144        compareWithReference(14924, "input", 0);
     145    }
    135146}
Note: See TracChangeset for help on using the changeset viewer.