1 10 package com.hp.hpl.jena.util.test; 11 12 import com.hp.hpl.jena.util.Tokenizer; 13 14 import junit.framework.TestCase; 15 import junit.framework.TestSuite; 16 17 23 public class TestTokenizer extends TestCase { 24 25 28 public TestTokenizer( String name ) { 29 super( name ); 30 } 31 32 36 public static TestSuite suite() { 37 return new TestSuite( TestTokenizer.class ); 38 } 39 40 43 public void testTokenizer() { 44 Tokenizer tokenizer = new Tokenizer("a(foo,bar) 'i am a literal' so there", "()[], \t\n\r'", "'", true); 45 assertEquals(tokenizer.nextToken(), "a"); 46 assertEquals(tokenizer.nextToken(), "("); 47 assertEquals(tokenizer.nextToken(), "foo"); 48 assertEquals(tokenizer.nextToken(), ","); 49 assertEquals(tokenizer.nextToken(), "bar"); 50 assertEquals(tokenizer.nextToken(), ")"); 51 assertEquals(tokenizer.nextToken(), " "); 52 assertEquals(tokenizer.nextToken(), " "); 53 assertEquals(tokenizer.nextToken(), "'"); 54 assertEquals(tokenizer.nextToken(), "i am a literal"); 55 assertEquals(tokenizer.nextToken(), "'"); 56 assertEquals(tokenizer.nextToken(), " "); 57 assertEquals(tokenizer.nextToken(), "so"); 58 assertEquals(tokenizer.nextToken(), " "); 59 assertEquals(tokenizer.nextToken(), "there"); 60 assertTrue( ! tokenizer.hasMoreTokens()); 61 62 tokenizer = new Tokenizer("a(foo,bar) 'i am a literal' so there", "()[], \t\n\r'", "'", false); 63 assertEquals(tokenizer.nextToken(), "a"); 64 assertEquals(tokenizer.nextToken(), "foo"); 65 assertEquals(tokenizer.nextToken(), "bar"); 66 assertEquals(tokenizer.nextToken(), "i am a literal"); 67 assertEquals(tokenizer.nextToken(), "so"); 68 assertEquals(tokenizer.nextToken(), "there"); 69 assertTrue( ! tokenizer.hasMoreTokens()); 70 71 } 72 73 74 } 75 76 77 | Popular Tags |