Fix the old test case record.getComment() will never be null (#62)
* The old test case record.getComment() will never be null and if record.getComment() be null the test code misplace the null test. Add a new test file that record.getComment() will be null and test record.getComment() no null before using * keep the caching of "record.getComment()"
This commit is contained in:
parent
72edc56862
commit
5591444148
4
pom.xml
4
pom.xml
|
@ -257,6 +257,8 @@
|
||||||
<exclude>src/test/resources/ferc.gov/transaction.txt</exclude>
|
<exclude>src/test/resources/ferc.gov/transaction.txt</exclude>
|
||||||
<exclude>src/test/resources/**/*.bin</exclude>
|
<exclude>src/test/resources/**/*.bin</exclude>
|
||||||
<exclude>src/test/resources/CSV-259/sample.txt</exclude>
|
<exclude>src/test/resources/CSV-259/sample.txt</exclude>
|
||||||
|
<exclude>src/test/resources/CSVFileParser/testCSV246.csv</exclude>
|
||||||
|
<exclude>src/test/resources/CSVFileParser/testCSV246_checkWithNoComment.txt</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -375,6 +377,8 @@
|
||||||
<exclude>src/test/resources/ferc.gov/transaction.txt</exclude>
|
<exclude>src/test/resources/ferc.gov/transaction.txt</exclude>
|
||||||
<exclude>src/test/resources/**/*.bin</exclude>
|
<exclude>src/test/resources/**/*.bin</exclude>
|
||||||
<exclude>src/test/resources/CSV-259/sample.txt</exclude>
|
<exclude>src/test/resources/CSV-259/sample.txt</exclude>
|
||||||
|
<exclude>src/test/resources/CSVFileParser/testCSV246.csv</exclude>
|
||||||
|
<exclude>src/test/resources/CSVFileParser/testCSV246_checkWithNoComment.txt</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -93,11 +93,9 @@ public class CSVFileParserTest {
|
||||||
try (final CSVParser parser = CSVParser.parse(new File(BASE, split[0]), Charset.defaultCharset(), format)) {
|
try (final CSVParser parser = CSVParser.parse(new File(BASE, split[0]), Charset.defaultCharset(), format)) {
|
||||||
for (final CSVRecord record : parser) {
|
for (final CSVRecord record : parser) {
|
||||||
String parsed = Arrays.toString(record.values());
|
String parsed = Arrays.toString(record.values());
|
||||||
if (checkComments) {
|
String comment = record.getComment();
|
||||||
final String comment = record.getComment().replace("\n", "\\n");
|
if (checkComments && comment != null) {
|
||||||
if (comment != null) {
|
parsed += "#" + comment.replace("\n", "\\n");
|
||||||
parsed += "#" + comment;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final int count = record.size();
|
final int count = record.size();
|
||||||
assertEquals(readTestData(testData), count + ":" + parsed, testFile.getName());
|
assertEquals(readTestData(testData), count + ":" + parsed, testFile.getName());
|
||||||
|
@ -140,11 +138,9 @@ public class CSVFileParserTest {
|
||||||
try (final CSVParser parser = CSVParser.parse(resource, Charset.forName("UTF-8"), format)) {
|
try (final CSVParser parser = CSVParser.parse(resource, Charset.forName("UTF-8"), format)) {
|
||||||
for (final CSVRecord record : parser) {
|
for (final CSVRecord record : parser) {
|
||||||
String parsed = Arrays.toString(record.values());
|
String parsed = Arrays.toString(record.values());
|
||||||
if (checkComments) {
|
String comment = record.getComment();
|
||||||
final String comment = record.getComment().replace("\n", "\\n");
|
if (checkComments && comment != null) {
|
||||||
if (comment != null) {
|
parsed += "#" + comment.replace("\n", "\\n");
|
||||||
parsed += "#" + comment;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final int count = record.size();
|
final int count = record.size();
|
||||||
assertEquals(readTestData(testData), count + ":" + parsed, testFile.getName());
|
assertEquals(readTestData(testData), count + ":" + parsed, testFile.getName());
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
a,b,c,e,f
|
||||||
|
# Very Long
|
||||||
|
# Comment 2
|
||||||
|
g,h,i,j,k
|
||||||
|
# Very Long
|
||||||
|
|
||||||
|
# Comment 3
|
||||||
|
l,m,n,o,p
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
testCSV246.csv CommentStart=# CheckComments
|
||||||
|
Delimiter=<,> QuoteChar=<"> CommentStart=<#> SkipHeaderRecord:false
|
||||||
|
5:[a, b, c, e, f]
|
||||||
|
# Very Long
|
||||||
|
# Comment 2
|
||||||
|
5:[g, h, i, j, k]#Very Long\nComment 2
|
||||||
|
# Very Long
|
||||||
|
1:[]#Very Long
|
||||||
|
# Comment 3
|
||||||
|
5:[l, m, n, o, p]#Comment 3
|
Loading…
Reference in New Issue