@Test public void testSubsumedBy() { BlocksGroup group1 = newBlocksGroup(newBlock("a", 1), newBlock("b", 2)); BlocksGroup group2 = newBlocksGroup(newBlock("a", 2), newBlock("b", 3), newBlock("c", 4)); // block "c" from group2 does not have corresponding block in group1 assertThat(group2.subsumedBy(group1, 1), is(false)); }
@Test public void testIntersect() { BlocksGroup group1 = newBlocksGroup(newBlock("a", 1), newBlock("b", 2)); BlocksGroup group2 = newBlocksGroup(newBlock("a", 2), newBlock("b", 3)); BlocksGroup intersection = group1.intersect(group2); assertThat(intersection.size(), is(2)); }
@Test public void shouldReturnSize() { BlocksGroup group = newBlocksGroup(newBlock("a", 1), newBlock("b", 2)); assertThat(group.size(), is(2)); }
@Test public void testSubsumedBy2() { BlocksGroup group1 = newBlocksGroup(newBlock("a", 1), newBlock("b", 2)); BlocksGroup group2 = newBlocksGroup(newBlock("a", 2), newBlock("b", 3)); BlocksGroup group3 = newBlocksGroup(newBlock("a", 3), newBlock("b", 4)); BlocksGroup group4 = newBlocksGroup(newBlock("a", 4), newBlock("b", 5)); assertThat(group2.subsumedBy(group1, 1), is(true)); // correction of index - 1 assertThat(group3.subsumedBy(group1, 2), is(true)); // correction of index - 2 assertThat(group3.subsumedBy(group2, 1), is(true)); // correction of index - 1 assertThat(group4.subsumedBy(group1, 3), is(true)); // correction of index - 3 assertThat(group4.subsumedBy(group2, 2), is(true)); // correction of index - 2 assertThat(group4.subsumedBy(group3, 1), is(true)); // correction of index - 1 }
assertThat(newBlocksGroup(newBlock("a", 2), newBlock("b", 0)) .subsumedBy(newBlocksGroup(newBlock("a", 1)), 1), is(false)); assertThat(newBlocksGroup(newBlock("a", 3), newBlock("b", 1)) .subsumedBy(newBlocksGroup(newBlock("a", 1)), 1), is(false)); assertThat(newBlocksGroup(newBlock("a", 4), newBlock("b", 2)) .subsumedBy(newBlocksGroup(newBlock("a", 1)), 1), is(false)); assertThat(newBlocksGroup(newBlock("a", 5), newBlock("b", 3)) .subsumedBy(newBlocksGroup(newBlock("a", 1)), 1), is(false)); assertThat(newBlocksGroup(newBlock("a", 3), newBlock("b", 1)) .subsumedBy(newBlocksGroup(newBlock("a", 2), newBlock("b", 0)), 1), is(true)); assertThat(newBlocksGroup(newBlock("a", 4), newBlock("b", 2), newBlock("c", 0)) .subsumedBy(newBlocksGroup(newBlock("a", 3), newBlock("b", 1)), 1), is(false)); assertThat(newBlocksGroup(newBlock("a", 5), newBlock("b", 3), newBlock("c", 1)) .subsumedBy(newBlocksGroup(newBlock("a", 3), newBlock("b", 1)), 1), is(false)); assertThat(newBlocksGroup(newBlock("a", 6), newBlock("c", 2))
assertThat(newBlocksGroup(newBlock("a", 2), newBlock("b", 0)) .intersect(newBlocksGroup(newBlock("a", 3), newBlock("b", 1))) .size(), is(2)); assertThat(newBlocksGroup(newBlock("a", 3), newBlock("b", 1)) .intersect(newBlocksGroup(newBlock("a", 4), newBlock("b", 2), newBlock("c", 0))) .size(), is(2)); assertThat(newBlocksGroup(newBlock("a", 4), newBlock("b", 2)) .intersect(newBlocksGroup(newBlock("a", 5), newBlock("b", 3), newBlock("c", 1))) .size(), is(2)); assertThat(newBlocksGroup(newBlock("a", 5), newBlock("b", 3)) .intersect(newBlocksGroup(newBlock("a", 6), newBlock("c", 2))) .size(), is(1)); assertThat(newBlocksGroup(newBlock("a", 4), newBlock("b", 2), newBlock("c", 0)) .intersect(newBlocksGroup(newBlock("a", 5), newBlock("b", 3), newBlock("c", 1))) .size(), is(3)); assertThat(newBlocksGroup(newBlock("a", 5), newBlock("b", 3), newBlock("c", 1)) .intersect(newBlocksGroup(newBlock("a", 6), newBlock("c", 2))) .size(), is(2)); assertThat(newBlocksGroup(newBlock("a", 6), newBlock("c", 7)) .intersect(newBlocksGroup(newBlock("a", 7))) .size(), is(1));