org.apache.regexp

Class RETest

public class RETest extends Object

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
REDebugCompilercompiler
intfailures
static StringNEW_LINE
static booleanshowSuccesses
inttestCount
Constructor Summary
RETest()
Constructor
Method Summary
voidassertEquals(String message, String expected, String actual)
voidassertEquals(String message, int expected, int actual)
voiddie(String s)
Exit with a fatal error.
voidfail(StringBuffer log, String s)
Fail with an error.
voidfail(String s)
Fail with an error.
StringfindNextTest(BufferedReader br)
Finds next test description in a given script.
booleangetExpectedResult(String yesno)
Converts yesno string to boolean.
RETestCasegetNextTestCase(BufferedReader br)
Creates testcase for the next test description in the script file.
static voidmain(String[] args)
Main program entrypoint.
voidrunAutomatedTests(String testDocument)
Run automated tests in RETest.txt file (from Perl 4.0 test battery)
voidrunInteractiveTests(String expr)
Compile and test matching against a single expression
voidsay(String s)
Say something to standard out
voidshowParens(RE r)
Dump parenthesized subexpressions found by a regular expression matcher object
static booleantest(String[] args)
Testing entrypoint.
voidtestOther()
Run automated unit test
voidtestPrecompiledRE()
voidtestSplitAndGrep()
voidtestSubst()

Field Detail

compiler

final REDebugCompiler compiler

failures

int failures

NEW_LINE

static final String NEW_LINE

showSuccesses

static final boolean showSuccesses

testCount

int testCount

Constructor Detail

RETest

public RETest()
Constructor

Method Detail

assertEquals

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

assertEquals

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

die

void die(String s)
Exit with a fatal error.

Parameters: s Last famous words before exiting

fail

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

fail

void fail(String s)
Fail with an error. Will print a big failure message to System.out.

Parameters: s Failure description

findNextTest

private String findNextTest(BufferedReader br)
Finds next test description in a given script.

Parameters: br BufferedReader for a script file

Returns: strign tag for next test description

Throws: IOException if some io problems occured

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)
Creates testcase for the next test description in the script file.

Parameters: br BufferedReader for script file.

Returns: a new tescase or null.

Throws: IOException if some io problems occured

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

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

Throws: Exception thrown in case of error

runInteractiveTests

void runInteractiveTests(String expr)
Compile and test matching against a single expression

Parameters: expr Expression to compile and test

say

void say(String s)
Say something to standard out

Parameters: s What to say

showParens

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)
Testing entrypoint.

Parameters: args Command line arguments

Throws: Exception thrown in case of error

testOther

void testOther()
Run automated unit test

Throws: Exception thrown in case of error

testPrecompiledRE

private void testPrecompiledRE()

testSplitAndGrep

private void testSplitAndGrep()

testSubst

private void testSubst()
Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.