From ce33b3d5cbb7396490aa0c972945cba6072ca53b Mon Sep 17 00:00:00 2001 From: Looly Date: Sat, 25 Sep 2021 18:53:12 +0800 Subject: [PATCH] add test --- .../cn/hutool/core/util/ObjectUtilTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hutool-core/src/test/java/cn/hutool/core/util/ObjectUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/util/ObjectUtilTest.java index 5cd6f2442..347a534f7 100644 --- a/hutool-core/src/test/java/cn/hutool/core/util/ObjectUtilTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/util/ObjectUtilTest.java @@ -9,9 +9,40 @@ import org.junit.Test; import java.time.Instant; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; public class ObjectUtilTest { + @Test + public void equalsTest(){ + Object a = null; + Object b = null; + Assert.assertTrue(ObjectUtil.equals(a, b)); + } + + @Test + public void lengthTest(){ + int[] array = new int[]{1,2,3,4,5}; + int length = ObjectUtil.length(array); + Assert.assertEquals(5, length); + + Map map = new HashMap<>(); + map.put("a", "a1"); + map.put("b", "b1"); + map.put("c", "c1"); + length = ObjectUtil.length(map); + Assert.assertEquals(3, length); + } + + @Test + public void containsTest(){ + int[] array = new int[]{1,2,3,4,5}; + + final boolean contains = ObjectUtil.contains(array, 1); + Assert.assertTrue(contains); + } + @Test public void cloneTest() { Obj obj = new Obj(); @@ -54,6 +85,12 @@ public class ObjectUtilTest { Instant result2 = ObjectUtil.defaultIfEmpty(dateStr, () -> DateUtil.parse(dateStr, DatePattern.NORM_DATETIME_PATTERN).toInstant(), Instant.now()); Assert.assertNotNull(result2); + } + @Test + public void isBasicTypeTest(){ + int a = 1; + final boolean basicType = ObjectUtil.isBasicType(a); + Assert.assertTrue(basicType); } }