Package org.apache.regexp
Class RETest
java.lang.Object
org.apache.regexp.RETest
Data driven (and optionally interactive) testing harness to exercise regular
expression compiler and matching engine.
- Version:
- $Id: RETest.java 518156 2007-03-14 14:31:26Z vgritsenko $
- Author:
- Jonathan Locke, Jon S. Stevens, Michael McCallum
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final REDebugCompiler(package private) int(package private) static final String(package private) static final boolean(package private) int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertEquals(String message, int expected, int actual) voidassertEquals(String message, String expected, String actual) (package private) voidExit with a fatal error.(package private) voidFail with an error.(package private) voidfail(StringBuffer log, String s) Fail with an error.private StringFinds next test description in a given script.private booleangetExpectedResult(String yesno) Converts yesno string to boolean.private RETestCaseCreates testcase for the next test description in the script file.static voidMain program entrypoint.(package private) voidrunAutomatedTests(String testDocument) Run automated tests in RETest.txt file (from Perl 4.0 test battery)(package private) voidrunInteractiveTests(String expr) Compile and test matching against a single expression(package private) voidSay something to standard out(package private) voidshowParens(RE r) Dump parenthesized subexpressions found by a regular expression matcher objectstatic booleanTesting entrypoint.(package private) voidRun automated unit testprivate voidprivate voidprivate void
-
Field Details
-
showSuccesses
static final boolean showSuccesses- See Also:
-
NEW_LINE
-
compiler
-
testCount
int testCount -
failures
int failures
-
-
Constructor Details
-
RETest
public RETest()Constructor
-
-
Method Details
-
main
Main program entrypoint. If an argument is given, it will be compiled and interactive matching will ensue. If no argument is given, the file RETest.txt will be used as automated testing input.- Parameters:
args- Command line arguments (optional regular expression)
-
test
Testing entrypoint.- Parameters:
args- Command line arguments- Throws:
Exception- thrown in case of error
-
runInteractiveTests
Compile and test matching against a single expression- Parameters:
expr- Expression to compile and test
-
die
Exit with a fatal error.- Parameters:
s- Last famous words before exiting
-
fail
Fail with an error. Will print a big failure message to System.out.- Parameters:
log- Output before failures- Failure description
-
fail
Fail with an error. Will print a big failure message to System.out.- Parameters:
s- Failure description
-
say
Say something to standard out- Parameters:
s- What to say
-
showParens
Dump parenthesized subexpressions found by a regular expression matcher object- Parameters:
r- Matcher object with results to show
-
runAutomatedTests
Run automated tests in RETest.txt file (from Perl 4.0 test battery)- Throws:
Exception- thrown in case of error
-
testOther
Run automated unit test- Throws:
Exception- thrown in case of error
-
testPrecompiledRE
private void testPrecompiledRE() -
testSplitAndGrep
private void testSplitAndGrep() -
testSubst
private void testSubst() -
assertEquals
-
assertEquals
-
getExpectedResult
Converts yesno string to boolean.- Parameters:
yesno- string representation of expected result- Returns:
- true if yesno is "YES", false if yesno is "NO" stops program otherwise.
-
findNextTest
Finds next test description in a given script.- Parameters:
br-BufferedReaderfor a script file- Returns:
- strign tag for next test description
- Throws:
IOException- if some io problems occured
-
getNextTestCase
Creates testcase for the next test description in the script file.- Parameters:
br-BufferedReaderfor script file.- Returns:
- a new tescase or null.
- Throws:
IOException- if some io problems occured
-