laser.regularlanguage.fsa.util.test
Class FSAsTests<L extends LabelInterface>

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by laser.regularlanguage.fsa.util.test.FSAsTests<L>
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
StringDFAsTests, StringFSAsTests

public abstract class FSAsTests<L extends LabelInterface>
extends junit.framework.TestCase

The FSAsTests class tests the FSAs class' methods. There should be a FSAsTests subclass for each FSAs subclass. It is built on the JUnit testing framework.


Field Summary
protected  MutableFSAInterface<L> emptyFSA_
           
protected  MutableFSAInterface<L> epsilonFSA_
           
protected  FSAs<L> fsasInstance_
          The FSAs class being tested
protected  MutableFSAInterface<L> labelFSA_
           
protected  MutableFSAInterface<L> starFSA_
           
 
Constructor Summary
FSAsTests()
           
 
Method Summary
protected abstract  FSAs<L> _createFSAsInstance()
          Creates the appropriate FSAs.
protected  void _setUp()
           
protected abstract  AlphabetInterface<L> createAlphabetInstance()
          Creates a new empty alphabet.
protected abstract  FSAEpsilonTransitionInterface<L> createFSAEpsilonTransitionInstance(MutableFSAInterface<L> fsa, FSAStateInterface<L> source, FSAStateInterface<L> target)
          Creates a new FSAEpsilonTransitionInterface from the given source to the given target within the specified FSA.
protected abstract  FSALabelTransitionInterface<L> createFSALabelTransitionInstance(MutableFSAInterface<L> fsa, FSAStateInterface<L> source, FSAStateInterface<L> target, L l)
          Creates a new FSALabelTransitionInterface from the given source to the given target on the given label within the specified FSA.
protected abstract  FSAStateInterface<L> createFSAStateInstance(MutableFSAInterface<L> fsa)
          Creates a new FSAStateInterface within the given FSA.
protected abstract  L createLabelInstance()
          Creates a new label.
protected abstract  MutableFSAInterface<L> createMutableDFAInstance()
          Creates a new mutable DFA.
protected abstract  MutableFSAInterface<L> createMutableFSAInstance()
          Creates a new mutable FSA.
protected abstract  java.lang.Object[] getCreateArgsForFSA()
          Gets any necessary arguments for the fsa factory method.
protected abstract  java.lang.Object[] getCreateArgsForLabelTransition()
          Gets any necessary arguments for the label transition factory method.
protected abstract  java.lang.Object[] getCreateArgsForState()
          Gets any necessary arguments for the state factory method.
protected  RunnableFSAInterface<L> getRunnableEmptyFSA()
          Returns an empty FSA.
protected  RunnableFSAInterface<L> getRunnableEpsilonFSA()
          Returns an epsilon FSA.
protected  RunnableFSAInterface<L> getRunnableFSA(MutableFSAInterface<L> mFSA)
          Converts from the given mutable FSA into the corresponding runnable FSA.
protected  RunnableFSAInterface<L> getRunnableLabelFSA()
          Returns a label FSA.
protected  RunnableFSAInterface<L> getRunnableStarFSA()
          Returns a star FSA.
protected  void setUp()
           
 void testComplement()
           
 void testComplementDeMorgansLawIntersect()
           
 void testComplementDeMorgansLawUnion()
           
 void testComplementEmptyIsEpsilon()
           
 void testComplementFSAIntersectComplementFSAIsEmpty()
           
 void testComplementFSAIsComplementComplementFSA()
           
 void testComplementFSAUnionComplementFSAIsUniveral()
           
 void testConcatenation()
           
 void testConcatenationDFABecomesNFA()
           
 void testConcatenationEmptyIsEmpty()
           
 void testConcatenationEpsilonIsEquivalent()
           
 void testDeleteUnnecessaryStatesReturnsFalse()
           
 void testDeleteUnnecessaryStatesReturnsTrue()
           
 void testDeterminizeDFA()
           
 void testDeterminizeEpsilonFreeNFA()
           
 void testDeterminizeNFA()
           
 void testDifferenceAsymmetricLabelFSAEmptyFSANotSameAlphabet()
           
 void testDifferenceAsymmetricLabelFSAEmptyFSASameAlphabet()
           
 void testDifferenceAsymmetricLabelFSALabelFSA()
           
 void testDifferenceSymmetricLabelFSAEmptyFSANotSameAlphabet()
           
 void testDifferenceSymmetricLabelFSAEmptyFSASameAlphabet()
           
 void testDifferenceSymmetricLabelFSALabelFSA()
           
 void testInflateDestructiveAlphabetIsEquals()
           
 void testInflateDestructiveAlphabetIsSubset()
           
 void testInflateDestructiveAlphabetIsSuperset()
           
 void testInflateDestructiveNullAlphabet()
           
 void testInflateDestructiveNullFSA()
           
 void testIntersect()
           
 void testIntersectEmptyIsEmpty()
           
 void testIntersectSameIsEquivalent()
           
 void testIsEmptyReturnsFalse()
           
 void testIsEmptyReturnsTrue()
           
 void testIsEqivalentReturnsFalse()
           
 void testIsEqivalentReturnsTrue()
           
 void testMinimizeMinimalFSA()
           
 void testMinimizeNotMinimalFSA()
           
 void testProductAsIntersect()
           
 void testProductEmptyIsEmpty()
           
 void testProductSameIsEquivalent()
           
 void testReplaceLabelsWithEpsilonLabelNotInSigma()
           
 void testReplaceLabelsWithEpsilonLabelTransitions()
           
 void testReplaceLabelsWithEpsilonNotLabelTransitions()
           
 void testReplaceLabelsWithEpsilonNullLabel()
           
 void testReplaceLabelsWithEpsilonNullLabels()
           
 void testReverseDFABecomesNFA()
           
 void testReverseReturnsIsEquivalent()
           
 void testReverseReturnsNotIsEquivalent()
           
 void testStar()
           
 void testStarDFABecomesNFA()
           
 void testStarEmptyIsEpsilon()
           
 void testStarEpsilonIsEquivalent()
           
 void testUnion()
           
 void testUnionEmptyIsEquivalent()
           
 void testUnionSameIsEquivalent()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fsasInstance_

protected FSAs<L extends LabelInterface> fsasInstance_
The FSAs class being tested


emptyFSA_

protected MutableFSAInterface<L extends LabelInterface> emptyFSA_

epsilonFSA_

protected MutableFSAInterface<L extends LabelInterface> epsilonFSA_

labelFSA_

protected MutableFSAInterface<L extends LabelInterface> labelFSA_

starFSA_

protected MutableFSAInterface<L extends LabelInterface> starFSA_
Constructor Detail

FSAsTests

public FSAsTests()
Method Detail

setUp

protected final void setUp()
                    throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

_setUp

protected void _setUp()
               throws java.lang.Exception
Throws:
java.lang.Exception

_createFSAsInstance

protected abstract FSAs<L> _createFSAsInstance()
Creates the appropriate FSAs. POSTCONDITION:

Returns:
The appropriate FSAs

createMutableDFAInstance

protected abstract MutableFSAInterface<L> createMutableDFAInstance()
Creates a new mutable DFA. NOTE: This is an fsa factory method.

POSTCONDITION:

Returns:
A new mutable DFA

createMutableFSAInstance

protected abstract MutableFSAInterface<L> createMutableFSAInstance()
Creates a new mutable FSA. NOTE: This is an fsa factory method.

POSTCONDITION:

Returns:
A new mutable FSA

getCreateArgsForFSA

protected abstract java.lang.Object[] getCreateArgsForFSA()
Gets any necessary arguments for the fsa factory method.

Returns:
Any necessary arguments

getCreateArgsForState

protected abstract java.lang.Object[] getCreateArgsForState()
Gets any necessary arguments for the state factory method.

Returns:
Any necessary arguments

getCreateArgsForLabelTransition

protected abstract java.lang.Object[] getCreateArgsForLabelTransition()
Gets any necessary arguments for the label transition factory method.

Returns:
Any necessary arguments

createAlphabetInstance

protected abstract AlphabetInterface<L> createAlphabetInstance()
Creates a new empty alphabet. NOTE: This is the alphabet factory method.

POSTCONDITIONS:

Returns:
A new empty alphabet

createLabelInstance

protected abstract L createLabelInstance()
Creates a new label. NOTE: This is the label factory method.

POSTCONDITIONS:

Returns:
A new label

createFSAStateInstance

protected abstract FSAStateInterface<L> createFSAStateInstance(MutableFSAInterface<L> fsa)
Creates a new FSAStateInterface within the given FSA. NOTE: This is the state factory method.

POSTCONDITIONS:

Parameters:
fsa - The FSA that will contain the new state
Returns:
The new state

createFSAEpsilonTransitionInstance

protected abstract FSAEpsilonTransitionInterface<L> createFSAEpsilonTransitionInstance(MutableFSAInterface<L> fsa,
                                                                                       FSAStateInterface<L> source,
                                                                                       FSAStateInterface<L> target)
Creates a new FSAEpsilonTransitionInterface from the given source to the given target within the specified FSA. NOTE: This is a transition factory method.

POSTCONDITIONS:

Parameters:
fsa - The FSA that will contain the new epsilon transition
source - The source for the new epsilon transition
target - The target for the new epsilon transition
Returns:
The new epsilon transition

createFSALabelTransitionInstance

protected abstract FSALabelTransitionInterface<L> createFSALabelTransitionInstance(MutableFSAInterface<L> fsa,
                                                                                   FSAStateInterface<L> source,
                                                                                   FSAStateInterface<L> target,
                                                                                   L l)
Creates a new FSALabelTransitionInterface from the given source to the given target on the given label within the specified FSA. NOTE: This is a transition factory method.

POSTCONDITIONS:

Parameters:
fsa - The FSA that will contain the new label transition
source - The source for the new label transition
target - The target for the new label transition
l - The label for the new label transition
Returns:
The new label transition

getRunnableFSA

protected RunnableFSAInterface<L> getRunnableFSA(MutableFSAInterface<L> mFSA)
Converts from the given mutable FSA into the corresponding runnable FSA. PRECONDITIONS:

Parameters:
mFSA - The mutable FSA to be converted
Returns:
The corresponding runnable FSA

getRunnableEmptyFSA

protected RunnableFSAInterface<L> getRunnableEmptyFSA()
Returns an empty FSA. L(emptyFSA) = "No strings are accepted".

Returns:
An empty FSA

getRunnableEpsilonFSA

protected RunnableFSAInterface<L> getRunnableEpsilonFSA()
Returns an epsilon FSA. L(epsilonFSA) = "The empty string is accepted".

Returns:
An epsilon FSA

getRunnableLabelFSA

protected RunnableFSAInterface<L> getRunnableLabelFSA()
Returns a label FSA. L(labelFSA) = "One label occurs".

Returns:
A label FSA

getRunnableStarFSA

protected RunnableFSAInterface<L> getRunnableStarFSA()
Returns a star FSA. L(starFSA) = "Zero or more labels occur".

Returns:
A star FSA

testIsEmptyReturnsFalse

public final void testIsEmptyReturnsFalse()

testIsEmptyReturnsTrue

public final void testIsEmptyReturnsTrue()

testIsEqivalentReturnsFalse

public final void testIsEqivalentReturnsFalse()

testIsEqivalentReturnsTrue

public final void testIsEqivalentReturnsTrue()

testConcatenationEmptyIsEmpty

public final void testConcatenationEmptyIsEmpty()

testConcatenationEpsilonIsEquivalent

public final void testConcatenationEpsilonIsEquivalent()

testConcatenation

public final void testConcatenation()

testConcatenationDFABecomesNFA

public final void testConcatenationDFABecomesNFA()

testUnionEmptyIsEquivalent

public final void testUnionEmptyIsEquivalent()

testUnionSameIsEquivalent

public final void testUnionSameIsEquivalent()

testUnion

public final void testUnion()

testStarEmptyIsEpsilon

public final void testStarEmptyIsEpsilon()

testStarEpsilonIsEquivalent

public final void testStarEpsilonIsEquivalent()

testStar

public final void testStar()

testStarDFABecomesNFA

public final void testStarDFABecomesNFA()

testComplementEmptyIsEpsilon

public final void testComplementEmptyIsEpsilon()

testComplement

public final void testComplement()

testComplementFSAIsComplementComplementFSA

public final void testComplementFSAIsComplementComplementFSA()

testComplementFSAIntersectComplementFSAIsEmpty

public final void testComplementFSAIntersectComplementFSAIsEmpty()

testComplementFSAUnionComplementFSAIsUniveral

public final void testComplementFSAUnionComplementFSAIsUniveral()

testComplementDeMorgansLawIntersect

public final void testComplementDeMorgansLawIntersect()

testComplementDeMorgansLawUnion

public final void testComplementDeMorgansLawUnion()

testDifferenceAsymmetricLabelFSAEmptyFSANotSameAlphabet

public final void testDifferenceAsymmetricLabelFSAEmptyFSANotSameAlphabet()

testDifferenceAsymmetricLabelFSAEmptyFSASameAlphabet

public final void testDifferenceAsymmetricLabelFSAEmptyFSASameAlphabet()

testDifferenceAsymmetricLabelFSALabelFSA

public final void testDifferenceAsymmetricLabelFSALabelFSA()

testDifferenceSymmetricLabelFSAEmptyFSANotSameAlphabet

public final void testDifferenceSymmetricLabelFSAEmptyFSANotSameAlphabet()

testDifferenceSymmetricLabelFSAEmptyFSASameAlphabet

public final void testDifferenceSymmetricLabelFSAEmptyFSASameAlphabet()

testDifferenceSymmetricLabelFSALabelFSA

public final void testDifferenceSymmetricLabelFSALabelFSA()

testIntersectEmptyIsEmpty

public final void testIntersectEmptyIsEmpty()

testIntersectSameIsEquivalent

public final void testIntersectSameIsEquivalent()

testIntersect

public final void testIntersect()

testProductEmptyIsEmpty

public final void testProductEmptyIsEmpty()

testProductSameIsEquivalent

public final void testProductSameIsEquivalent()

testProductAsIntersect

public final void testProductAsIntersect()

testDeleteUnnecessaryStatesReturnsFalse

public final void testDeleteUnnecessaryStatesReturnsFalse()

testDeleteUnnecessaryStatesReturnsTrue

public final void testDeleteUnnecessaryStatesReturnsTrue()

testDeterminizeNFA

public final void testDeterminizeNFA()

testDeterminizeEpsilonFreeNFA

public final void testDeterminizeEpsilonFreeNFA()

testDeterminizeDFA

public final void testDeterminizeDFA()

testInflateDestructiveNullFSA

public final void testInflateDestructiveNullFSA()

testInflateDestructiveNullAlphabet

public final void testInflateDestructiveNullAlphabet()

testInflateDestructiveAlphabetIsSubset

public final void testInflateDestructiveAlphabetIsSubset()

testInflateDestructiveAlphabetIsEquals

public final void testInflateDestructiveAlphabetIsEquals()

testInflateDestructiveAlphabetIsSuperset

public final void testInflateDestructiveAlphabetIsSuperset()

testMinimizeNotMinimalFSA

public final void testMinimizeNotMinimalFSA()

testMinimizeMinimalFSA

public final void testMinimizeMinimalFSA()

testReplaceLabelsWithEpsilonNullLabels

public final void testReplaceLabelsWithEpsilonNullLabels()

testReplaceLabelsWithEpsilonNullLabel

public final void testReplaceLabelsWithEpsilonNullLabel()

testReplaceLabelsWithEpsilonLabelNotInSigma

public final void testReplaceLabelsWithEpsilonLabelNotInSigma()

testReplaceLabelsWithEpsilonNotLabelTransitions

public final void testReplaceLabelsWithEpsilonNotLabelTransitions()

testReplaceLabelsWithEpsilonLabelTransitions

public final void testReplaceLabelsWithEpsilonLabelTransitions()

testReverseReturnsIsEquivalent

public final void testReverseReturnsIsEquivalent()

testReverseReturnsNotIsEquivalent

public final void testReverseReturnsNotIsEquivalent()

testReverseDFABecomesNFA

public final void testReverseDFABecomesNFA()