예제 #1
0
  public void testQuoted() throws ParseException {

    TokenizerType test = new TokenizerType();
    test.setText("a,'b,c'");
    test.setQuote('\'');

    String[] result = test.parse();

    assertEquals("a", result[0]);
    assertEquals("b,c", result[1]);
  }
예제 #2
0
  public void testSimpleCSV() throws ParseException {

    TokenizerType test = new TokenizerType();
    test.setText("a, b, c");

    String[] result = test.parse();

    assertEquals("a", result[0]);
    assertEquals("b", result[1]);
    assertEquals("c", result[2]);
  }
예제 #3
0
  public void testTabDelimited() throws ParseException {

    TokenizerType test = new TokenizerType();
    test.setText("a\tb\tc");
    test.setDelimiter("\t");

    String[] result = test.parse();

    assertEquals("a", result[0]);
    assertEquals("b", result[1]);
    assertEquals("c", result[2]);
  }
예제 #4
0
  public void testRegexpDelimited() throws ParseException {

    TokenizerType test = new TokenizerType();
    test.setText("a,b;c");
    test.setDelimiter("(,|;)");
    test.setRegexp(true);

    String[] result = test.parse();

    assertEquals("a", result[0]);
    assertEquals("b", result[1]);
    assertEquals("c", result[2]);
  }