Changeset 18777 in josm for trunk/test/unit/org
- Timestamp:
- 2023-07-20T22:21:29+02:00 (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java
r18341 r18777 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 7 import java.awt.Polygon; 8 import java.util.ArrayList; 7 9 import java.util.Arrays; 10 import java.util.Objects; 8 11 12 import nl.jqno.equalsverifier.EqualsVerifier; 9 13 import org.junit.jupiter.api.Test; 10 14 import org.junit.jupiter.params.ParameterizedTest; … … 53 57 () -> assertEquals(coordinate, shape.getPoints().get(1).getLat())); 54 58 } 59 60 /** 61 * Ensure that the hashcode is semantically the same as what it previously was 62 */ 63 @ParameterizedTest 64 @ValueSource(strings = {"47.1 11.1 47.2 11.2 47.3 11.3", "-47.1 -11.1 -47.2 -11.2 -47.3 -11.3"}) 65 void testHashCode(String shapeString) { 66 final Shape shape = new Shape(shapeString, " "); 67 assertEquals(Objects.hash(shape.getPoints()), shape.hashCode(), 68 "The hashcode for shape should be the same as that for the point list (specific coord list)"); 69 assertEquals(Objects.hash(new ArrayList<>(shape.getPoints())), shape.hashCode(), 70 "The hashcode for shape should be the same as that for the point list (non-specific)"); 71 } 72 73 @Test 74 void testEqualsHashCodeContract() { 75 EqualsVerifier.simple().forClass(Shape.class) 76 .withNonnullFields("coords") 77 .withPrefabValues(Polygon.class, new Polygon(), new Polygon(new int[] {1, 2, 3}, new int[]{4, 5, 6}, 3)) 78 .verify(); 79 } 55 80 }
Note:
See TracChangeset
for help on using the changeset viewer.