-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #483: improve location tracking for CSV
- Loading branch information
1 parent
3756666
commit 4c28c14
Showing
3 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
csv/src/test/java/com/fasterxml/jackson/dataformat/csv/deser/ParserLocation483Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.fasterxml.jackson.dataformat.csv.deser; | ||
|
||
import java.util.*; | ||
|
||
import com.fasterxml.jackson.core.JacksonException; | ||
import com.fasterxml.jackson.databind.MappingIterator; | ||
import com.fasterxml.jackson.dataformat.csv.CsvMapper; | ||
import com.fasterxml.jackson.dataformat.csv.CsvParser; | ||
import com.fasterxml.jackson.dataformat.csv.ModuleTestBase; | ||
|
||
public class ParserLocation483Test extends ModuleTestBase | ||
{ | ||
private final CsvMapper MAPPER = mapperForCsv(); | ||
|
||
// [dataformats-text#483]: Location incorrect | ||
public void testAsSequence() throws Exception | ||
{ | ||
try (MappingIterator<List<String>> reader = MAPPER | ||
.readerForListOf(String.class) | ||
.with(CsvParser.Feature.WRAP_AS_ARRAY) | ||
.readValues("name,dob\n\"string without end")) { | ||
reader.readAll(); | ||
} catch (JacksonException e) { | ||
verifyException(e, "Missing closing quote"); | ||
assertEquals(2, e.getLocation().getLineNr()); | ||
// This is not always accurate but should be close: | ||
assertEquals(20, e.getLocation().getColumnNr()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters