Changeset 8759 in josm for trunk/test


Ignore:
Timestamp:
2015-09-14T20:57:25+02:00 (4 years ago)
Author:
simon04
Message:

fix #11849 - Add NavigationComponentTest (patch by michael2402, modified)

Location:
trunk/test/unit/org
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/CustomMatchers.java

    r8514 r8759  
    22package org;
    33
     4import java.awt.geom.Point2D;
    45import java.util.Collection;
    56
     7import org.hamcrest.CustomTypeSafeMatcher;
    68import org.hamcrest.Description;
    79import org.hamcrest.Matcher;
    810import org.hamcrest.TypeSafeMatcher;
    911import org.junit.Ignore;
     12import org.openstreetmap.josm.data.coor.EastNorth;
     13import org.openstreetmap.josm.data.coor.LatLon;
    1014import org.openstreetmap.josm.tools.Predicate;
    1115
     
    6064    }
    6165
     66    public static Matcher<? super Point2D> is(final Point2D expected) {
     67        return new CustomTypeSafeMatcher<Point2D>("the same Point2D") {
     68            @Override
     69            protected boolean matchesSafely(Point2D actual) {
     70                return expected.distance(actual) <= 0.0000001;
     71            }
     72        };
     73    }
     74
     75    public static Matcher<? super LatLon> is(final LatLon expected) {
     76        return new CustomTypeSafeMatcher<LatLon>("the same LatLon") {
     77            @Override
     78            protected boolean matchesSafely(LatLon actual) {
     79                return Math.abs(expected.getX() - actual.getX()) <= LatLon.MAX_SERVER_PRECISION
     80                        && Math.abs(expected.getY() - actual.getY()) <= LatLon.MAX_SERVER_PRECISION;
     81            }
     82        };
     83    }
     84
     85    public static Matcher<? super EastNorth> is(final EastNorth expected) {
     86        return new CustomTypeSafeMatcher<EastNorth>("the same EastNorth") {
     87            @Override
     88            protected boolean matchesSafely(EastNorth actual) {
     89                return Math.abs(expected.getX() - actual.getX()) <= LatLon.MAX_SERVER_PRECISION
     90                        && Math.abs(expected.getY() - actual.getY()) <= LatLon.MAX_SERVER_PRECISION;
     91            }
     92        };
     93    }
     94
    6295}
Note: See TracChangeset for help on using the changeset viewer.