This commit is contained in:
Looly
2020-05-01 23:01:55 +08:00
parent be65a142b4
commit 70c0f4cacc
5 changed files with 109 additions and 156 deletions

View File

@@ -1,15 +1,13 @@
package cn.hutool.core.convert;
import cn.hutool.core.map.MapBuilder;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapBuilder;
/**
* Map转换单元测试
*
@@ -31,7 +29,10 @@ public class MapConvertTest {
@Test
public void mapToMapTest() {
Map<String, Object> srcMap = MapBuilder.create(new HashMap<String, Object>()).put("name", "AAA").put("age", 45).map();
Map<String, Object> srcMap = MapBuilder
.create(new HashMap<String, Object>())
.put("name", "AAA")
.put("age", 45).map();
LinkedHashMap<?, ?> map = Convert.convert(LinkedHashMap.class, srcMap);
Assert.assertEquals("AAA", map.get("name"));

View File

@@ -0,0 +1,22 @@
package cn.hutool.core.map;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
public class BiMapTest {
@Test
public void getTest(){
BiMap<String, Integer> biMap = new BiMap<>(new HashMap<>());
biMap.put("aaa", 111);
biMap.put("bbb", 222);
Assert.assertEquals(new Integer(111), biMap.get("aaa"));
Assert.assertEquals(new Integer(222), biMap.get("bbb"));
Assert.assertEquals("aaa", biMap.getKey(111));
Assert.assertEquals("bbb", biMap.getKey(222));
}
}

View File

@@ -0,0 +1,20 @@
package cn.hutool.core.map;
import org.junit.Assert;
import org.junit.Test;
public class TableMapTest {
@Test
public void getTest(){
TableMap<String, Integer> tableMap = new TableMap<>(16);
tableMap.put("aaa", 111);
tableMap.put("bbb", 222);
Assert.assertEquals(new Integer(111), tableMap.get("aaa"));
Assert.assertEquals(new Integer(222), tableMap.get("bbb"));
Assert.assertEquals("aaa", tableMap.getKey(111));
Assert.assertEquals("bbb", tableMap.getKey(222));
}
}