Hey all,
I have a function, which I'd like to get under test. However, it's very large and creates a finite state machine. The function looks roughly like:
std::auto_ptr<IFiniteStateMachine> CreateFSM()
{
std::auto_ptr<IFiniteStateMachine> = apFSM( new CFiniteStateMachine() );
std::list<IState*> listStates;
listState.push_back( new CStateFoo( /*params*/ ) );
listState.push_back( new CStateBar( /*params*/ ) );
// etc.
apFSM->AddState( listStates );
// Define the transition table
// 1st param: event received
// 2nd param: current state
// 3rd param: next state
apFSM->AddTransition( "EventA", "StateFoo", "StateBar" );
// etc.
return apFSM;
}
Basically, this function just creates a FSM, states, and transition tables. Each of the individual components (the IFiniteStateMachine and IState classes) are testable.
So my question is: can a function like this be put under test? I'm not sure how you would even verify that this function worked as expected. I could probably divide it up into smaller functions that create states and transitions. However, a function that just created these states also seems rather complicated and hard to test.
Thanks.