CSVSniffer { List<CSVResult> sniff(Reader reader) throws IOException { if (! reader.markSupported()) { reader = new BufferedReader(reader); } List<CSVResult> ret = new ArrayList<>(); for (char delimiter : delimiters) { reader.mark(markLimit); try { CSVResult result = new Snifflet(delimiter).sniff(reader); ret.add(result); } finally { reader.reset(); } } Collections.sort(ret); return ret; } CSVSniffer(char[] delimiters);   CSVSniffer(int markLimit, char[] delimiters, double minConfidence);   }
@Test public void testCSVBasic() throws Exception { List<CSVResult> results = sniff(DELIMITERS, CSV_BASIC, StandardCharsets.UTF_8); assertEquals(2, results.size()); assertEquals(new Character(','), results.get(0).getDelimiter()); results = sniff(DELIMITERS, TSV_BASIC, StandardCharsets.UTF_8); assertEquals(2, results.size()); assertEquals(new Character('\t'), results.get(0).getDelimiter()); }
@Test public void testCSVMidCellQuoteException() throws Exception { List<CSVResult> results = sniff(DELIMITERS, CSV_MID_CELL_QUOTE_EXCEPTION, StandardCharsets.UTF_8); assertEquals(2, results.size()); }
@Test public void testAllowWhiteSpacesAroundAQuote() throws Exception { List<CSVResult> results = sniff(DELIMITERS, ALLOW_SPACES_BEFORE_QUOTE, StandardCharsets.UTF_8); assertEquals(2, results.size()); assertEquals(new Character(','), results.get(0).getDelimiter()); results = sniff(DELIMITERS, ALLOW_SPACES_AFTER_QUOTE, StandardCharsets.UTF_8); assertEquals(2, results.size()); assertEquals(new Character(','), results.get(0).getDelimiter()); }