mirror of https://github.com/alibaba/arthas.git
commit
29eef89b86
@ -0,0 +1,40 @@
|
||||
package com.taobao.arthas.core.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
/**
|
||||
* @author earayu
|
||||
*/
|
||||
public class ArrayUtilsTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testEmptyLongArray() {
|
||||
Assert.assertArrayEquals(ArrayUtils.EMPTY_LONG_ARRAY, new long[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToPrimitive() {
|
||||
Assert.assertArrayEquals(ArrayUtils.toPrimitive(null), null);
|
||||
Assert.assertArrayEquals(ArrayUtils.toPrimitive(new Long[0]), new long[0]);
|
||||
Assert.assertArrayEquals(
|
||||
ArrayUtils.toPrimitive(new Long[]{
|
||||
1L,
|
||||
1763L,
|
||||
54769975464L
|
||||
}),
|
||||
new long[]{
|
||||
1L,
|
||||
1763L,
|
||||
54769975464L
|
||||
});
|
||||
//throws NullPointerException if array content is null
|
||||
thrown.expect(NullPointerException.class);
|
||||
Assert.assertArrayEquals(ArrayUtils.toPrimitive(new Long[]{null}), new long[]{1L});
|
||||
}
|
||||
}
|
@ -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…
Reference in New Issue