import org.junit.Before;
import org.junit.Test;
-/***
- *
+/**
* Test that read-only iterators do not allow for any updates.
* Test that non read-only iterators allow for updates.
- *
*/
public class TestReadOnlyAndUpdatableIterators {
private static final int MAP_SIZE = 200;
@Test(expected = UnsupportedOperationException.class)
public void testReadOnlyIteratorSet() {
- trySet(bt.readOnlyIterator());
+ trySet(bt.immutableIterator());
}
@Test(expected = UnsupportedOperationException.class)
public void testReadOnlyIteratorRemove() {
- tryRemove(bt.readOnlyIterator());
+ tryRemove(bt.immutableIterator());
}
@Test(expected = UnsupportedOperationException.class)
public void testReadOnlySnapshotReadOnlyIteratorSet() {
- trySet(bt.immutableSnapshot().readOnlyIterator());
+ trySet(bt.immutableSnapshot().immutableIterator());
}
@Test(expected = UnsupportedOperationException.class)
public void testReadOnlySnapshotReadOnlyIteratorRemove() {
- tryRemove(bt.immutableSnapshot().readOnlyIterator());
+ tryRemove(bt.immutableSnapshot().immutableIterator());
}
@Test(expected = UnsupportedOperationException.class)
}
@Test
- public void testIterator () {
+ public void testIterator() {
Iterator<Entry<Integer, Integer>> it = bt.iterator();
- it.next().setValue (0);
+ it.next().setValue(0);
it.remove();
// All changes are done on the original map
}
@Test
- public void testSnapshotIterator () {
+ public void testSnapshotIterator() {
TrieMap<Integer, Integer> snapshot = bt.mutableSnapshot();
Iterator<Entry<Integer, Integer>> it = snapshot.iterator();
it.next().setValue(0);
// All changes are done on the snapshot, not on the original map
// Map size should remain unchanged
- assertEquals(MAP_SIZE, bt.size ());
+ assertEquals(MAP_SIZE, bt.size());
// snapshot size was changed
- assertEquals(MAP_SIZE-1, snapshot.size ());
+ assertEquals(MAP_SIZE - 1, snapshot.size());
}
}