-
-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for collecting blank lines of comments
- Loading branch information
Showing
3 changed files
with
67 additions
and
1 deletion.
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
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
39 changes: 39 additions & 0 deletions
39
src/test/java/com/univocity/parsers/issues/github/Github_447.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,39 @@ | ||
package com.univocity.parsers.issues.github; | ||
|
||
import com.univocity.parsers.fixed.*; | ||
import org.testng.annotations.*; | ||
|
||
import java.io.*; | ||
|
||
import static org.testng.Assert.*; | ||
|
||
|
||
/** | ||
* From: https://github.com/univocity/univocity-parsers/issues/447 | ||
* | ||
* @author Univocity Software Pty Ltd - <a href="mailto:[email protected]">[email protected]</a> | ||
*/ | ||
public class Github_447 { | ||
|
||
@Test | ||
public void parseCSV() { | ||
String input = "" + | ||
"#\n" + | ||
"# underscores are used as the padding character, so leading/trailing whitespace can be considered part of the value\n" + | ||
"#\n" + | ||
"#4 5 40 40 8"; | ||
|
||
final FixedWidthParserSettings settings = new FixedWidthParserSettings(new FixedWidthFields(4, 5, 40, 40, 8)); | ||
settings.setCommentCollectionEnabled(true, true); | ||
settings.getFormat().setComment('#'); | ||
settings.getFormat().setNormalizedNewline('\n'); | ||
settings.getFormat().setLineSeparator("\n"); | ||
settings.setHeaderExtractionEnabled(true); | ||
|
||
final FixedWidthParser parser = new FixedWidthParser(settings); | ||
parser.parse(new StringReader(input)); | ||
|
||
assertEquals(parser.getContext().comments().size(), 4); | ||
|
||
} | ||
} |