Class AutomatonTestUtil
java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.automaton.AutomatonTestUtil
Utilities for testing automata.
Capable of generating random regular expressions, and automata, and also provides a number of very basic unoptimized implementations (*slow) for testing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Lets you retrieve random strings accepted by an Automaton. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default maximum number of states thatOperations.determinize(org.apache.lucene.util.automaton.Automaton, int)
should create.static final int
Maximum level of recursion allowed in recursive operations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertCleanDFA
(Automaton automaton) Asserts that an automaton is a DFA with no dead statesstatic void
assertCleanNFA
(Automaton automaton) Asserts that an automaton has no dead statesstatic void
assertMinimalDFA
(Automaton automaton) Asserts that an automaton is a minimal DFA.static void
Checks that an automaton has no detached states that are unreachable from the initial state.static Automaton
Simple, original brics implementation of determinize()static Automaton
determinizeSimple
(Automaton a, Set<Integer> initialset) Simple, original brics implementation of determinize() Determinizes the given automaton using the given set of initial states.getFiniteStringsRecursive
(Automaton a, int limit) Simple, original implementation of getFiniteStrings.static boolean
Returns true if the automaton is deterministic.static boolean
Returns true if the language of this automaton is finite.static Automaton
Simple, original brics implementation of Brzozowski minimize()static Automaton
randomAutomaton
(Random random) return a random NFA/DFA for testingstatic String
Returns random string, including full unicode range.static Automaton
reverseOriginal
(Automaton a, Set<Integer> initialStates) Original brics implementation of reverse().static boolean
sameLanguage
(Automaton a1, Automaton a2) Returns true if these two automata accept exactly the same language.static boolean
Returns true if the language ofa1
is a subset of the language ofa2
.Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail
-
Field Details
-
DEFAULT_MAX_DETERMINIZED_STATES
public static final int DEFAULT_MAX_DETERMINIZED_STATESDefault maximum number of states thatOperations.determinize(org.apache.lucene.util.automaton.Automaton, int)
should create.- See Also:
-
MAX_RECURSION_LEVEL
public static final int MAX_RECURSION_LEVELMaximum level of recursion allowed in recursive operations.- See Also:
-
-
Constructor Details
-
AutomatonTestUtil
public AutomatonTestUtil()
-
-
Method Details
-
randomRegexp
Returns random string, including full unicode range. -
randomAutomaton
return a random NFA/DFA for testing -
reverseOriginal
Original brics implementation of reverse(). It tries to satisfy multiple use-cases by populating a set of initial states too. -
minimizeSimple
Simple, original brics implementation of Brzozowski minimize() -
assertMinimalDFA
Asserts that an automaton is a minimal DFA. -
assertCleanDFA
Asserts that an automaton is a DFA with no dead states -
assertCleanNFA
Asserts that an automaton has no dead states -
determinizeSimple
Simple, original brics implementation of determinize() -
determinizeSimple
Simple, original brics implementation of determinize() Determinizes the given automaton using the given set of initial states. -
getFiniteStringsRecursive
Simple, original implementation of getFiniteStrings.Returns the set of accepted strings, assuming that at most
limit
strings are accepted. If more thanlimit
strings are accepted, the first limit strings found are returned. Iflimit
<0, then the limit is infinite.This implementation is recursive: it uses one stack frame for each digit in the returned strings (ie, max is the max length returned string).
-
isFinite
Returns true if the language of this automaton is finite. The automaton must not have any dead states. -
assertNoDetachedStates
Checks that an automaton has no detached states that are unreachable from the initial state. -
isDeterministicSlow
Returns true if the automaton is deterministic. -
sameLanguage
Returns true if these two automata accept exactly the same language. This is a costly computation! Both automata must be determinized and have no dead states! -
subsetOf
Returns true if the language ofa1
is a subset of the language ofa2
. Both automata must be determinized and must have no dead states.Complexity: quadratic in number of states.
-