예제 #1
0
  public void testEquals() {
    assertTrue(hm1.equals(hm1));
    assertTrue(hm1.equals(hm2));
    assertTrue(!hm1.equals(hm3));
    assertTrue(!hm1.equals(hm4));

    assertTrue(hm2.equals(hm1));
    assertTrue(hm2.equals(hm2));
    assertTrue(!hm2.equals(hm3));
    assertTrue(!hm2.equals(hm4));

    assertTrue(!hm3.equals(hm1));
    assertTrue(!hm3.equals(hm2));
    assertTrue(hm3.equals(hm3));
    assertTrue(!hm3.equals(hm4));

    assertTrue(!hm4.equals(hm1));
    assertTrue(!hm4.equals(hm2));
    assertTrue(!hm4.equals(hm3));
    assertTrue(hm4.equals(hm4));
  }
예제 #2
0
  public void testHashCode() {
    assertTrue(hm1.hashCode() == hm1.hashCode());
    assertTrue(hm1.hashCode() == hm2.hashCode());
    assertTrue(hm1.hashCode() != hm3.hashCode());
    assertTrue(hm1.hashCode() != hm4.hashCode());

    assertTrue(hm2.hashCode() == hm1.hashCode());
    assertTrue(hm2.hashCode() == hm2.hashCode());
    assertTrue(hm2.hashCode() != hm3.hashCode());
    assertTrue(hm2.hashCode() != hm4.hashCode());

    assertTrue(hm3.hashCode() != hm1.hashCode());
    assertTrue(hm3.hashCode() != hm2.hashCode());
    assertTrue(hm3.hashCode() == hm3.hashCode());
    assertTrue(hm3.hashCode() != hm4.hashCode());

    assertTrue(hm4.hashCode() != hm1.hashCode());
    assertTrue(hm4.hashCode() != hm2.hashCode());
    assertTrue(hm4.hashCode() != hm3.hashCode());
    assertTrue(hm4.hashCode() == hm4.hashCode());
  }