import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterators;
import java.io.ByteArrayInputStream;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
+import org.junit.Before;
import org.junit.Test;
public class OffsetMapTest {
return (ImmutableOffsetMap<String, String>) ImmutableOffsetMap.copyOf(twoEntryMap);
}
+ @Before
+ public void setup() {
+ OffsetMapCache.invalidateCache();
+ }
+
@Test(expected=IllegalArgumentException.class)
public void testWrongImmutableConstruction() {
- new ImmutableOffsetMap<String, String>(Collections.<String, Integer>emptyMap(), new String[1]);
+ new ImmutableOffsetMap.Ordered<String, String>(Collections.<String, Integer>emptyMap(), new String[1]);
}
@Test
assertFalse(map.equals("string"));
}
- @Test
- public void testImmutableCopyConstructor() {
- final ImmutableOffsetMap<String, String> source = createMap();
- final ImmutableOffsetMap<String, String> result = new ImmutableOffsetMap<>(source);
-
- assertSame(source.offsets(), result.offsets());
- assertSame(source.objects(), result.objects());
- }
-
@Test
public void testImmutableGet() {
final Map<String, String> map = createMap();
@Test
public void testEmptyMutable() throws CloneNotSupportedException {
- final MutableOffsetMap<String, String> map = new MutableOffsetMap<>();
+ final MutableOffsetMap<String, String> map = MutableOffsetMap.of();
assertTrue(map.isEmpty());
final Map<String, String> other = map.clone();
assertNotSame(other, map);
}
- @Test
- public void testMutableWithKeyset() {
- final MutableOffsetMap<String, String> map = new MutableOffsetMap<>(ImmutableList.of("k1", "k2"));
- assertTrue(map.isEmpty());
- assertTrue(map.keySet().isEmpty());
- assertNull(map.get("k1"));
- assertNull(map.remove("k2"));
- }
-
@Test
public void testMutableToEmpty() {
final MutableOffsetMap<String, String> mutable = createMap().toModifiableMap();