mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -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"));
|
||||
|
22
hutool-core/src/test/java/cn/hutool/core/map/BiMapTest.java
Normal file
22
hutool-core/src/test/java/cn/hutool/core/map/BiMapTest.java
Normal 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));
|
||||
}
|
||||
}
|
@@ -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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user