Skip to content

Commit c8ef033

Browse files
committed
added test
1 parent 2290f46 commit c8ef033

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/testbench/graph/mpautomatontest.cc

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,26 @@ void MPAutomatonTest::testDFSFSM() {
184184
fsa.addEdge(*s0, 2, *s1);
185185
fsa.addEdge(*s1, 2, *s2);
186186
fsa.addEdge(*s2, 2, *s3);
187-
auto e = fsa.addEdge(*s3, 2, *s1);
188187

189-
fsa.setEdgeLabel(e, 5);
188+
bool foundCycle = false;
189+
FSM::Abstract::SetOfStateRefs statesFound;
190190

191-
FSM::Abstract::DetectCycle DC(fsa);
192-
bool hasCycle = DC.checkForCycles();
191+
FSM::Abstract::DepthFirstSearchLambda DFS(fsa);
193192

194-
ASSERT(hasCycle);
193+
DFS.setOnEnterLambda([&statesFound](FSM::Abstract::StateRef s) {
194+
ASSERT(!statesFound.includesState(s));
195+
statesFound.insert(s);
196+
});
197+
DFS.setOnSimpleCycleLambda(
198+
[&foundCycle](const FSM::Abstract::DepthFirstSearch::DfsStack &) {
199+
foundCycle = true;
200+
});
201+
202+
// from all initial states
203+
204+
DFS.DoDepthFirstSearch(s2);
205+
ASSERT(!foundCycle);
206+
ASSERT(statesFound.size() == 2);
195207
}
196208
}
197209

0 commit comments

Comments
 (0)