org.apache.regexp

Class RETest


public class RETest
extends java.lang.Object

Data driven (and optionally interactive) testing harness to exercise regular expression compiler and matching engine.
Version:
$Id: RETest.java 232192 2005-08-12 03:04:07Z vgritsenko $
Authors:
Jonathan Locke
Jon S. Stevens
Michael McCallum

Field Summary

(package private) static String
NEW_LINE
(package private) REDebugCompiler
compiler
(package private) int
failures
(package private) static boolean
showSuccesses
(package private) int
testCount

Constructor Summary

RETest()
Constructor

Method Summary

void
assertEquals(String message, String expected, String actual)
void
assertEquals(String message, int expected, int actual)
(package private) void
die(String s)
Exit with a fatal error.
(package private) void
fail(String s)
Fail with an error.
(package private) void
fail(StringBuffer log, String s)
Fail with an error.
private String
findNextTest(BufferedReader br)
Finds next test description in a given script.
private boolean
getExpectedResult(String yesno)
Converts yesno string to boolean.
private RETestCase
getNextTestCase(BufferedReader br)
Creates testcase for the next test description in the script file.
static void
main(String[] args)
Main program entrypoint.
(package private) void
runAutomatedTests(String testDocument)
Run automated tests in RETest.txt file (from Perl 4.0 test battery)
(package private) void
runInteractiveTests(String expr)
Compile and test matching against a single expression
(package private) void
say(String s)
Say something to standard out
(package private) void
showParens(RE r)
Dump parenthesized subexpressions found by a regular expression matcher object
static boolean
test(String[] args)
Testing entrypoint.
(package private) void
testOther()
Run automated unit test
private void
testPrecompiledRE()
private void
testSplitAndGrep()
private void
testSubst()

Field Details

NEW_LINE

(package private) static final String NEW_LINE

compiler

(package private)  REDebugCompiler compiler

failures

(package private)  int failures

showSuccesses

(package private) static final boolean showSuccesses
Field Value:
false

testCount

(package private)  int testCount

Constructor Details

RETest

public RETest()
Constructor

Method Details

assertEquals

public void assertEquals(String message,
                         String expected,
                         String actual)

assertEquals

public void assertEquals(String message,
                         int expected,
                         int actual)

die

(package private)  void die(String s)
Exit with a fatal error.
Parameters:
s - Last famous words before exiting

fail

(package private)  void fail(String s)
Fail with an error. Will print a big failure message to System.out.
Parameters:
s - Failure description

fail

(package private)  void fail(StringBuffer log,
                             String s)
Fail with an error. Will print a big failure message to System.out.
Parameters:
log - Output before failure
s - Failure description

findNextTest

private String findNextTest(BufferedReader br)
            throws IOException
Finds next test description in a given script.
Parameters:
br - BufferedReader for a script file
Returns:
strign tag for next test description

getExpectedResult

private boolean getExpectedResult(String yesno)
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.

getNextTestCase

private RETestCase getNextTestCase(BufferedReader br)
            throws IOException
Creates testcase for the next test description in the script file.
Parameters:
br - BufferedReader for script file.
Returns:
a new tescase or null.

main

public static void main(String[] args)
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)

runAutomatedTests

(package private)  void runAutomatedTests(String testDocument)
            throws Exception
Run automated tests in RETest.txt file (from Perl 4.0 test battery)

runInteractiveTests

(package private)  void runInteractiveTests(String expr)
Compile and test matching against a single expression
Parameters:
expr - Expression to compile and test

say

(package private)  void say(String s)
Say something to standard out
Parameters:
s - What to say

showParens

(package private)  void showParens(RE r)
Dump parenthesized subexpressions found by a regular expression matcher object
Parameters:
r - Matcher object with results to show

test

public static boolean test(String[] args)
            throws Exception
Testing entrypoint.
Parameters:
args - Command line arguments

testOther

(package private)  void testOther()
            throws Exception
Run automated unit test

testPrecompiledRE

private void testPrecompiledRE()

testSplitAndGrep

private void testSplitAndGrep()

testSubst

private void testSubst()

Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.