Skip to content

Commit

Permalink
Refactoring #191 test some more
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 12, 2020
1 parent 19057da commit 8962b95
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 50 deletions.
Expand Up @@ -21,7 +21,6 @@ public class CsvDecoder

private final static int INT_CR = '\r';
private final static int INT_LF = '\n';
private final static int INT_HASH = '#';

/*
/**********************************************************************
Expand Down Expand Up @@ -543,6 +542,10 @@ public boolean skipLinesWhenNeeded() throws IOException {
return false; // end of input
}

// 12-Apr-2020, tatu: Not used any more (probably replaced by above?)
/*
private final static int INT_HASH = '#';
protected int _skipCommentLines() throws IOException
{
while ((_inputPtr < _inputEnd) || loadMore()) {
Expand All @@ -561,6 +564,7 @@ protected int _skipCommentLines() throws IOException
}
return -1; // end of input
}
*/

/**
* Method called to blindly skip a single line of content, without considering
Expand Down
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.dataformat.csv.failing;

import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.List;
import java.util.Map;

Expand All @@ -15,19 +16,20 @@ public class ParserSkipEmpty191Test extends ModuleTestBase {
private static String COL_2 = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";

// [dataformats-text#191]: IndexArrayOutOfBounds at 4000
public void testBigCsvFile() throws Exception {
public void testBigCsvFile() throws Exception
{
CsvSchema schema = CsvSchema
.emptySchema()
.withHeader()
.withColumnSeparator(';')
.withNullValue("null")
.withComments();

try (InputStream csvFileStream = getClass().getResourceAsStream("/csv/issue-191.csv")) {
try (Reader r = new StringReader(_generate4kDoc())) {
List<Map<String, String>> result = new CsvMapper()
.readerFor(Map.class)
.with(schema)
.<Map<String, String>>readValues(csvFileStream)
.<Map<String, String>>readValues(r)
.readAll();

for (Map<String, String> row : result) {
Expand All @@ -36,4 +38,16 @@ public void testBigCsvFile() throws Exception {
}
}
}
}

private String _generate4kDoc() {
StringBuilder sb = new StringBuilder(5000)
.append("COL_1;COL_2\n")
.append("# csv file with a newline at char 4000 (the buffer size) to verify a bug\n")
.append("# LF has to be used for newlines to work\n")
.append("# alignment chars to have the newline as the 4000s char: ----------------\n");
for (int i = 0; i < 40; ++i) {
sb.append("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n");
}
return sb.toString();
}
}
44 changes: 0 additions & 44 deletions csv/src/test/resources/csv/issue-191.csv

This file was deleted.

0 comments on commit 8962b95

Please sign in to comment.