lp.parse
Class LpLexerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by lp.parse.LpLexerTest
All Implemented Interfaces:
Test
Direct Known Subclasses:
LpLookaheadLexerTest

public class LpLexerTest
extends TestCase

Contains tests of the LpLexer class.

Version:
1.0.0
Author:
Martin Slota
See Also:
LpLexer

Field Summary
protected  LpLexer lexer
           
 
Constructor Summary
LpLexerTest(String testName)
          A default test case constructor.
 
Method Summary
protected  void doTest(String source, List<LpToken> expectedTokens)
          Uses lexer to tokenize source and compares the results with contents of expectedTokens.
 void testAfterClose()
          Tests the default values the lexer should return after LpLexer.close() is called.
 void testComments()
          Tests the lexer on an input containing some comments.
 void testDefaultValues()
          Tests the default values the lexer should return before LpLexer.nextToken() is called for the first time.
protected  void testEqual(LpToken expected, LpToken actual)
          Tests whether actual is as expected.
protected  void testEqual(LpToken expected, LpTokenType type, String lexem, int lineNumber, int position)
          Tests whether a type, lexem, position and lineNumber are as expected.
 void testSetInputExceptions()
          Tests the lexer on null input (a IllegalArgumentException should be thrown).
 void testTokens()
          Tests the lexer on a more complicated input.
 void testTokensSimple()
          Tests the lexer on an input containing all types of tokens.
 void testWhiteSpace()
          Tests the lexer on an input with lots of whitespace.
 
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

lexer

protected LpLexer lexer
Constructor Detail

LpLexerTest

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

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

testWhiteSpace

public void testWhiteSpace()
Tests the lexer on an input with lots of whitespace.

Throws:
IOException - if an I/O error occurs while reading the input (should never happen)

testComments

public void testComments()
Tests the lexer on an input containing some comments.

Throws:
IOException - if an I/O error occurs while reading the input (should never happen)

testTokensSimple

public void testTokensSimple()
Tests the lexer on an input containing all types of tokens.

Throws:
IOException - if an I/O error occurs while reading the input (should never happen)

testTokens

public void testTokens()
Tests the lexer on a more complicated input.

Throws:
IOException - if an I/O error occurs while reading the input (should never happen)

testDefaultValues

public void testDefaultValues()
Tests the default values the lexer should return before LpLexer.nextToken() is called for the first time.

Throws:
IOException - if an I/O error occurs while reading the input (should never happen)

testAfterClose

public void testAfterClose()
Tests the default values the lexer should return after LpLexer.close() is called.

Throws:
IOException - if an I/O error occurs while reading the input (should never happen)

testSetInputExceptions

public void testSetInputExceptions()
Tests the lexer on null input (a IllegalArgumentException should be thrown).

Throws:
IOException - if an I/O error occurs while reading the input (should never happen)

doTest

protected void doTest(String source,
                      List<LpToken> expectedTokens)
Uses lexer to tokenize source and compares the results with contents of expectedTokens.

Throws:
IOException - (wrapped in an ExceptionAdapter) if an I/O error occurs while reading the input (should never happen)

testEqual

protected void testEqual(LpToken expected,
                         LpToken actual)
Tests whether actual is as expected.

Parameters:
expected - the expected value
actual - the tested LpToken.

testEqual

protected void testEqual(LpToken expected,
                         LpTokenType type,
                         String lexem,
                         int lineNumber,
                         int position)
Tests whether a type, lexem, position and lineNumber are as expected.

Parameters:
expected - a LpToken instance containg the correct values
type - the tested LpTokenType
lexem - the tested lexem
lineNumber - the tested line number
position - the tested position