lp.trans
Class LpGrounderTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by lp.trans.LpGrounderTest
All Implemented Interfaces:
Test

public class LpGrounderTest
extends TestCase

Contains tests of the LpGrounder class.

Version:
1.0.0
Author:
Martin Slota
See Also:
LpGrounder

Field Summary
private  LpGrounder grounder
          The LpGrounder instance used in the tests.
private  LpLiteral[] litAs
          An array with literals "a(1)" ...
private  LpLiteral litAVar
          A literal "a(X)" used in the tests.
private  LpLiteral litBConst
          A literal "b(x)" used in the tests.
private  LpLiteral[] litBs
          An array with literals "b(1)" ...
private  LpLiteral litBVar
          A literal "b(X)" used in the tests.
private  LpLiteral[] litDs
          An array with literals "b(1)" ...
private  LpLiteral litDVar
          A literal "d(X)" used in the tests.
private  LpLiteral[] litNotAs
          An array with literals "not a(1)" ...
private  LpLiteral litNotAVar
          Literal "not a(X)" used in the tests.
private  LpLiteral[] litNotBs
          An array with literals "not b(1)" ...
private  LpLiteral litNotBVar
          Literal "not b(X)" used in the tests.
 
Constructor Summary
LpGrounderTest(String testName)
          A default test case constructor.
 
Method Summary
private  void doTest(LogicProgram inputProgram, LogicProgram expOutputProgram, GrounderMessage expError, List<GrounderMessage> expWarnings)
          Performs a single call of grounder.ground(inputProgram); and tests if expected output program, error and warnings are extracted from the lparse's output.
 void testErrorFreeInput()
          Tests LpGrounder on an error free input.
 void testInputWithError()
          Tests LpGrounder on an input with a single error and no warnings.
 void testMultipleWarnings()
          Tests LpGrounder on an input with a multiple warnings and no error.
 void testOneWarning()
          Tests LpGrounder on an input with a single warning and no error.
 
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

litAVar

private final LpLiteral litAVar
A literal "a(X)" used in the tests.


litNotAVar

private final LpLiteral litNotAVar
Literal "not a(X)" used in the tests.


litAs

private final LpLiteral[] litAs
An array with literals "a(1)" ... "a(100)" used in the tests.


litNotAs

private final LpLiteral[] litNotAs
An array with literals "not a(1)" ... "not a(100)" used in the tests.


litBConst

private final LpLiteral litBConst
A literal "b(x)" used in the tests.


litBVar

private final LpLiteral litBVar
A literal "b(X)" used in the tests.


litNotBVar

private final LpLiteral litNotBVar
Literal "not b(X)" used in the tests.


litBs

private final LpLiteral[] litBs
An array with literals "b(1)" ... "b(100)" used in the tests.


litNotBs

private final LpLiteral[] litNotBs
An array with literals "not b(1)" ... "not b(100)" used in the tests.


litDVar

private final LpLiteral litDVar
A literal "d(X)" used in the tests.


litDs

private final LpLiteral[] litDs
An array with literals "b(1)" ... "b(100)" used in the tests.


grounder

private final LpGrounder grounder
The LpGrounder instance used in the tests.

Constructor Detail

LpGrounderTest

public LpGrounderTest(String testName)
A default test case constructor.

Parameters:
testName - the name of the test case
Method Detail

testErrorFreeInput

public void testErrorFreeInput()
Tests LpGrounder on an error free input. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testInputWithError

public void testInputWithError()
Tests LpGrounder on an input with a single error and no warnings. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testOneWarning

public void testOneWarning()
Tests LpGrounder on an input with a single warning and no error. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testMultipleWarnings

public void testMultipleWarnings()
Tests LpGrounder on an input with a multiple warnings and no error. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


doTest

private void doTest(LogicProgram inputProgram,
                    LogicProgram expOutputProgram,
                    GrounderMessage expError,
                    List<GrounderMessage> expWarnings)
Performs a single call of
grounder.ground(inputProgram);
and tests if expected output program, error and warnings are extracted from the lparse's output.

Parameters:
inputProgram - the input program to ground
expOutputProgram - the expected output program
expError - the expected lparse error
expWarnings - the expected lparse warnings