/** This method performs format conversions with string constructors in degrees and dms */ public void testRandomEquals() { for (int i = 0; i < 1000; i++) { Geodetic3DPoint a1 = randomGeoPoint(r); Geodetic3DPoint a2 = new Geodetic3DPoint(a1.getLongitude(), a1.getLatitude(), a1.getElevation()); // note by making equals() work in round off errors (such as in this case) using // Angle.equals() vs phi1=phi2 && lamb1==lamb2 // but break contract in hashCode such that a.equals(b) -> true but hashCode(a) may not equal // hashCode(b) assertEquals(a1, a2); assertEquals(a1.hashCode(), a2.hashCode()); // for symmetric tests to work elevation must be non-zero final double elevation = a1.getElevation(); if (elevation == 0.0 || Math.abs(elevation) < 1e-8) a1.setElevation(1234.5); // test symmetric equals tests a.equals(b) -> b.equals(a) Geodetic2DPoint pt2 = new Geodetic2DPoint(a1.getLongitude(), a1.getLatitude()); assertFalse(pt2.equals(a1)); assertFalse(a1.equals(pt2)); a1.setElevation(0); assertEquals(pt2, a1); // pt2.equals(al) -> a1.equals(pt2) assertEquals(a1, pt2); } }