@Test public void copyMethodsReallyReturnCopies() { BasicInterval bi = new BasicInterval(DEFAULT_BEGIN, DEFAULT_END); CompoundInterval toCopy = new CompoundInterval(bi, null); BasicInterval bi2 = new BasicInterval(DEFAULT_END, DEFAULT_END + 1); toCopy.add(bi2); CompoundInterval aCopy = toCopy.copy(new Register(1)); assertThat(aCopy, not(sameInstance(toCopy))); CompoundInterval anotherCopy = toCopy.copy(new Register(3), bi); assertThat(anotherCopy, not(sameInstance(toCopy))); }
@Test public void copyStopsAtTheRightPointWhenRequired() { BasicInterval bi = new BasicInterval(DEFAULT_BEGIN, DEFAULT_END); CompoundInterval toCopy = new CompoundInterval(bi, null); BasicInterval bi2 = new BasicInterval(DEFAULT_END, DEFAULT_END + 1); BasicInterval bi3 = new BasicInterval(DEFAULT_END + 1, DEFAULT_END + 2); toCopy.add(bi2); toCopy.add(bi3); Register r = new Register(2); CompoundInterval copy = toCopy.copy(r, bi2); assertThat(copy.getRegister(), is(r)); assertThat(copy.contains(bi), is(true)); assertThat(copy.contains(bi2), is(true)); assertThat(copy.contains(bi3), is(false)); assertThat(copy.size(), is(2)); }
@Test public void copyCopiesAllIntervalsToNewCompoundIntervalWithRightRegister() { BasicInterval bi = new BasicInterval(DEFAULT_BEGIN, DEFAULT_END); CompoundInterval toCopy = new CompoundInterval(bi, null); BasicInterval bi2 = new BasicInterval(DEFAULT_END, DEFAULT_END + 1); BasicInterval bi3 = new BasicInterval(DEFAULT_END + 1, DEFAULT_END + 2); toCopy.add(bi2); toCopy.add(bi3); Register r = new Register(2); CompoundInterval copy = toCopy.copy(r); assertThat(copy.getRegister(), is(r)); assertThat(copy.contains(bi), is(true)); assertThat(copy.contains(bi2), is(true)); assertThat(copy.contains(bi3), is(true)); assertThat(copy.size(), is(3)); }