/** * The toString() for two equal values must be the same. For two non-equal values it must be * different. */ @Test public void testToString() { HeroStat heroStatA = HeroStat.valueOf(3, 9, 2); HeroStat heroStatB = HeroStat.valueOf(3, 9, 2); HeroStat heroStatC = HeroStat.valueOf(3, 9, 8); assertThat(heroStatA.toString(), is(heroStatB.toString())); assertThat(heroStatA.toString(), is(not(heroStatC.toString()))); }
/** * Tester for equals() and hashCode() methods of a class. Using guava's EqualsTester. * * @see http://static.javadoc.io/com.google.guava/guava-testlib/19.0/com/google/common/testing/ * EqualsTester.html */ @Test public void testEquals() { HeroStat heroStatA = HeroStat.valueOf(3, 9, 2); HeroStat heroStatB = HeroStat.valueOf(3, 9, 2); new EqualsTester().addEqualityGroup(heroStatA, heroStatB).testEquals(); }