issue #112 & issue #113

add ArthasCheckUtils test case & translation
pull/126/head
earayu 7 years ago
parent a66fe61c3c
commit e737ac5d71

@ -1,17 +1,17 @@
package com.taobao.arthas.core.util; package com.taobao.arthas.core.util;
/** /**
* * Utils for checks
* Created by vlinux on 15/5/19. * Created by vlinux on 15/5/19.
*/ */
public class ArthasCheckUtils { public class ArthasCheckUtils {
/** /**
* <br/> * check whether a component is in an Array<br/>
* *
* @param e * @param e component
* @param s * @param s array
* @param <E> * @param <E> component type
* @return <br/> * @return <br/>
* (1,1,2,3) == true * (1,1,2,3) == true
* (1,2,3,4) == false * (1,2,3,4) == false
@ -33,11 +33,11 @@ public class ArthasCheckUtils {
} }
/** /**
* <br/> * check whether two components are equal<br/>
* *
* @param src * @param src source component
* @param target * @param target target component
* @param <E> * @param <E> component type
* @return <br/> * @return <br/>
* (null, null) == true * (null, null) == true
* (1L,2L) == false * (1L,2L) == false

@ -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"));
}
}
Loading…
Cancel
Save