Skip to content

Commit 51049fd

Browse files
committed
Fix test
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1727538 13f79535-47bb-0310-9956-ffa450edef68
1 parent 51b4bf3 commit 51049fd

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,37 @@
1616
*/
1717
package org.apache.commons.csv;
1818

19+
import java.io.BufferedReader;
1920
import java.io.File;
21+
import java.io.FileReader;
2022
import java.io.IOException;
2123
import java.nio.charset.Charset;
2224

2325
import org.junit.Assert;
24-
import org.junit.Ignore;
2526
import org.junit.Test;
2627

2728
public class JiraCsv167Test {
2829

2930
@Test
30-
@Ignore("Fails")
3131
public void parse() throws IOException {
3232
final File csvData = new File("src/test/resources/csv-167/sample1.csv");
33+
BufferedReader br = new BufferedReader(new FileReader(csvData));
34+
String s = null;
35+
int totcomment = 0;
36+
int totrecs = 0;
37+
boolean lastWasComment = false;
38+
while((s=br.readLine()) != null) {
39+
if (s.startsWith("#")) {
40+
if (!lastWasComment) { // comments are merged
41+
totcomment++;
42+
}
43+
lastWasComment = true;
44+
} else {
45+
totrecs++;
46+
lastWasComment = false;
47+
}
48+
}
49+
br.close();
3350
CSVFormat format = CSVFormat.DEFAULT;
3451
//
3552
format = format.withAllowMissingColumnNames(false);
@@ -50,15 +67,14 @@ public void parse() throws IOException {
5067
int comments = 0;
5168
int records = 0;
5269
for (final CSVRecord csvRecord : parser) {
70+
// System.out.println(csvRecord.isComment() + "[" + csvRecord.toString() + "]");
71+
records++;
5372
if (csvRecord.isComment()) {
5473
comments++;
55-
} else {
56-
records++;
57-
// System.out.println("[" + csvRecord.toString() + "]");
5874
}
5975
}
6076
// Comment lines are concatenated, in this example 4 lines become 2 comments.
61-
Assert.assertEquals(2, comments);
62-
Assert.assertEquals(3, records);
77+
Assert.assertEquals(totcomment, comments);
78+
Assert.assertEquals(totrecs, records); // records includes the header
6379
}
6480
}

0 commit comments

Comments
 (0)