super(name);
}
public void testHasMoreTokens()
{
CSVTokenizer tokeniser = new CSVTokenizer("", CSVTokenizer.SEPARATOR_COMMA,
CSVTokenizer.DOUBLE_QUATE);
assertTrue("Should have no more tokens.", (!tokeniser.hasMoreTokens()));
tokeniser = new CSVTokenizer("a,b,c", CSVTokenizer.SEPARATOR_COMMA,
CSVTokenizer.DOUBLE_QUATE);
assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
assertEquals("a", tokeniser.nextToken());
assertEquals("b", tokeniser.nextToken());
assertEquals("c", tokeniser.nextToken());
tokeniser = new CSVTokenizer(",b,c", CSVTokenizer.SEPARATOR_COMMA,
CSVTokenizer.DOUBLE_QUATE);
assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
assertEquals("", tokeniser.nextToken());
assertEquals("b", tokeniser.nextToken());
assertEquals("c", tokeniser.nextToken());
tokeniser = new CSVTokenizer("a,,c", CSVTokenizer.SEPARATOR_COMMA,
CSVTokenizer.DOUBLE_QUATE);
assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
assertEquals("a", tokeniser.nextToken());
assertEquals("", tokeniser.nextToken());
assertEquals("c", tokeniser.nextToken());
tokeniser = new CSVTokenizer("a,b,", CSVTokenizer.SEPARATOR_COMMA,
CSVTokenizer.DOUBLE_QUATE);
assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
assertEquals("a", tokeniser.nextToken());
assertEquals("b", tokeniser.nextToken());
assertEquals("", tokeniser.nextToken());
tokeniser = new CSVTokenizer(",,", CSVTokenizer.SEPARATOR_COMMA,
CSVTokenizer.DOUBLE_QUATE);
assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
assertEquals("", tokeniser.nextToken());
assertEquals("", tokeniser.nextToken());
assertEquals("", tokeniser.nextToken());
tokeniser = new CSVTokenizer("\"\",\"\",\"\"", CSVTokenizer.SEPARATOR_COMMA,
CSVTokenizer.DOUBLE_QUATE);
assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
assertEquals("", tokeniser.nextToken());
assertEquals("", tokeniser.nextToken());
assertEquals("", tokeniser.nextToken());
}