From: <ce...@pr...> - 2004-01-26 04:51:48
|
Update of /cvsroot/csseditor/net.sourceforge.csseditor.tests/src/net/sourceforge/csseditor/tests/internal/text In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6489/src/net/sourceforge/csseditor/tests/internal/text Added Files: CssPartitionScannerTest.java Log Message: Add test case for bug #877547 (Incorrect syntax highlighting for seemingly escaped comments) --- NEW FILE: CssPartitionScannerTest.java --- /* * Copyright (c) 2003 Christopher Lenz and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Christopher Lenz - initial API and implementation * * $Id: CssPartitionScannerTest.java,v 1.1 2004/01/24 22:51:48 cell Exp $ */ package net.sourceforge.csseditor.tests.internal.text; import junit.framework.TestCase; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.rules.IPartitionTokenScanner; import org.eclipse.jface.text.rules.ITokenScanner; import net.sourceforge.csseditor.IProfile; import net.sourceforge.csseditor.internal.text.CssPartitionScanner; import net.sourceforge.csseditor.profiles.Css2Profile; import net.sourceforge.csseditor.text.CssTextTools; /** * Tests for the <code>CssPartitionScanner</code> class. */ public class CssPartitionScannerTest extends TestCase { // Instance Variables ------------------------------------------------------ private IPreferenceStore store; private IProfile profile; // TestCase Implementation ------------------------------------------------- /* * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { profile = new Css2Profile(null); store = new PreferenceStore(); } /* * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { profile = null; store = null; } // Test Methods ------------------------------------------------------------ public void testEmptyCommentDetected() throws Exception { ITokenScanner scanner = prepareScanner("/**/"); //$NON-NLS-1$ assertEquals(CssPartitionScanner.CSS_COMMENT, scanner.nextToken().getData()); } public void testCommentContainingNormalTextDetected() throws Exception { ITokenScanner scanner = prepareScanner("/* test */"); //$NON-NLS-1$ assertEquals(CssPartitionScanner.CSS_COMMENT, scanner.nextToken().getData()); } public void testEscapeInCommentIgnored() throws Exception { ITokenScanner scanner = prepareScanner("/*\\*/"); //$NON-NLS-1$ assertEquals(CssPartitionScanner.CSS_COMMENT, scanner.nextToken().getData()); } // Private Methods --------------------------------------------------------- /** * Creates a new <code>CssParitionScanner</code> instance, and sets its * input to the specified text. * * @param text the input for the scanner * @return the created scanner */ private IPartitionTokenScanner prepareScanner(String text) { CssTextTools tools = new CssTextTools(store, profile); IPartitionTokenScanner scanner = tools.getPartitionScanner(); IDocument document = new Document(text); scanner.setRange(document, 0, document.getLength()); return scanner; } } |