/
CsvHelperReaderTest.java
43 lines (35 loc) · 1.12 KB
/
CsvHelperReaderTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.github.houbb.csv.util;
import com.github.houbb.csv.model.User;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
/**
* @author binbin.hou
* @since 0.0.8
*/
@Ignore
public class CsvHelperReaderTest {
/**
* 读取列表
* @since 0.0.8
*/
@Test
public void readListTest() {
List<String> lines = Arrays.asList("name,age,score,money,sex,level,id,status,coin",
"你好,10,60.0,200.0,true,4,1,Y,1");
List<User> userList = CsvHelper.read(lines, User.class);
Assert.assertEquals("[User{name='你好', age=10, score=60.0, money=200.0, sex=true, level=4, id=1, status=Y, coin=1}]", userList.toString());
}
/**
* 读取列表
* @since 0.0.8
*/
@Test
public void readFilePathTest() {
final String path = "src\\test\\resources\\common.csv";
List<User> userList = CsvHelper.read(path, User.class);
Assert.assertEquals("[User{name='你好', age=10, score=60.0, money=200.0, sex=true, level=4, id=1, status=Y, coin=1}]", userList.toString());
}
}