mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package cn.hutool.core.collection.partition;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PartitionTest {
|
||||
@Test
|
||||
public void sizeTest() {
|
||||
final ArrayList<Integer> list = ListUtil.of(1, 2, 3, 4, 5);
|
||||
final Partition<Integer> partition = new Partition<>(list, 4);
|
||||
Assert.assertEquals(2, partition.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSizeTest() {
|
||||
List<Integer> mockedList = makingList(19);
|
||||
Partition<Integer> partition = new Partition<>(mockedList, 10);
|
||||
Assert.assertEquals(2, partition.size());
|
||||
|
||||
mockedList = makingList(11);
|
||||
partition = new Partition<>(mockedList, 10);
|
||||
Assert.assertEquals(2, partition.size());
|
||||
|
||||
mockedList = makingList(10);
|
||||
partition = new Partition<>(mockedList, 10);
|
||||
Assert.assertEquals(1, partition.size());
|
||||
|
||||
mockedList = makingList(9);
|
||||
partition = new Partition<>(mockedList, 10);
|
||||
Assert.assertEquals(1, partition.size());
|
||||
|
||||
mockedList = makingList(5);
|
||||
partition = new Partition<>(mockedList, 10);
|
||||
Assert.assertEquals(1, partition.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getZeroSizeTest() {
|
||||
final List<Integer> mockedList = makingList(0);
|
||||
final Partition<Integer> partition = new Partition<>(mockedList, 10);
|
||||
Assert.assertEquals(0, partition.size());
|
||||
}
|
||||
|
||||
private List<Integer> makingList(final int length) {
|
||||
final List<Integer> list = ListUtil.of();
|
||||
for (int i = 0; i < length; i++) {
|
||||
list.add(i);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user