private void check(Range rng, int a, int b) { rng.set(a, b); eq(rng, a, b); eq(rng.limit(), rng.start + rng.length); long backup = rng.backup(); rng.set(rnd(), rnd()); rng.restore(backup); eq(rng, a, b); }
@Test public void shouldBackupAndRestore() { Range range = new Range(10, 3); eq(range, 10, 3); long backup = range.backup(); range.set(7, 17); eq(range, 7, 17); range.restore(backup); eq(range, 10, 3); }