Пример #1
0
  public void testCountEqual() {
    Geocache[] pts =
        new Geocache[] {
          new Geocache(1, 2), new Geocache(3, 4), new Geocache(50, 60), new Geocache(1, 2)
        };
    Geocache origin = new Geocache(0, 0);
    Geocache p12 = new Geocache(1, 2);
    assertTrue(p12.equals(pts[0]));
    assertFalse(p12.equals(origin));

    assertEquals(0, StaticMethodsAreEasy.countEqual(pts, origin));
    assertEquals(2, StaticMethodsAreEasy.countEqual(pts, p12));
  }
Пример #2
0
  public static void testEquality() {
    final Geocache one = new Geocache();
    final Geocache two = new Geocache();

    // identity
    assertThat(one.equals(one)).isTrue();

    // different objects without geocode shall not be equal
    assertThat(one.equals(two)).isFalse();

    one.setGeocode("geocode");
    two.setGeocode("geocode");

    // different objects with same geocode shall be equal
    assertThat(one.equals(two)).isTrue();
  }