mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add methods
This commit is contained in:
@@ -81,6 +81,7 @@ public class CollStreamUtilTest {
|
||||
Assert.assertEquals(map, compare);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupBy2Key() {
|
||||
Map<Long, Map<Long, List<Student>>> map = CollStreamUtil.groupBy2Key(null, Student::getTermId, Student::getClassId);
|
||||
Assert.assertEquals(map, Collections.EMPTY_MAP);
|
||||
@@ -229,4 +230,4 @@ public class CollStreamUtilTest {
|
||||
private long studentId;//班级id
|
||||
private String name;//学生名称
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package cn.hutool.core.collection;
|
||||
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PartitionIterTest {
|
||||
|
||||
@Test
|
||||
public void iterTest() {
|
||||
final LineIter lineIter = new LineIter(ResourceUtil.getUtf8Reader("test_lines.csv"));
|
||||
final PartitionIter<String> iter = new PartitionIter<>(lineIter.iterator(), 3);
|
||||
for (List<String> lines : iter) {
|
||||
Assert.assertTrue(lines.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void iterMaxTest() {
|
||||
final List<Integer> list = ListUtil.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 0, 12, 45, 12);
|
||||
final PartitionIter<Integer> iter = new PartitionIter<>(list.iterator(), 3);
|
||||
int max = 0;
|
||||
for (List<Integer> lines : iter) {
|
||||
max = NumberUtil.max(max, NumberUtil.max(lines.toArray(new Integer[0])));
|
||||
}
|
||||
Assert.assertEquals(45, max);
|
||||
}
|
||||
}
|
@@ -4,6 +4,9 @@ import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IoUtilTest {
|
||||
|
||||
@Test
|
||||
@@ -11,4 +14,13 @@ public class IoUtilTest {
|
||||
final byte[] bytes = IoUtil.readBytes(ResourceUtil.getStream("hutool.jpg"));
|
||||
Assert.assertEquals(22807, bytes.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readLinesTest(){
|
||||
try(BufferedReader reader = ResourceUtil.getUtf8Reader("test_lines.csv");){
|
||||
IoUtil.readLines(reader, (LineHandler) Assert::assertNotNull);
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user