mirror of
https://github.com/apache/commons-csv.git
synced 2025-02-17 07:26:32 +00:00
More tests.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1715712 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bae5752644
commit
e0f022ee94
@ -866,7 +866,7 @@ public class CSVParserTest {
|
||||
assertEquals("2", record.get("b"));
|
||||
assertEquals("3", record.get("c"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSkipSetHeader() throws Exception {
|
||||
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
|
||||
@ -878,6 +878,28 @@ public class CSVParserTest {
|
||||
assertEquals("3", record.get("c"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipSetAltHeaders() throws Exception {
|
||||
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
|
||||
final Iterator<CSVRecord> records = CSVFormat.DEFAULT.withHeader("X", "Y", "Z").withSkipHeaderRecord()
|
||||
.parse(in).iterator();
|
||||
final CSVRecord record = records.next();
|
||||
assertEquals("1", record.get("X"));
|
||||
assertEquals("2", record.get("Y"));
|
||||
assertEquals("3", record.get("Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipHeaderOverrideDuplicateHeaders() throws Exception {
|
||||
final Reader in = new StringReader("a,a,a\n1,2,3\nx,y,z");
|
||||
final Iterator<CSVRecord> records = CSVFormat.DEFAULT.withHeader("X", "Y", "Z").withSkipHeaderRecord()
|
||||
.parse(in).iterator();
|
||||
final CSVRecord record = records.next();
|
||||
assertEquals("1", record.get("X"));
|
||||
assertEquals("2", record.get("Y"));
|
||||
assertEquals("3", record.get("Z"));
|
||||
}
|
||||
|
||||
private void validateLineNumbers(final String lineSeparator) throws IOException {
|
||||
final CSVParser parser = CSVParser.parse("a" + lineSeparator + "b" + lineSeparator + "c",
|
||||
CSVFormat.DEFAULT.withRecordSeparator(lineSeparator));
|
||||
|
Loading…
x
Reference in New Issue
Block a user