diff --git a/core/src/main/java/com/taobao/arthas/core/util/ArthasCheckUtils.java b/core/src/main/java/com/taobao/arthas/core/util/ArthasCheckUtils.java index f540ba49f..ff1503038 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/ArthasCheckUtils.java +++ b/core/src/main/java/com/taobao/arthas/core/util/ArthasCheckUtils.java @@ -1,17 +1,17 @@ package com.taobao.arthas.core.util; /** - * 检查工具类 + * Utils for checks * Created by vlinux on 15/5/19. */ public class ArthasCheckUtils { /** - * 比对某个元素是否在集合中
+ * check whether a component is in an Array
* - * @param e 元素 - * @param s 元素集合 - * @param 元素类型 + * @param e component + * @param s array + * @param component type * @return
* (1,1,2,3) == true * (1,2,3,4) == false @@ -33,11 +33,11 @@ public class ArthasCheckUtils { } /** - * 比对两个对象是否相等
+ * check whether two components are equal
* - * @param src 源对象 - * @param target 目标对象 - * @param 对象类型 + * @param src source component + * @param target target component + * @param component type * @return
* (null, null) == true * (1L,2L) == false diff --git a/core/src/test/java/com/taobao/arthas/core/util/ArthasCheckUtilsTest.java b/core/src/test/java/com/taobao/arthas/core/util/ArthasCheckUtilsTest.java new file mode 100644 index 000000000..30a2f2f0b --- /dev/null +++ b/core/src/test/java/com/taobao/arthas/core/util/ArthasCheckUtilsTest.java @@ -0,0 +1,32 @@ +package com.taobao.arthas.core.util; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author earayu + */ +public class ArthasCheckUtilsTest { + + @Test + public void testIsIn(){ + Assert.assertTrue(ArthasCheckUtils.isIn(1,1,2,3)); + Assert.assertFalse(ArthasCheckUtils.isIn(1,2,3,4)); + Assert.assertTrue(ArthasCheckUtils.isIn(null,1,null,2)); + Assert.assertFalse(ArthasCheckUtils.isIn(1,null)); + Assert.assertTrue(ArthasCheckUtils.isIn(1L,1L,2L,3L)); + Assert.assertFalse(ArthasCheckUtils.isIn(1L,2L,3L,4L)); + Assert.assertTrue(ArthasCheckUtils.isIn("foo","foo","bar")); + Assert.assertFalse(ArthasCheckUtils.isIn("foo","bar","goo")); + } + + + @Test + public void testIsEquals(){ + Assert.assertTrue(ArthasCheckUtils.isEquals(1,1)); + Assert.assertTrue(ArthasCheckUtils.isEquals(1L,1L)); + Assert.assertTrue(ArthasCheckUtils.isEquals("foo","foo")); + Assert.assertFalse(ArthasCheckUtils.isEquals(1,2)); + Assert.assertFalse(ArthasCheckUtils.isEquals("foo","bar")); + } +}