edu.rice.cs.util.swing
Class FindReplaceMachineTest
java.lang.Object
|
+--junit.framework.Assert
|
+--junit.framework.TestCase
|
+--edu.rice.cs.util.swing.FindReplaceMachineTest
- All Implemented Interfaces:
- Test
- public class FindReplaceMachineTest
- extends TestCase
Test the interactions between double quotes and backslashes.
- Version:
- $Id: FindReplaceMachineTest.java,v 1.5 2002/06/12 18:29:58 jhsia Exp $
Method Summary |
private void |
_assertOffsets(FindReplaceMachine frm,
int start,
int current)
|
private void |
_initFrm(int pos)
|
private void |
_testFindNextFails(FindReplaceMachine frm,
ContinueCommand cont,
int start,
int current)
|
private void |
_testFindNextSucceeds(FindReplaceMachine frm,
ContinueCommand cont,
int start,
int found)
test case no longer applies -- we always wrap
public void testReplaceAllHalt() throws BadLocationException {
doc.insertString(0, EVIL_TEXT, null);
_initFrm(15);
_assertOffsets(frm, 15, 15);
frm.setFindWord("evil");
frm.setReplaceWord("monkey");
frm.replaceAll(HALT);
assertEquals("revised text",
"Hear no evil, see no monkey, speak no monkey.",
doc.getText(0, doc.getLength()));
} |
protected void |
setUp()
Initializes the document for the tests. |
static Test |
suite()
Creates a test suite for JUnit to use. |
void |
testCreateMachineSuccess()
|
void |
testFindNextAndFailIsOnMatch()
|
void |
testFindNextUpdatesCurrent()
|
void |
testFindNoMatchCase()
|
void |
testMultipleCallsToFindNext()
|
void |
testNotInDocument()
// halting tests are obsolete. |
void |
testReplaceAllContinue()
|
void |
testReplaceAllContinueNoMatchCase()
|
void |
testSimpleReplace()
|
void |
testStartFromTopContinue()
|
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, tearDown, toString |
Methods inherited from class junit.framework.Assert |
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
doc
Document doc
frm
FindReplaceMachine frm
EVIL_TEXT
private static final String EVIL_TEXT
CONTINUE
private static ContinueCommand CONTINUE
FindReplaceMachineTest
public FindReplaceMachineTest(String name)
- Constructor.
- Parameters:
name
- a name for the test.
setUp
protected void setUp()
- Initializes the document for the tests.
- Overrides:
setUp
in class TestCase
suite
public static Test suite()
- Creates a test suite for JUnit to use.
- Returns:
- a test suite for JUnit
testCreateMachineSuccess
public void testCreateMachineSuccess()
throws BadLocationException
_initFrm
private void _initFrm(int pos)
testFindNextUpdatesCurrent
public void testFindNextUpdatesCurrent()
throws BadLocationException
testFindNextAndFailIsOnMatch
public void testFindNextAndFailIsOnMatch()
throws BadLocationException
testMultipleCallsToFindNext
public void testMultipleCallsToFindNext()
throws BadLocationException
testStartFromTopContinue
public void testStartFromTopContinue()
throws BadLocationException
testNotInDocument
public void testNotInDocument()
throws BadLocationException
- // halting tests are obsolete. We don't halt anymore. we always wrap.
public void testStartFromTopHalt() throws BadLocationException {
doc.insertString(0, EVIL_TEXT, null);
_initFrm(5);
_assertOffsets(frm, 5, 5);
frm.setFindWord("Hear");
_testFindNextFails(frm, HALT, 5, 5);
}
testSimpleReplace
public void testSimpleReplace()
throws BadLocationException
testReplaceAllContinue
public void testReplaceAllContinue()
throws BadLocationException
testFindNoMatchCase
public void testFindNoMatchCase()
throws BadLocationException
testReplaceAllContinueNoMatchCase
public void testReplaceAllContinueNoMatchCase()
throws BadLocationException
_testFindNextSucceeds
private void _testFindNextSucceeds(FindReplaceMachine frm,
ContinueCommand cont,
int start,
int found)
- test case no longer applies -- we always wrap
public void testReplaceAllHalt() throws BadLocationException {
doc.insertString(0, EVIL_TEXT, null);
_initFrm(15);
_assertOffsets(frm, 15, 15);
frm.setFindWord("evil");
frm.setReplaceWord("monkey");
frm.replaceAll(HALT);
assertEquals("revised text",
"Hear no evil, see no monkey, speak no monkey.",
doc.getText(0, doc.getLength()));
}
_testFindNextFails
private void _testFindNextFails(FindReplaceMachine frm,
ContinueCommand cont,
int start,
int current)
_assertOffsets
private void _assertOffsets(FindReplaceMachine frm,
int start,
int current)