@Test public void shouldNotMatchWhenIndexesDoNotOverlap() { MutationIdentifier a = new MutationIdentifier(aLocation().build(), new HashSet<Integer>(100, 200), "M"); MutationIdentifier b = new MutationIdentifier(aLocation().build(), 1, "M"); assertFalse(a.matches(b)); }
@Test public void shouldBeUnEqualWhenLocationDiffers() { MutationIdentifier a = aMutationId().withLocation(aLocation().withMethod("FOO")).build(); MutationIdentifier b = aMutationId().withLocation(aLocation().withMethod("BAR")).build(); assertFalse(a.equals(b)); assertFalse(b.equals(a)); }
@Test public void shouldMatchWhenIndexesOverlap() { MutationIdentifier a = new MutationIdentifier(aLocation().build(), new HashSet<Integer>(Arrays.asList(1, 2)), "M"); MutationIdentifier b = new MutationIdentifier(aLocation().build(), 1, "M"); assertTrue(a.matches(b)); }
@Test public void shouldBeUnEqualWhenMutatorDiffers() { MutationIdentifier a = aMutationId().withMutator("FOO").build(); MutationIdentifier b = aMutationId().withMutator("BAR").build(); assertFalse(a.equals(b)); assertFalse(b.equals(a)); }
@Test public void shouldBeUnEqualWhenIndexDiffers() { MutationIdentifier a = aMutationId().withIndex(1).build(); MutationIdentifier b = aMutationId().withIndex(2).build(); assertFalse(a.equals(b)); assertFalse(b.equals(a)); }
@Test public void shouldNotMatchWhenLocationsDiffer() { MutationIdentifier a = new MutationIdentifier(aLocation().withMethodDescription("X").build(), 1, "M"); MutationIdentifier b = new MutationIdentifier(aLocation().withMethodDescription("Y").build(), 1, "M"); assertFalse(a.matches(b)); }
@Test public void shouldHaveSymmetricEqulasImplementation() { MutationIdentifier a = aMutationId().withIndex(1).withMutator("M").build(); MutationIdentifier b = aMutationId().withIndex(1).withMutator("M").build(); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.hashCode() == b.hashCode()); }
@Test public void shouldNotMatchWhenIndexesDiffer() { MutationIdentifier a = aMutationId().withIndex(1).build(); MutationIdentifier b = aMutationId().withIndex(100).build(); assertFalse(a.matches(b)); }
@Test public void shouldNotMatchWhenMutatorsDiffer() { MutationIdentifier a = aMutationId().withMutator("A").build(); MutationIdentifier b = aMutationId().withMutator("XXXX").build(); assertFalse(a.matches(b)); }
@Test public void shouldMatchWhenObjectsAreEqual() { MutationIdentifier a = aMutationId().build(); MutationIdentifier b = aMutationId().build(); assertTrue(a.matches(b)); }
@Test public void shouldEqualSelf() { MutationIdentifier a = aMutationId().withIndex(1).withMutator("M").build(); assertTrue(a.equals(a)); }