Changeset 8759 in josm
- Timestamp:
- 2015-09-14T20:57:25+02:00 (9 years ago)
- Location:
- trunk/test/unit/org
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/CustomMatchers.java
r8514 r8759 2 2 package org; 3 3 4 import java.awt.geom.Point2D; 4 5 import java.util.Collection; 5 6 7 import org.hamcrest.CustomTypeSafeMatcher; 6 8 import org.hamcrest.Description; 7 9 import org.hamcrest.Matcher; 8 10 import org.hamcrest.TypeSafeMatcher; 9 11 import org.junit.Ignore; 12 import org.openstreetmap.josm.data.coor.EastNorth; 13 import org.openstreetmap.josm.data.coor.LatLon; 10 14 import org.openstreetmap.josm.tools.Predicate; 11 15 … … 60 64 } 61 65 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 62 95 }
Note:
See TracChangeset
for help on using the changeset viewer.