Point { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj instanceof Point<?>) { final Point<?> a = (Point<?>) obj; return NUMBER_COMPARATOR.compare(x, a.x) == 0 && NUMBER_COMPARATOR.compare(y, a.y) == 0; } else { return false; } } protected  Point(Point<T> pt); protected  Point(T x, T y, T z); @Override boolean equals(Object obj); void set(Point<T> other); void setX(T x); void setY(T y); void setZ(T z); @Override String toString();  }
@Test public void doublePointEqualsAndHashCodeItselfTest() { DoublePoint dp = new DoublePoint(1.23, 5.34, 234.23); Assert.assertTrue(dp.equals(dp)); Assert.assertEquals(dp.hashCode(), dp.hashCode()); }
@Test public void doublePointEqualsAndHashCodeToAnotherEqualPointTest() { DoublePoint first = new DoublePoint(1.23, 5.34, 234.23); DoublePoint second = new DoublePoint(1.23, 5.34, 13); Assert.assertTrue(first.equals(second)); Assert.assertTrue(second.equals(first)); Assert.assertNotEquals(first.hashCode(), second.hashCode()); }
@Test public void doublePointEqualsAndHashCodeToAnotherNotEqualPointTest() { DoublePoint first = new DoublePoint(1.23, 5.34, 234.23); DoublePoint second = new DoublePoint(0, 5.34, 234.23); Assert.assertFalse(first.equals(second)); Assert.assertFalse(second.equals(first)); Assert.assertNotEquals(first.hashCode(), second.hashCode()); second = new DoublePoint(1.23, 0, 234.23); Assert.assertFalse(first.equals(second)); Assert.assertFalse(second.equals(first)); Assert.assertNotEquals(first.hashCode(), second.hashCode()); }
@Test public void doublePointEqualsToNullTest() { DoublePoint dp = new DoublePoint(1.23, 5.34, 234.23); Assert.assertFalse(dp.equals(null)); }
@Test public void doublePointEqualsToAnotherClassTest() { DoublePoint dp = new DoublePoint(1.23, 5.34, 234.23); Assert.assertFalse(dp.equals(new String())); }
@Test public void longPointEqualsAndHashCodeItselfTest() { LongPoint lp = new LongPoint(1, 5, 234); Assert.assertTrue(lp.equals(lp)); Assert.assertEquals(lp.hashCode(), lp.hashCode()); }
@Test public void longPointEqualsAndHashCodeToAnotherEqualPointTest() { LongPoint first = new LongPoint(1, 5, 234); LongPoint second = new LongPoint(1, 5, 13); Assert.assertTrue(first.equals(second)); Assert.assertTrue(second.equals(first)); Assert.assertNotEquals(first.hashCode(), second.hashCode()); }
@Test public void longPointEqualsAndHashCodeToAnotherNotEqualPointTest() { LongPoint first = new LongPoint(1, 5, 234); LongPoint second = new LongPoint(0, 5, 234); Assert.assertFalse(first.equals(second)); Assert.assertFalse(second.equals(first)); Assert.assertNotEquals(first.hashCode(), second.hashCode()); second = new LongPoint(1, 0, 234); Assert.assertFalse(first.equals(second)); Assert.assertFalse(second.equals(first)); Assert.assertNotEquals(first.hashCode(), second.hashCode()); }
@Test public void longPointEqualsToNullTest() { LongPoint lp = new LongPoint(1, 5, 234); Assert.assertFalse(lp.equals(null)); }
@Test public void longPointEqualsToAnotherClassTest() { LongPoint lp = new LongPoint(1, 5, 234); Assert.assertFalse(lp.equals(new String())); }