public void testSerialisation0() throws Exception { Flat3Map map = new Flat3Map(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(map); byte[] bytes = bout.toByteArray(); out.close(); ByteArrayInputStream bin = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(bin); Flat3Map ser = (Flat3Map) in.readObject(); in.close(); assertEquals(0, map.size()); assertEquals(0, ser.size()); }
public void testCollections261() { final Flat3Map m = new Flat3Map(); m.put( new Integer(1), new Integer(1) ); m.put( new Integer(0), new Integer(0) ); assertEquals( new Integer(1), m.remove( new Integer(1) ) ); assertEquals( new Integer(0), m.remove( new Integer(0) ) ); m.put( new Integer(2), new Integer(2) ); m.put( new Integer(1), new Integer(1) ); m.put( new Integer(0), new Integer(0) ); assertEquals( new Integer(2), m.remove( new Integer(2) ) ); assertEquals( new Integer(1), m.remove( new Integer(1) ) ); assertEquals( new Integer(0), m.remove( new Integer(0) ) ); }
public void testSerialisation2() throws Exception { Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(map); byte[] bytes = bout.toByteArray(); out.close(); ByteArrayInputStream bin = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(bin); Flat3Map ser = (Flat3Map) in.readObject(); in.close(); assertEquals(2, map.size()); assertEquals(2, ser.size()); assertEquals(true, ser.containsKey(ONE)); assertEquals(true, ser.containsKey(TWO)); assertEquals(TEN, ser.get(ONE)); assertEquals(TWENTY, ser.get(TWO)); }
public void testEntryIteratorSetValue3() throws Exception { final Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); map.put(THREE, THIRTY); final Iterator it = map.entrySet().iterator(); it.next(); it.next(); final Map.Entry entry = (Map.Entry) it.next(); entry.setValue("NewValue"); assertEquals(3, map.size()); assertEquals(true, map.containsKey(ONE)); assertEquals(true, map.containsKey(TWO)); assertEquals(true, map.containsKey(THREE)); assertEquals(TEN, map.get(ONE)); assertEquals(TWENTY, map.get(TWO)); assertEquals("NewValue", map.get(THREE)); }
public void testEntryIteratorSetValue1() throws Exception { final Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); map.put(THREE, THIRTY); final Iterator it = map.entrySet().iterator(); final Map.Entry entry = (Map.Entry) it.next(); entry.setValue("NewValue"); assertEquals(3, map.size()); assertEquals(true, map.containsKey(ONE)); assertEquals(true, map.containsKey(TWO)); assertEquals(true, map.containsKey(THREE)); assertEquals("NewValue", map.get(ONE)); assertEquals(TWENTY, map.get(TWO)); assertEquals(THIRTY, map.get(THREE)); }
public void testEntryIteratorSetValue2() throws Exception { final Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); map.put(THREE, THIRTY); final Iterator it = map.entrySet().iterator(); it.next(); final Map.Entry entry = (Map.Entry) it.next(); entry.setValue("NewValue"); assertEquals(3, map.size()); assertEquals(true, map.containsKey(ONE)); assertEquals(true, map.containsKey(TWO)); assertEquals(true, map.containsKey(THREE)); assertEquals(TEN, map.get(ONE)); assertEquals("NewValue", map.get(TWO)); assertEquals(THIRTY, map.get(THREE)); }
public void testSerialisation4() throws Exception { Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); map.put(TEN, ONE); map.put(TWENTY, TWO); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(map); byte[] bytes = bout.toByteArray(); out.close(); ByteArrayInputStream bin = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(bin); Flat3Map ser = (Flat3Map) in.readObject(); in.close(); assertEquals(4, map.size()); assertEquals(4, ser.size()); assertEquals(true, ser.containsKey(ONE)); assertEquals(true, ser.containsKey(TWO)); assertEquals(true, ser.containsKey(TEN)); assertEquals(true, ser.containsKey(TWENTY)); assertEquals(TEN, ser.get(ONE)); assertEquals(TWENTY, ser.get(TWO)); assertEquals(ONE, ser.get(TEN)); assertEquals(TWO, ser.get(TWENTY)); }
public void testClone2() { Flat3Map map = new Flat3Map(); assertEquals(0, map.size()); map.put(ONE, TEN); map.put(TWO, TWENTY); assertEquals(2, map.size()); assertEquals(true, map.containsKey(ONE)); assertEquals(true, map.containsKey(TWO)); assertSame(TEN, map.get(ONE)); assertSame(TWENTY, map.get(TWO)); // clone works (size = 2) Flat3Map cloned = (Flat3Map) map.clone(); assertEquals(2, cloned.size()); assertEquals(true, cloned.containsKey(ONE)); assertEquals(true, cloned.containsKey(TWO)); assertSame(TEN, cloned.get(ONE)); assertSame(TWENTY, cloned.get(TWO)); // change original doesn't change clone map.put(TEN, ONE); map.put(TWENTY, TWO); assertEquals(4, map.size()); assertEquals(2, cloned.size()); assertEquals(true, cloned.containsKey(ONE)); assertEquals(true, cloned.containsKey(TWO)); assertSame(TEN, cloned.get(ONE)); assertSame(TWENTY, cloned.get(TWO)); } public void testClone4() {
public void testClone4() { Flat3Map map = new Flat3Map(); assertEquals(0, map.size()); map.put(ONE, TEN); map.put(TWO, TWENTY); assertEquals(4, map.size()); assertEquals(4, cloned.size()); assertEquals(true, cloned.containsKey(ONE)); assertEquals(true, cloned.containsKey(TWO)); assertEquals(true, cloned.containsKey(TEN)); assertEquals(true, cloned.containsKey(TWENTY)); assertSame(TEN, cloned.get(ONE)); assertSame(TWENTY, cloned.get(TWO)); assertEquals(0, map.size()); assertEquals(4, cloned.size()); assertEquals(true, cloned.containsKey(ONE)); assertEquals(true, cloned.containsKey(TWO)); assertEquals(true, cloned.containsKey(TEN)); assertEquals(true, cloned.containsKey(TWENTY)); assertSame(TEN, cloned.get(ONE)); assertSame(TWENTY, cloned.get(TWO));
public void testEquals1() { Flat3Map map1 = new Flat3Map(); map1.put("a", "testA"); map1.put("b", "testB"); Flat3Map map2 = new Flat3Map(); map2.put("a", "testB"); map2.put("b", "testA"); assertEquals(false, map1.equals(map2)); }
public void testEquals2() { Flat3Map map1 = new Flat3Map(); map1.put("a", "testA"); map1.put("b", "testB"); Flat3Map map2 = new Flat3Map(); map2.put("a", "testB"); map2.put("c", "testA"); assertEquals(false, map1.equals(map2)); }