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

add more non-regression NMEA unit tests

Location:
trunk/src/org/openstreetmap/josm/data/gpx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r10680 r10906  
    482482        return DataSource.getDataSourceBounds(dataSources);
    483483    }
     484
     485    @Override
     486    public int hashCode() {
     487        final int prime = 31;
     488        int result = 1;
     489        result = prime * result + ((dataSources == null) ? 0 : dataSources.hashCode());
     490        result = prime * result + ((routes == null) ? 0 : routes.hashCode());
     491        result = prime * result + ((tracks == null) ? 0 : tracks.hashCode());
     492        result = prime * result + ((waypoints == null) ? 0 : waypoints.hashCode());
     493        return result;
     494    }
     495
     496    @Override
     497    public boolean equals(Object obj) {
     498        if (this == obj)
     499            return true;
     500        if (obj == null)
     501            return false;
     502        if (getClass() != obj.getClass())
     503            return false;
     504        GpxData other = (GpxData) obj;
     505        if (dataSources == null) {
     506            if (other.dataSources != null)
     507                return false;
     508        } else if (!dataSources.equals(other.dataSources))
     509            return false;
     510        if (routes == null) {
     511            if (other.routes != null)
     512                return false;
     513        } else if (!routes.equals(other.routes))
     514            return false;
     515        if (tracks == null) {
     516            if (other.tracks != null)
     517                return false;
     518        } else if (!tracks.equals(other.tracks))
     519            return false;
     520        if (waypoints == null) {
     521            if (other.waypoints != null)
     522                return false;
     523        } else if (!waypoints.equals(other.waypoints))
     524            return false;
     525        return true;
     526    }
    484527}
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxRoute.java

    r7005 r10906  
    77public class GpxRoute extends WithAttributes {
    88    public Collection<WayPoint> routePoints = new LinkedList<>();
     9
     10    @Override
     11    public int hashCode() {
     12        return 31 * super.hashCode() + ((routePoints == null) ? 0 : routePoints.hashCode());
     13    }
     14
     15    @Override
     16    public boolean equals(Object obj) {
     17        if (this == obj)
     18            return true;
     19        if (!super.equals(obj))
     20            return false;
     21        if (getClass() != obj.getClass())
     22            return false;
     23        GpxRoute other = (GpxRoute) obj;
     24        if (routePoints == null) {
     25            if (other.routePoints != null)
     26                return false;
     27        } else if (!routePoints.equals(other.routePoints))
     28            return false;
     29        return true;
     30    }
    931}
  • trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java

    r9949 r10906  
    1717public class ImmutableGpxTrack extends WithAttributes implements GpxTrack {
    1818
    19     private final Collection<GpxTrackSegment> segments;
     19    private final List<GpxTrackSegment> segments;
    2020    private final double length;
    2121    private final Bounds bounds;
     
    3434        }
    3535        this.attr = Collections.unmodifiableMap(new HashMap<>(attributes));
    36         this.segments = Collections.unmodifiableCollection(newSegments);
     36        this.segments = Collections.unmodifiableList(newSegments);
    3737        this.length = calculateLength();
    3838        this.bounds = calculateBounds();
     
    9090        return 0;
    9191    }
     92
     93    @Override
     94    public int hashCode() {
     95        return 31 * super.hashCode() + ((segments == null) ? 0 : segments.hashCode());
     96    }
     97
     98    @Override
     99    public boolean equals(Object obj) {
     100        if (this == obj)
     101            return true;
     102        if (!super.equals(obj))
     103            return false;
     104        if (getClass() != obj.getClass())
     105            return false;
     106        ImmutableGpxTrack other = (ImmutableGpxTrack) obj;
     107        if (segments == null) {
     108            if (other.segments != null)
     109                return false;
     110        } else if (!segments.equals(other.segments))
     111            return false;
     112        return true;
     113    }
    92114}
  • trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java

    r8510 r10906  
    55import java.util.Collection;
    66import java.util.Collections;
     7import java.util.List;
    78
    89import org.openstreetmap.josm.data.Bounds;
     
    1011public class ImmutableGpxTrackSegment implements GpxTrackSegment {
    1112
    12     private final Collection<WayPoint> wayPoints;
     13    private final List<WayPoint> wayPoints;
    1314    private final Bounds bounds;
    1415    private final double length;
    1516
     17    /**
     18     * Constructs a new {@code ImmutableGpxTrackSegment}.
     19     * @param wayPoints list of waypoints
     20     */
    1621    public ImmutableGpxTrackSegment(Collection<WayPoint> wayPoints) {
    17         this.wayPoints = Collections.unmodifiableCollection(new ArrayList<>(wayPoints));
     22        this.wayPoints = Collections.unmodifiableList(new ArrayList<>(wayPoints));
    1823        this.bounds = calculateBounds();
    1924        this.length = calculateLength();
     
    7075    }
    7176
     77    @Override
     78    public int hashCode() {
     79        return 31 + ((wayPoints == null) ? 0 : wayPoints.hashCode());
     80    }
     81
     82    @Override
     83    public boolean equals(Object obj) {
     84        if (this == obj)
     85            return true;
     86        if (obj == null)
     87            return false;
     88        if (getClass() != obj.getClass())
     89            return false;
     90        ImmutableGpxTrackSegment other = (ImmutableGpxTrackSegment) obj;
     91        if (wayPoints == null) {
     92            if (other.wayPoints != null)
     93                return false;
     94        } else if (!wayPoints.equals(other.wayPoints))
     95            return false;
     96        return true;
     97    }
    7298}
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r10467 r10906  
    159159        return new ArrayList<>(attr.keySet());
    160160    }
     161
     162    @Override
     163    public int hashCode() {
     164        final int prime = 31;
     165        int result = super.hashCode();
     166        long temp = Double.doubleToLongBits(lat);
     167        result = prime * result + (int) (temp ^ (temp >>> 32));
     168        temp = Double.doubleToLongBits(lon);
     169        result = prime * result + (int) (temp ^ (temp >>> 32));
     170        temp = Double.doubleToLongBits(time);
     171        result = prime * result + (int) (temp ^ (temp >>> 32));
     172        return result;
     173    }
     174
     175    @Override
     176    public boolean equals(Object obj) {
     177        if (this == obj)
     178            return true;
     179        if (!super.equals(obj))
     180            return false;
     181        if (getClass() != obj.getClass())
     182            return false;
     183        WayPoint other = (WayPoint) obj;
     184        if (Double.doubleToLongBits(lat) != Double.doubleToLongBits(other.lat))
     185            return false;
     186        if (Double.doubleToLongBits(lon) != Double.doubleToLongBits(other.lon))
     187            return false;
     188        if (Double.doubleToLongBits(time) != Double.doubleToLongBits(other.time))
     189            return false;
     190        return true;
     191    }
    161192}
  • trunk/src/org/openstreetmap/josm/data/gpx/WithAttributes.java

    r8510 r10906  
    9090        ext.put(key, value);
    9191    }
     92
     93    @Override
     94    public int hashCode() {
     95        return 31 + ((attr == null) ? 0 : attr.hashCode());
     96    }
     97
     98    @Override
     99    public boolean equals(Object obj) {
     100        if (this == obj)
     101            return true;
     102        if (obj == null)
     103            return false;
     104        if (getClass() != obj.getClass())
     105            return false;
     106        WithAttributes other = (WithAttributes) obj;
     107        if (attr == null) {
     108            if (other.attr != null)
     109                return false;
     110        } else if (!attr.equals(other.attr))
     111            return false;
     112        return true;
     113    }
    92114}
Note: See TracChangeset for help on using the changeset viewer.