Skip to content

Commit e0f022e

Browse files
committed
More tests.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1715712 13f79535-47bb-0310-9956-ffa450edef68
1 parent bae5752 commit e0f022e

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ public void testSkipAutoHeader() throws Exception {
866866
assertEquals("2", record.get("b"));
867867
assertEquals("3", record.get("c"));
868868
}
869-
869+
870870
@Test
871871
public void testSkipSetHeader() throws Exception {
872872
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
@@ -878,6 +878,28 @@ public void testSkipSetHeader() throws Exception {
878878
assertEquals("3", record.get("c"));
879879
}
880880

881+
@Test
882+
public void testSkipSetAltHeaders() throws Exception {
883+
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
884+
final Iterator<CSVRecord> records = CSVFormat.DEFAULT.withHeader("X", "Y", "Z").withSkipHeaderRecord()
885+
.parse(in).iterator();
886+
final CSVRecord record = records.next();
887+
assertEquals("1", record.get("X"));
888+
assertEquals("2", record.get("Y"));
889+
assertEquals("3", record.get("Z"));
890+
}
891+
892+
@Test
893+
public void testSkipHeaderOverrideDuplicateHeaders() throws Exception {
894+
final Reader in = new StringReader("a,a,a\n1,2,3\nx,y,z");
895+
final Iterator<CSVRecord> records = CSVFormat.DEFAULT.withHeader("X", "Y", "Z").withSkipHeaderRecord()
896+
.parse(in).iterator();
897+
final CSVRecord record = records.next();
898+
assertEquals("1", record.get("X"));
899+
assertEquals("2", record.get("Y"));
900+
assertEquals("3", record.get("Z"));
901+
}
902+
881903
private void validateLineNumbers(final String lineSeparator) throws IOException {
882904
final CSVParser parser = CSVParser.parse("a" + lineSeparator + "b" + lineSeparator + "c",
883905
CSVFormat.DEFAULT.withRecordSeparator(lineSeparator));

0 commit comments

Comments
 (0)