This commit is contained in:
Looly
2020-05-03 09:10:06 +08:00
parent a4c8ebc572
commit 0321ce1120
4 changed files with 121 additions and 36 deletions

View File

@@ -9,32 +9,32 @@ import java.util.HashMap;
public class TolerantMapTest {
private final TolerantMap<String, String> map = TolerantMap.of(new HashMap<>(), "default");
private final TolerantMap<String, String> map = TolerantMap.of(new HashMap<>(), "default");
@Before
public void before() {
map.put("monday", "星期一");
map.put("tuesday", "星期二");
}
@Before
public void before() {
map.put("monday", "星期一");
map.put("tuesday", "星期二");
}
@Test
public void testSerialize() {
byte[] bytes = ObjectUtil.serialize(map);
TolerantMap<String, String> serializedMap = ObjectUtil.deserialize(bytes);
assert serializedMap != map;
assert map.equals(serializedMap);
}
@Test
public void testSerialize() {
byte[] bytes = ObjectUtil.serialize(map);
TolerantMap<String, String> serializedMap = ObjectUtil.deserialize(bytes);
assert serializedMap != map;
assert map.equals(serializedMap);
}
@Test
public void testClone() {
TolerantMap<String, String> clonedMap = ObjectUtil.clone(map);
assert clonedMap != map;
assert map.equals(clonedMap);
}
@Test
public void testClone() {
TolerantMap<String, String> clonedMap = ObjectUtil.clone(map);
assert clonedMap != map;
assert map.equals(clonedMap);
}
@Test
public void testGet() {
assert "星期二".equals(map.get("tuesday"));
assert "default".equals(map.get(RandomUtil.randomString(6)));
}
@Test
public void testGet() {
assert "星期二".equals(map.get("tuesday"));
assert "default".equals(map.get(RandomUtil.randomString(6)));
}
}