QuotedStringTokenizerTestpublic class QuotedStringTokenizerTest extends TestCase Depends on junit.jar, admin-core/util.jsr |
Methods Summary |
---|
void | _countTokens(java.lang.String s, int expCount)
QuotedStringTokenizer tok = new QuotedStringTokenizer(s, null);
Assert.assertEquals(expCount, tok.countTokens());
| public static void | main(java.lang.String[] args)
junit.textui.TestRunner.run(suite());
//junit.swingui.TestRunner.run(suite());
| protected void | setUp()
| public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(QuotedStringTokenizerTest.class);
return suite;
| protected void | tearDown()
| public void | testCountTokens()
_countTokens("", 0);
_countTokens(" ", 0);
_countTokens(" ", 0);
_countTokens("a", 1);
_countTokens(" a", 1);
_countTokens(" a ", 1);
_countTokens(" a ", 1);
_countTokens(" ab ", 1);
_countTokens(" a b ", 2);
| public void | testCountTokensWithQuotes()
_countTokens("\"a\"", 1);
_countTokens("\"a b\"", 1);
_countTokens(" \"a\" ", 1);
_countTokens("\"", 1);
_countTokens("\"\"", 1);
_countTokens("\" \"", 1);
_countTokens("\"a\"b", 1);
_countTokens("\"a\" b", 2);
_countTokens("\"a\" \"b\"", 2);
_countTokens("\"a\"\"b\"", 1);
_countTokens("\" ", 1);
| public void | testCreate()
new QuotedStringTokenizer("");
new QuotedStringTokenizer("a");
try {
new QuotedStringTokenizer(null);
Assert.assertTrue(false);
} catch (IllegalArgumentException iae) {}
| public void | testIsDelimiter()
QuotedStringTokenizer tok = new QuotedStringTokenizer("");
Assert.assertTrue(tok.isDelimiter('\t"));
| public void | testJavaStringTokenizer()
StringTokenizer tok = new StringTokenizer("\" ", " ");
Assert.assertEquals("\"", tok.nextToken());
tok = new StringTokenizer("a", "\"");
Assert.assertEquals("a", tok.nextToken());
tok = new StringTokenizer("\"\"", "\" ");
Assert.assertEquals(0, tok.countTokens());
tok = new StringTokenizer("\t\"\t", "\" ");
Assert.assertEquals(2, tok.countTokens());
| public void | testNextToken1()
QuotedStringTokenizer tok = new QuotedStringTokenizer("a");
Assert.assertTrue(tok.hasMoreTokens());
Assert.assertEquals("a", tok.nextToken());
Assert.assertFalse(tok.hasMoreTokens());
try {
tok.nextToken();
Assert.assertTrue(false);
} catch (java.util.NoSuchElementException nsee) {}
| public void | testNextToken2()
QuotedStringTokenizer tok = new QuotedStringTokenizer("");
Assert.assertFalse(tok.hasMoreTokens());
try {
tok.nextToken();
Assert.assertTrue(false);
} catch (java.util.NoSuchElementException nsee) {}
| public void | testNextToken3()
QuotedStringTokenizer tok = new QuotedStringTokenizer("a b c d e f");
Assert.assertTrue(tok.countTokens() == 6);
tok.nextToken();
Assert.assertEquals("b", tok.nextToken());
Assert.assertTrue(tok.hasMoreTokens());
while (tok.hasMoreTokens())
tok.nextToken();
try {
tok.nextToken();
Assert.assertTrue(false);
} catch (java.util.NoSuchElementException nsee) {}
| public void | testNextToken4()
QuotedStringTokenizer tok = new QuotedStringTokenizer("abcdef");
Assert.assertTrue(tok.countTokens() == 1);
Assert.assertEquals("abcdef", tok.nextToken());
tok = new QuotedStringTokenizer(" abcdef g ");
Assert.assertTrue(tok.countTokens() == 2);
Assert.assertEquals("abcdef", tok.nextToken());
Assert.assertEquals("g", tok.nextToken());
| public void | testNextToken5()
QuotedStringTokenizer tok = new QuotedStringTokenizer("abc \t d \t\t ef");
Assert.assertEquals(3, tok.countTokens());
Assert.assertEquals("abc", tok.nextToken());
Assert.assertEquals("d", tok.nextToken());
Assert.assertEquals("ef", tok.nextToken());
| public void | testNextTokenWithQuotes()
QuotedStringTokenizer mtok = new QuotedStringTokenizer("\"\"");
Assert.assertEquals("\"\"", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer("\"");
Assert.assertEquals("\"", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
//??
mtok = new QuotedStringTokenizer("\" ");
Assert.assertEquals("\" ", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
//??
mtok = new QuotedStringTokenizer(" \" ");
Assert.assertEquals("\" ", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer("\t\"\t");
Assert.assertEquals("\"\t", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer("\"a\"");
Assert.assertEquals("\"a\"", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer(" \"a\" ");
Assert.assertEquals("\"a\"", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer("\"a");
Assert.assertEquals("\"a", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer("\"a\" \"b\"");
Assert.assertEquals("\"a\"", mtok.nextToken());
Assert.assertEquals("\"b\"", mtok.nextToken());
mtok = new QuotedStringTokenizer("\"a\"b");
Assert.assertEquals("\"a\"b", mtok.nextToken());
//??
mtok = new QuotedStringTokenizer("\"a ");
Assert.assertEquals("\"a ", mtok.nextToken());
mtok = new QuotedStringTokenizer("\"a b\"");
Assert.assertEquals(1, mtok.countTokens());
Assert.assertEquals("\"a b\"", mtok.nextToken());
| public void | testQuotesInQuotes()
QuotedStringTokenizer tok = new QuotedStringTokenizer("\"abc\"def g");
Assert.assertEquals("\"abc\"def", tok.nextToken());
Assert.assertEquals("g", tok.nextToken());
tok = new QuotedStringTokenizer("\"abc\"def\"");
Assert.assertEquals("\"abc\"def\"", tok.nextToken());
tok = new QuotedStringTokenizer(" \"abc\"def\" ");
Assert.assertEquals("\"abc\"def\" ", tok.nextToken());
| public void | testWithQuoteAsDelimiter()
QuotedStringTokenizer mtok = new QuotedStringTokenizer("\"\"", "\" ");
Assert.assertEquals(0, mtok.countTokens());
mtok = new QuotedStringTokenizer("\"", "\" ");
Assert.assertEquals(0, mtok.countTokens());
mtok = new QuotedStringTokenizer("\" ", "\" ");
Assert.assertEquals(0, mtok.countTokens());
mtok = new QuotedStringTokenizer(" \" ", "\" ");
Assert.assertEquals(0, mtok.countTokens());
mtok = new QuotedStringTokenizer("\t\"\t", "\" ");
Assert.assertEquals(2, mtok.countTokens());
mtok = new QuotedStringTokenizer("\"a\"", "\" ");
Assert.assertEquals("a", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer(" \"a\" ", "\" ");
Assert.assertEquals("a", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer("\"a", "\" ");
Assert.assertEquals("a", mtok.nextToken());
Assert.assertFalse(mtok.hasMoreTokens());
mtok = new QuotedStringTokenizer("\"a\" \"b\"", "\" ");
Assert.assertEquals("a", mtok.nextToken());
Assert.assertEquals("b", mtok.nextToken());
mtok = new QuotedStringTokenizer("\"a\"b", "\" ");
Assert.assertEquals("a", mtok.nextToken());
Assert.assertEquals("b", mtok.nextToken());
mtok = new QuotedStringTokenizer("ab", "\" ");
Assert.assertEquals("ab", mtok.nextToken());
|
|