appkit  1.5.1
RoadNarrows Robotics Application Kit
State Machine Tests

Fine-grained testing of the StateMach, State, StateKb, and StateEvent classes. More...

Classes

class  StateEventStart
 Start state event class. More...
 
class  StateEventRestart
 Restart state event class. More...
 
class  StateEventPauseResume
 Pause/resume state event class. More...
 
class  StateEventTerminate
 Terminate state event class. More...
 
class  State2_3Turing
 The (2,3) Turing state base class. More...
 
class  StateStart
 Start state event class. More...
 
class  StateEventASym0
 (2,3) Turing Machine's state A, symbol 0 event. More...
 
class  StateEventASym1
 (2,3) Turing Machine's state A, symbol 1 event. More...
 
class  StateEventASym2
 (2,3) Turing Machine's state A, symbol 2 event. More...
 
class  StateA
 (2,3) Turing Machine's state A. More...
 
class  StateEventBSym0
 (2,3) Turing Machine's state B, symbol 0 event. More...
 
class  StateEventBSym1
 (2,3) Turing Machine's state B, symbol 1 event. More...
 
class  StateEventBSym2
 (2,3) Turing Machine's state B, symbol 2 event. More...
 
class  StateB
 (2,3) Turing Machine's state B. More...
 

Functions

static int testSM ()
 Test State Machine. More...
 
 TEST (SM, SM2_3Turing)
 Test State Machine class. More...
 

Variables

static const int StateIdA = State::StateIdNumOf
 state A
 
static const int StateIdB = State::StateIdNumOf + 1
 state B
 
static const int EventIdPauseResume = 'p'
 pause/resume event id
 
static const int EventIdTerminate = 'q'
 terminate event id
 
static const int EventIdRestart = 'r'
 restart event id
 
static const int EventIdStart = 's'
 start event id
 
static const int EventIdSymbol [] = {' ', '@', '#'}
 tape symbol event ids
 
static const char * ColorHead = "\033[0;31m"
 color tape head
 
static const char * ColorSymbol [] = {"", "\033[0;33m", "\033[0;35m"}
 color of symbols
 
static const char * ColorEnd [] = {"", "\033[0m", "\033[0m"}
 end color
 
static const uint_t TRead = 500000
 read tape time interval
 
static const char * TestMenu
 Test menu. More...
 
static vector< int > State2_3Turing::Tape
 the tape of symbols More...
 
static int State2_3Turing::Head
 the tape read/write head
 

Detailed Description

Fine-grained testing of the StateMach, State, StateKb, and StateEvent classes.

Function Documentation

TEST ( SM  ,
SM2_3Turing   
)

Test State Machine class.

The Test:
Construct a (2,3) Turing State Machin and run.

Definition at line 838 of file ut-sm.cxx.

References testSM().

839 {
840  EXPECT_TRUE( testSM() == 0 );
841 }
static int testSM()
Test State Machine.
Definition: ut-sm.cxx:809
static int testSM ( )
static

Test State Machine.

(2,3) Turing Machine:
The 2-state 3-color(symbol) Turing machine (hereinafter (2,3) Turing machine) might be universal as well.

See http://en.wikipedia.org/wiki/Wolfram%27s_2-state_3-symbol_Turing_machine
Returns
Returns 0 if test succeeds, else returns < 0.

Definition at line 809 of file ut-sm.cxx.

References TestMenu.

Referenced by TEST().

810 {
811  // manually set rnr log level
812  //LOG_SET_THRESHOLD(LOG_LEVEL_DIAG3);
813 
814  State *listOfStates[] = {new StateStart(), new StateA(), new StateB(), NULL};
815 
816  StateMach sm(0, "(2,3)Turing", State::StateIdStart, listOfStates);
817 
818  sm.printStateMach();
819 
820  printf("%s", TestMenu);
821 
822  sm.run();
823 
824  LOG_SET_THRESHOLD(LOG_LEVEL_OFF);
825 
826  return 0;
827 }
(2,3) Turing Machine&#39;s state B.
Definition: ut-sm.cxx:747
Start state event class.
Definition: ut-sm.cxx:354
static const char * TestMenu
Test menu.
Definition: ut-sm.cxx:102
(2,3) Turing Machine&#39;s state A.
Definition: ut-sm.cxx:556

Variable Documentation

vector< int > State2_3Turing::Tape
static

the tape of symbols

tape of symbols

Definition at line 242 of file ut-sm.cxx.

Referenced by State2_3Turing::showTape().

const char* TestMenu
static
Initial value:
=
"\nTest Menu\n"
" 'p' pause/resume state machine\n"
" 'q' quite (terminate) state machine\n"
" 'r' restart state machine\n"
" 's' start state machine\n"

Test menu.

Definition at line 102 of file ut-sm.cxx.

Referenced by StateEventRestart::execAction(), testCameraCv(), testCameraGst(), and testSM().