|
|
@ -1,6 +1,5 @@ |
|
|
|
package com.fanruan.api.util; |
|
|
|
package com.fanruan.api.util; |
|
|
|
import com.fr.general.Inter; |
|
|
|
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
|
|
|
import com.fanruan.api.Prepare; |
|
|
|
import com.fanruan.api.Prepare; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
@ -8,31 +7,31 @@ import org.junit.Test; |
|
|
|
public class ArrayKitTest extends Prepare { |
|
|
|
public class ArrayKitTest extends Prepare { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void isEmpty() throws Exception{ |
|
|
|
public void isEmpty() throws Exception{ |
|
|
|
Object emptyArray []=new Object[0]; |
|
|
|
Object[] emptyArray = new Object[0]; |
|
|
|
Object notEmptyArray [] = new Object[1]; |
|
|
|
Object[] notEmptyArray = new Object[1]; |
|
|
|
Assert.assertEquals(ArrayKit.isEmpty(emptyArray), true); |
|
|
|
Assert.assertTrue(ArrayKit.isEmpty(emptyArray)); |
|
|
|
Assert.assertEquals(ArrayKit.isEmpty(notEmptyArray), false); |
|
|
|
Assert.assertFalse(ArrayKit.isEmpty(notEmptyArray)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void remove() throws Exception{ |
|
|
|
public void remove() throws Exception{ |
|
|
|
Integer intTestArray [] = {1,2,3,4}; |
|
|
|
Integer[] intTestArray = {1, 2, 3, 4}; |
|
|
|
Integer intTestResult [] = {1,2,3}; |
|
|
|
Integer[] intTestResult = {1, 2, 3}; |
|
|
|
Boolean booleanTestArray [] = {true, true, true, false}; |
|
|
|
Boolean[] booleanTestArray = {true, true, true, false}; |
|
|
|
Boolean booleanTestResult [] = {true, true, true}; |
|
|
|
Boolean[] booleanTestResult = {true, true, true}; |
|
|
|
Byte byteTestArray [] = {100,101,102,103}; |
|
|
|
Byte[] byteTestArray = {100, 101, 102, 103}; |
|
|
|
Byte byteTestResult [] = {100,101,102}; |
|
|
|
Byte[] byteTestResult = {100, 101, 102}; |
|
|
|
Character charTestArray [] = {'a','b','c','d'}; |
|
|
|
Character[] charTestArray = {'a', 'b', 'c', 'd'}; |
|
|
|
Character charTestResult [] = {'a','b','c'}; |
|
|
|
Character[] charTestResult = {'a', 'b', 'c'}; |
|
|
|
Double doubleTestArray [] = {1.1,2.2,3.3,4.4}; |
|
|
|
Double[] doubleTestArray = {1.1, 2.2, 3.3, 4.4}; |
|
|
|
Double doubleTestResult [] = {1.1,2.2,3.3}; |
|
|
|
Double[] doubleTestResult = {1.1, 2.2, 3.3}; |
|
|
|
Float floatTestArray [] = {1.1f,2.2f,3.3f,4.4f}; |
|
|
|
Float[] floatTestArray = {1.1f, 2.2f, 3.3f, 4.4f}; |
|
|
|
Float floatTestResult [] = {1.1f,2.2f,3.3f}; |
|
|
|
Float[] floatTestResult = {1.1f, 2.2f, 3.3f}; |
|
|
|
Long longTestArray [] = {1L,2L,3L,4L}; |
|
|
|
Long[] longTestArray = {1L, 2L, 3L, 4L}; |
|
|
|
Long longTestResult [] = {1L,2L,3L}; |
|
|
|
Long[] longTestResult = {1L, 2L, 3L}; |
|
|
|
Short shortTestArray [] = {1,2,3,4}; |
|
|
|
Short[] shortTestArray = {1, 2, 3, 4}; |
|
|
|
Short shortTestResult [] = {1,2,3}; |
|
|
|
Short[] shortTestResult = {1, 2, 3}; |
|
|
|
Assert.assertEquals(ArrayKit.remove(intTestArray, 3), intTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.remove(intTestArray, 3), intTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.remove(booleanTestArray, 3), booleanTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.remove(booleanTestArray, 3), booleanTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.remove(byteTestArray, 3), byteTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.remove(byteTestArray, 3), byteTestResult); |
|
|
@ -45,22 +44,22 @@ public class ArrayKitTest extends Prepare { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void add() throws Exception{ |
|
|
|
public void add() throws Exception{ |
|
|
|
Integer intTestArray [] = {1,2,3,4}; |
|
|
|
Integer[] intTestArray = {1, 2, 3, 4}; |
|
|
|
Integer intTestResult [] = {1,2,3,4,5}; |
|
|
|
Integer[] intTestResult = {1, 2, 3, 4, 5}; |
|
|
|
Boolean booleanTestArray [] = {true, true, true, false}; |
|
|
|
Boolean[] booleanTestArray = {true, true, true, false}; |
|
|
|
Boolean booleanTestResult [] = {true, true, true, false, true}; |
|
|
|
Boolean[] booleanTestResult = {true, true, true, false, true}; |
|
|
|
Byte byteTestArray [] = {1}; |
|
|
|
Byte[] byteTestArray = {1}; |
|
|
|
Byte byteTestResult [] = {1,0}; |
|
|
|
Byte[] byteTestResult = {1, 0}; |
|
|
|
Character charTestArray [] = {'a','b','c','d'}; |
|
|
|
Character[] charTestArray = {'a', 'b', 'c', 'd'}; |
|
|
|
Character charTestResult [] = {'a','b','c','d','e'}; |
|
|
|
Character[] charTestResult = {'a', 'b', 'c', 'd', 'e'}; |
|
|
|
Double doubleTestArray [] = {1.1,2.2,3.3,4.4}; |
|
|
|
Double[] doubleTestArray = {1.1, 2.2, 3.3, 4.4}; |
|
|
|
Double doubleTestResult [] = {1.1,2.2,3.3,4.4,5.5}; |
|
|
|
Double[] doubleTestResult = {1.1, 2.2, 3.3, 4.4, 5.5}; |
|
|
|
Float floatTestArray [] = {1.1f,2.2f,3.3f,4.4f}; |
|
|
|
Float[] floatTestArray = {1.1f, 2.2f, 3.3f, 4.4f}; |
|
|
|
Float floatTestResult [] = {1.1f,2.2f,3.3f,4.4f,5.5f}; |
|
|
|
Float[] floatTestResult = {1.1f, 2.2f, 3.3f, 4.4f, 5.5f}; |
|
|
|
Long longTestArray [] = {1L,2L,3L,4L}; |
|
|
|
Long[] longTestArray = {1L, 2L, 3L, 4L}; |
|
|
|
Long longTestResult [] = {1L,2L,3L,4L,5L}; |
|
|
|
Long[] longTestResult = {1L, 2L, 3L, 4L, 5L}; |
|
|
|
Short shortTestArray [] = {1,2,3,4}; |
|
|
|
Short[] shortTestArray = {1, 2, 3, 4}; |
|
|
|
Short shortTestResult [] = {1,2,3,4,5}; |
|
|
|
Short[] shortTestResult = {1, 2, 3, 4, 5}; |
|
|
|
Assert.assertEquals(ArrayKit.add(intTestArray, 5), intTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.add(intTestArray, 5), intTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.add(booleanTestArray, true), booleanTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.add(booleanTestArray, true), booleanTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.add(byteTestArray, new Byte("0")), byteTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.add(byteTestArray, new Byte("0")), byteTestResult); |
|
|
@ -73,22 +72,22 @@ public class ArrayKitTest extends Prepare { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void addAll() throws Exception{ |
|
|
|
public void addAll() throws Exception{ |
|
|
|
Integer intTestArray [] = {1,2,3,4}; |
|
|
|
Integer[] intTestArray = {1, 2, 3, 4}; |
|
|
|
Integer intTestResult [] = {1,2,3,4,5,6}; |
|
|
|
Integer[] intTestResult = {1, 2, 3, 4, 5, 6}; |
|
|
|
Boolean booleanTestArray [] = {true, true, true, false}; |
|
|
|
Boolean[] booleanTestArray = {true, true, true, false}; |
|
|
|
Boolean booleanTestResult [] = {true, true, true, false, true,true}; |
|
|
|
Boolean[] booleanTestResult = {true, true, true, false, true, true}; |
|
|
|
Byte byteTestArray [] = {1}; |
|
|
|
Byte[] byteTestArray = {1}; |
|
|
|
Byte byteTestResult [] = {1,0,0}; |
|
|
|
Byte[] byteTestResult = {1, 0, 0}; |
|
|
|
Character charTestArray [] = {'a','b','c','d'}; |
|
|
|
Character[] charTestArray = {'a', 'b', 'c', 'd'}; |
|
|
|
Character charTestResult [] = {'a','b','c','d','e','f'}; |
|
|
|
Character[] charTestResult = {'a', 'b', 'c', 'd', 'e', 'f'}; |
|
|
|
Double doubleTestArray [] = {1.1,2.2,3.3,4.4}; |
|
|
|
Double[] doubleTestArray = {1.1, 2.2, 3.3, 4.4}; |
|
|
|
Double doubleTestResult [] = {1.1,2.2,3.3,4.4,5.5,6.6}; |
|
|
|
Double[] doubleTestResult = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6}; |
|
|
|
Float floatTestArray [] = {1.1f,2.2f,3.3f,4.4f}; |
|
|
|
Float[] floatTestArray = {1.1f, 2.2f, 3.3f, 4.4f}; |
|
|
|
Float floatTestResult [] = {1.1f,2.2f,3.3f,4.4f,5.5f,6.6f}; |
|
|
|
Float[] floatTestResult = {1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f}; |
|
|
|
Long longTestArray [] = {1L,2L,3L,4L}; |
|
|
|
Long[] longTestArray = {1L, 2L, 3L, 4L}; |
|
|
|
Long longTestResult [] = {1L,2L,3L,4L,5L,6L}; |
|
|
|
Long[] longTestResult = {1L, 2L, 3L, 4L, 5L, 6L}; |
|
|
|
Short shortTestArray [] = {1,2,3,4}; |
|
|
|
Short[] shortTestArray = {1, 2, 3, 4}; |
|
|
|
Short shortTestResult [] = {1,2,3,4,5,6}; |
|
|
|
Short[] shortTestResult = {1, 2, 3, 4, 5, 6}; |
|
|
|
Assert.assertEquals(ArrayKit.addAll(intTestArray, 5,6), intTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.addAll(intTestArray, 5,6), intTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.addAll(booleanTestArray, true, true), booleanTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.addAll(booleanTestArray, true, true), booleanTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.addAll(byteTestArray, new Byte("0"), new Byte("0")), byteTestResult); |
|
|
|
Assert.assertEquals(ArrayKit.addAll(byteTestArray, new Byte("0"), new Byte("0")), byteTestResult); |
|
|
|