コード例 #1
0
  @Test
  public void testEqualsAndHashCode() {

    ExportedVariable var1 = new ExportedVariable("test", "value 1");
    ExportedVariable var2 = new ExportedVariable("test", "value 2");

    HashSet<ExportedVariable> set = new HashSet<>(2);
    set.add(var1);
    set.add(var2);
    Assert.assertEquals(1, set.size());

    Assert.assertEquals(var1, var2);
    Assert.assertFalse(var1.equals(new Object()));
    Assert.assertFalse(var1.equals(new ExportedVariable("test2", "value 1")));

    Assert.assertTrue(new ExportedVariable().hashCode() > 0);
  }
コード例 #2
0
 @Test
 public void testToString() {
   ExportedVariable var = new ExportedVariable("test", null);
   Assert.assertEquals("test", var.toString());
 }