1 package jester.tests; 2 3 import jester.*; 4 import junit.framework.TestCase; 5 6 public class IgnoreListDocumentTest extends TestCase { 7 public IgnoreListDocumentTest(String arg0) { 8 super(arg0); 9 } 10 11 public static void main(String [] args) { 12 junit.awtui.TestRunner.run(IgnoreListDocumentTest.class); 13 } 14 15 public void testTextIsIgnored() throws ConfigurationException{ 16 IgnoreList ignoreList = new IgnoreList("%/*%*/"); 17 String source = "mary had a /*little*/ lamb"; 18 IgnoreListDocument document = new IgnoreListDocument(source, ignoreList); 19 20 assertEquals(source.indexOf("lamb"), document.indexOf("l",0)); 21 } 22 23 public void testTextIsIgnoredForMultipleIgnores() throws ConfigurationException{ 24 IgnoreList ignoreList = new IgnoreList("%/*%*/\n%//start%//end"); 25 String source = "mary had a /*little*/ lamb, //start she eat it //end with mint sauce"; 26 IgnoreListDocument document = new IgnoreListDocument(source, ignoreList); 27 28 assertEquals("didn't ignore /* */ region",source.indexOf("lamb"), document.indexOf("l",0)); 29 assertEquals("didn't ignore //start //end region",source.indexOf("th mint"), document.indexOf("t",0)); 30 } 31 32 public void testCharAtReturnsSpaceInsideIgnoreRegion() throws ConfigurationException{ 33 IgnoreList ignoreList = new IgnoreList("%/*%*/"); 34 String source = "mary had a /*little*/ lamb"; 35 IgnoreListDocument document = new IgnoreListDocument(source, ignoreList); 36 37 assertEquals(' ', document.charAt(source.indexOf('l'))); 38 } 39 } 40 | Popular Tags |