### Question:
CsvParser { public static List<Object> parseCSVLine(String line, String separatorChar) { String regex = "\\G(?:^|" + separatorChar + ")" + "(?:" + "\"" + "((?:[^\"]++|\"\")*+)" + "\"" + "|" + "([^\"" + separatorChar + "]*)" + ")"; Matcher mMain = Pattern.compile(regex).matcher(""); Matcher mQuote = Pattern.compile("\"\"").matcher(""); Matcher mDouble = Pattern.compile(DOUBLE_REGEX_WITH_NAN).matcher(""); List<Object> values = new ArrayList<>(); mMain.reset(line); while (mMain.find()) { Object value; if (mMain.start(2) >= 0) { String field = mMain.group(2); if (mDouble.reset(field).matches()) { value = Double.parseDouble(field); } else { value = field; } } else { value = mQuote.reset(mMain.group(1)).replaceAll("\""); } values.add(value); } return values; } private  CsvParser(String separators, Header header); String getSeparators(); CsvParser withSeparators(String separators); Header getHeader(); CsvParser withHeader(Header header); CsvParserResult parse(Reader reader); static List<Object> parseCSVLine(String line, String separatorChar); static final CsvParser AUTOMATIC; }### Answer:
@Test public void parseCSVLine1() { String line = "\"a\" 1 2.3 \"b\""; List<Object> tokens = CsvParser.parseCSVLine(line, " "); assertThat(tokens, equalTo(Arrays.<Object>asList("a", 1.0, 2.3, "b"))); }
@Test public void parseCSVLine2() { String line = "\"This is a test\" \"Another test\" \"No spaces\" \"Between these two\""; List<Object> tokens = CsvParser.parseCSVLine(line, " "); assertThat(tokens, equalTo(Arrays.<Object>asList("This is a test", "Another test", "No spaces", "Between these two"))); }
@Test public void parseCSVLine3() { String line = "\"And he asked:\"\"Does quoting works?\"\"\""; List<Object> tokens = CsvParser.parseCSVLine(line, " "); assertThat(tokens, equalTo(Arrays.<Object>asList("And he asked:\"Does quoting works?\""))); }
@Test public void parseCSVLine4() { String line = "1 2 3 4"; List<Object> tokens = CsvParser.parseCSVLine(line, " "); assertThat(tokens, equalTo(Arrays.<Object>asList(1.0, 2.0, 3.0, 4.0))); }
@Test public void parseCSVLine5() { String line = "\"Name\" \"Value\" \"Index\"\n"; List<Object> tokens = CsvParser.parseCSVLine(line, " "); assertThat(tokens, equalTo(Arrays.<Object>asList("Name", "Value", "Index"))); }
@Test public void parseCSVLine6() { String line = "\"A\" 0.234 1"; List<Object> tokens = CsvParser.parseCSVLine(line, " "); assertThat(tokens, equalTo(Arrays.<Object>asList("A", 0.234, 1.0))); }
@Test public void parseCSVLine7() { String line = "\"One \nTwo\nThree\""; List<Object> tokens = CsvParser.parseCSVLine(line, " "); assertThat(tokens, equalTo(Arrays.<Object>asList("One \nTwo\nThree"))); }