File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -184,14 +184,26 @@ void MPAutomatonTest::testDFSFSM() {
184
184
fsa.addEdge (*s0, 2 , *s1);
185
185
fsa.addEdge (*s1, 2 , *s2);
186
186
fsa.addEdge (*s2, 2 , *s3);
187
- auto e = fsa.addEdge (*s3, 2 , *s1);
188
187
189
- fsa.setEdgeLabel (e, 5 );
188
+ bool foundCycle = false ;
189
+ FSM::Abstract::SetOfStateRefs statesFound;
190
190
191
- FSM::Abstract::DetectCycle DC (fsa);
192
- bool hasCycle = DC.checkForCycles ();
191
+ FSM::Abstract::DepthFirstSearchLambda DFS (fsa);
193
192
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 );
195
207
}
196
208
}
197
209
You can’t perform that action at this time.
0 commit comments