1 13 14 package org.netbeans.lib.html.lexer; 15 16 import junit.framework.TestCase; 17 import org.netbeans.api.html.lexer.HTMLTokenId; 18 import org.netbeans.lib.lexer.test.FixedTextDescriptor; 19 import org.netbeans.lib.lexer.test.LexerTestUtilities; 20 import org.netbeans.lib.lexer.test.RandomCharDescriptor; 21 import org.netbeans.lib.lexer.test.RandomModifyDescriptor; 22 import org.netbeans.lib.lexer.test.RandomTextProvider; 23 import org.netbeans.lib.lexer.test.TestRandomModify; 24 25 30 public class HTMLLexerRandomTest extends TestCase { 31 32 public HTMLLexerRandomTest(String testName) { 33 super(testName); 34 } 35 36 protected void setUp() throws java.lang.Exception { 37 LexerTestUtilities.setTesting(true); 39 } 40 41 protected void tearDown() throws java.lang.Exception { 42 } 43 44 public void testRandom() throws Exception { 45 test(0); 46 } 47 48 private void test(long seed) throws Exception { 49 TestRandomModify randomModify = new TestRandomModify(seed); 50 randomModify.setLanguage(HTMLTokenId.language()); 51 52 56 randomModify.insertText(0, "<a>"); 58 randomModify.insertText(2, " "); randomModify.removeText(2, 1); 60 61 randomModify.clearDocument(); 62 63 randomModify.insertText(0, "<body>"); 65 randomModify.insertText(5, " "); randomModify.insertText(6, "bgcolor='red'"); randomModify.clearDocument(); 68 69 FixedTextDescriptor[] fixedTexts = new FixedTextDescriptor[] { 71 FixedTextDescriptor.create("/>", 0.2), 72 }; 73 74 RandomCharDescriptor[] regularChars = new RandomCharDescriptor[] { 75 RandomCharDescriptor.letter(0.2), 76 RandomCharDescriptor.space(0.2), 77 RandomCharDescriptor.lf(0.05), 78 RandomCharDescriptor.chars(new char[] { '<', '>', '=' }, 0.3), 79 }; 80 81 RandomTextProvider regularTextProvider = new RandomTextProvider(regularChars, fixedTexts); 82 83 randomModify.test( 84 new RandomModifyDescriptor[] { 85 new RandomModifyDescriptor(200, regularTextProvider, 86 0.4, 0.2, 0.2, 87 0.1, 0.1, 88 0.0, 0.0), new RandomModifyDescriptor(200, regularTextProvider, 90 0.2, 0.2, 0.1, 91 0.4, 0.3, 92 0.0, 0.0), } 94 ); 95 } 96 97 } 98 | Popular Tags |