|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
lp.parse.LpParserTest
public class LpParserTest
Contains tests of the LpParser class.
LpParser| Field Summary | |
|---|---|
protected LpParser |
parser
The LpParser instance used in the tests. |
protected LpBuffer |
printer
The printer used in the tests. |
private LpRule |
rule1
A container for the rule constructed by getRule1(). |
private LpRule |
rule2
A container for the rule constructed by getRule2(). |
| Constructor Summary | |
|---|---|
LpParserTest(String testName)
A default test case constructor. |
|
| Method Summary | |
|---|---|
protected void |
doRulesFromFileTest(String filename)
Parses rules from a file and checks that they are what they should be (through the LpAbstractStructureUnit.toString() method) |
private void |
doTestException(String source,
LpParserException expected)
Checks that an LpParser instance actually throws the specified
LpParserException on the given source. |
protected LpRule |
getRule1()
Returns a rule corresponding to the string a <- b, not c. |
protected LpRule |
getRule2()
Returns a rule corresponding to the string human(X) :- lives(X), not colour(green, X), not assert(rule(dead(X))). |
void |
testBothRules()
Tests the parser on an input containing the rules returned by getRule1() and getRule2(). |
void |
testExceptions()
Tests exceptions thrown by LpParser. |
void |
testInvalidRule()
Tests the parser on a ":- ." rule -- a constraint with no literal in its body. |
void |
testNormalRule()
Tests the parser on an input containing the rule returned by getRule2(). |
void |
testPropositionalRule()
Tests the parser on an input containing the rule returned by getRule1(). |
void |
testRulesFromFile()
Parses rules from a file and checks that they are what they should be (through the LpBuffer instance) |
void |
testSetInputExceptions()
Tests the parser on null input (a IllegalArgumentException should
be thrown). |
| Methods inherited from class junit.framework.TestCase |
|---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString |
| Methods inherited from class junit.framework.Assert |
|---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private LpRule rule1
getRule1().
private LpRule rule2
getRule2().
protected LpParser parser
LpParser instance used in the tests.
protected LpBuffer printer
| Constructor Detail |
|---|
public LpParserTest(String testName)
testName - the name of the test case| Method Detail |
|---|
public void testSetInputExceptions()
IllegalArgumentException should
be thrown).
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)protected LpRule getRule1()
a <- b, not c.
protected LpRule getRule2()
human(X) :- lives(X), not colour(green, X), not assert(rule(dead(X))).
public void testPropositionalRule()
getRule1().
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)
if - a LpParserException is thrown while parsing the input
(should never happen)public void testNormalRule()
getRule2().
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)
if - a LpParserException is thrown while parsing the input
(should never happen)public void testBothRules()
getRule1() and getRule2().
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)
if - a LpParserException is thrown while parsing the input
(should never happen)
public void testRulesFromFile()
throws IOException
LpBuffer instance)
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)
if - a LpParserException is thrown while parsing the input
(should never happen)
protected void doRulesFromFileTest(String filename)
throws IOException
LpAbstractStructureUnit.toString() method)
filename - path to the text file with rules
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)
if - a LpParserException is thrown while parsing the input
(should never happen)public void testExceptions()
LpParser.
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)public void testInvalidRule()
LpParserException is expected to be thrown
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)
private void doTestException(String source,
LpParserException expected)
LpParser instance actually throws the specified
LpParserException on the given source.
source - the given sourceexpected - the exception to be thrown
IOException - (wrapped in an ExceptionAdapter) if
an I/O exception occurs while parsing the input (should never happen)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||