00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "TestCaseCyclingPunctualActionModeManager_1.h"
00011
#include "../GeneralInclude/CompilerSwitches.h"
00012
#include "../GeneralInclude/ClassId.h"
00013
#include "../GeneralInclude/Constants.h"
00014
#include "../Base/DC_CyclingPunctualActionModeManager.h"
00015
#include "../Base/DC_DummyPunctualAction.h"
00016
#include "../Base/ModeManager.h"
00017
#include "../Event/DC_EventRepository.h"
00018
00019 TestCaseCyclingPunctualActionModeManager_1::TestCaseCyclingPunctualActionModeManager_1(
void) :
00020
TestCaseWithEvtCheck(ID_CYCLINGPUNCTUALACTIONMODEMANAGER*10+1,"
TestCaseCyclingPunctualActionModeManager_1") {
00021
return;
00022 }
00023
00024 void TestCaseCyclingPunctualActionModeManager_1::runTestCase(
void) {
00025
00026
unsigned int nEvt =
getNumberOfEvents();
00027
DC_CyclingPunctualActionModeManager* pMM =
new DC_CyclingPunctualActionModeManager();
00028
00029
00030
if ( pMM->
getClassId() != ID_CYCLINGPUNCTUALACTIONMODEMANAGER)
00031 { setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00032
return;
00033 }
00034
00035
00036
if ( pMM->
isObjectConfigured() ==
CONFIGURED )
00037 { setTestResult(
TEST_FAILURE,
"Wrong configuration status at creation");
00038
return;
00039 }
00040
00041
00042
DC_DummyPunctualAction* list1 =
new DC_DummyPunctualAction[3];
00043 DC_DummyPunctualAction* list2 =
new DC_DummyPunctualAction[2];
00044 DC_DummyPunctualAction* list3 =
new DC_DummyPunctualAction[3];
00045
00046
00047
TD_Mode n = 3;
00048
TD_Mode def = 1;
00049 pMM->
setNumberOfModes(n);
00050 pMM->
setDefaultMode(def);
00051 pMM->
setListLength(0,3);
00052 pMM->
setListLength(1,2);
00053 pMM->
setListLength(2,3);
00054 pMM->
setListItem(0,0,&list1[0]);
00055 pMM->
setListItem(0,1,&list1[1]);
00056 pMM->
setListItem(0,2,&list1[2]);
00057 pMM->
setListItem(1,0,&list2[0]);
00058 pMM->
setListItem(1,1,&list2[1]);
00059 pMM->
setListItem(2,0,&list3[0]);
00060 pMM->
setListItem(2,1,&list3[1]);
00061 pMM->
setListItem(2,2,&list3[2]);
00062 pMM->
reset();
00063
00064
00065
if ( pMM->
isObjectConfigured() !=
CONFIGURED )
00066 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00067
return;
00068 }
00069
00070
00071
int i = 0;
00072
for (pMM->
first(); !pMM->
isIterationFinished(); pMM->
next()) {
00073
PunctualAction* a = pMM->
getIterationPunctualAction();
00074
if ( (a) != &list2[i] )
00075 { setTestResult(
TEST_FAILURE,
"Error during iteration");
00076
return;
00077 }
00078 i++;
00079 }
00080
if ( i != 2 )
00081 { setTestResult(
TEST_FAILURE,
"Wrong number of iteration cycles");
00082
return;
00083 }
00084
00085
00086 pMM->
next();
00087
if ( &list2[1]!=(pMM->
getIterationPunctualAction()) )
00088 { setTestResult(
TEST_FAILURE,
"Error after non-nominal call to nextInt()");
00089
return;
00090 }
00091
00092
00093 pMM->
update();
00094
if ( pMM->
getCurrentMode()!=def+1 )
00095 { setTestResult(
TEST_FAILURE,
"Wrong mode");
00096
return;
00097 }
00098
00099 pMM->
first();
00100
PunctualAction* item = pMM->
getIterationPunctualAction();
00101
if ( (item) != &list3[0] )
00102 { setTestResult(
TEST_FAILURE,
"Error during iteration");
00103
return;
00104 }
00105
00106 pMM->
update();
00107
if ( pMM->
getCurrentMode()!=0 )
00108 { setTestResult(
TEST_FAILURE,
"Wrong mode");
00109
return;
00110 }
00111
00112 pMM->
next();
00113 item = pMM->
getIterationPunctualAction();
00114
if ( (item) != &list3[1] )
00115 { setTestResult(
TEST_FAILURE,
"Error during iteration");
00116
return;
00117 }
00118
00119
00120
if (
isNonNominalCheckAllowed()) {
00121 pMM->
setListItem(1,2,&list2[1]);
00122
if (verifyLatestEvent(nEvt+1,EVT_ILLEGAL_MM))
00123
return;
00124 nEvt++;
00125 }
00126
00127 setTestResult(
TEST_SUCCESS,
"Test Successful");
00128
return;
00129 }