4141 */
4242public class CSVParserTest {
4343
44- String code = "a,b,c,d\n "
44+ private static final String CSVINPUT = "a,b,c,d\n "
4545 + " a , b , 1 2 \n "
4646 + "\" foo baar\" , b,\n "
4747 // + " \"foo\n,,\n\"\",,\n\\\"\",d,e\n";
4848 + " \" foo\n ,,\n \" \" ,,\n \" \" \" ,d,e\n " ; // changed to use standard CSV escaping
49- String [][] res = {
49+
50+ private static final String [][] RESULT = {
5051 {"a" , "b" , "c" , "d" },
5152 {"a" , "b" , "1 2" },
5253 {"foo baar" , "b" , "" },
@@ -55,8 +56,8 @@ public class CSVParserTest {
5556
5657 @ Test
5758 public void testGetLine () throws IOException {
58- CSVParser parser = new CSVParser (new StringReader (code ), CSVFormat .DEFAULT .withSurroundingSpacesIgnored (true ));
59- for (String [] re : res ) {
59+ CSVParser parser = new CSVParser (new StringReader (CSVINPUT ), CSVFormat .DEFAULT .withSurroundingSpacesIgnored (true ));
60+ for (String [] re : RESULT ) {
6061 assertArrayEquals (re , parser .getRecord ().values ());
6162 }
6263
@@ -65,12 +66,12 @@ public void testGetLine() throws IOException {
6566
6667 @ Test
6768 public void testGetRecords () throws IOException {
68- CSVParser parser = new CSVParser (new StringReader (code ), CSVFormat .DEFAULT .withSurroundingSpacesIgnored (true ));
69+ CSVParser parser = new CSVParser (new StringReader (CSVINPUT ), CSVFormat .DEFAULT .withSurroundingSpacesIgnored (true ));
6970 List <CSVRecord > records = parser .getRecords ();
70- assertEquals (res .length , records .size ());
71+ assertEquals (RESULT .length , records .size ());
7172 assertTrue (records .size () > 0 );
72- for (int i = 0 ; i < res .length ; i ++) {
73- assertArrayEquals (res [i ], records .get (i ).values ());
73+ for (int i = 0 ; i < RESULT .length ; i ++) {
74+ assertArrayEquals (RESULT [i ], records .get (i ).values ());
7475 }
7576 }
7677
@@ -331,7 +332,7 @@ public void testDefaultFormat() throws IOException {
331332 String code = ""
332333 + "a,b\n " // 1)
333334 + "\" \n \" ,\" \" \n " // 2)
334- + "\" \" ,#\n " // 2 )
335+ + "\" \" ,#\n " // 3 )
335336 ;
336337 String [][] res = {
337338 {"a" , "b" },
0 commit comments