00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
#include "../GeneralInclude/CompilerSwitches.h"
00019
#include "../GeneralInclude/ClassId.h"
00020
#include "../GeneralInclude/Constants.h"
00021
#include "../Data/ControlBlock.h"
00022
#include "../Data/DC_DummyCopyControlBlock.h"
00023
#include "../Data/DC_ControlList.h"
00024
#include "TestCaseControlList_1.h"
00025
00026
#include <math.h>
00027
#include <float.h>
00028
00029 TestCaseControlList_1::TestCaseControlList_1(
void) :
00030
TestCaseWithEvtCheck(ID_CONTROLLIST*10+1,"
TestCaseControlList_1") {
00031
return;
00032 }
00033
00034 void TestCaseControlList_1::runTestCase(
void) {
00035
DC_ControlList *pCL =
new DC_ControlList;
00036
const unsigned int nEvt =
getNumberOfEvents();
00037
const unsigned int listSize =2;
00038
const unsigned int numInputs =3;
00039
const unsigned int numOutputs =2;
00040
const unsigned int numParameters=2;
00041
DC_DummyCopyControlBlock *pDCB[listSize];
00042
00043
00044
00045
for (
unsigned int i=0;i<listSize;i++) {
00046 pDCB[i]=
new DC_DummyCopyControlBlock;
00047
00048
00049
for (
unsigned int t=0;t<numInputs;t++)
00050 pDCB[i]->
setInput(t,(
TD_Float)1.0);
00051
00052
for (
unsigned int t=0;t<numOutputs;t++)
00053 pDCB[i]->
setOutput(t,(
TD_Float)0.0);
00054
00055
for (
unsigned int t=0;t<numParameters;t++)
00056 pDCB[i]->
setParameter(t,(
TD_Float)1.0);
00057 }
00058
00059
00060
if (pCL->
getClassId()!=ID_CONTROLLIST) {
00061 setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00062
return;
00063 }
00064
00065
00066
if (pCL->
isObjectConfigured()) {
00067 setTestResult(
TEST_FAILURE,
"Newly created object already configured");
00068
return;
00069 }
00070
00071
00072 pCL->
setListSize(listSize);
00073
if (pCL->
getListSize()!=listSize) {
00074 setTestResult(
TEST_FAILURE,
"getListSize() failed");
00075
return;
00076 }
00077
00078
00079
for (
unsigned int i=0;i<listSize;i++) {
00080
00081
if (pCL->
isObjectConfigured()) {
00082 setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00083
return;
00084 }
00085
00086 pCL->
setControlBlock(i,pDCB[i]);
00087
00088
if (pCL->
getControlBlock(i)!=pDCB[i]) {
00089 setTestResult(
TEST_FAILURE,
"setControlBlock() failed");
00090
return;
00091 }
00092 }
00093
00094
00095
if (!pCL->
isObjectConfigured()) {
00096 setTestResult(
TEST_FAILURE,
"Object not configured");
00097
return;
00098 }
00099
00100
00101
00102
if (
isNonNominalCheckAllowed()) {
00103 pCL->
setControlBlock(listSize,pDCB[0]);
00104
if (!verifyLatestEvent(nEvt+1,EVT_ILLEGAL_CL)) {
00105 setTestResult(
TEST_FAILURE,
"Failure of non-nominal behaviour check");
00106
return;
00107 }
00108 }
00109
00110
00111
if (pCL->
execute()!=ACTION_SUCCESS) {
00112 setTestResult(
TEST_FAILURE,
"Wrong execution return code");
00113
return;
00114 }
00115
00116
00117
for (
unsigned int i=0;i<listSize;i++) {
00118
if (fabsf((
float)pDCB[i]->getOutput(0))<=FLT_EPSILON) {
00119 setTestResult(
TEST_FAILURE,
"Control block's propagate() not invoked");
00120
return;
00121 }
00122 }
00123
00124
00125
00126 pCL->
reset();
00127
for (
unsigned int i=0;i<listSize;i++) {
00128
if (fabsf((
float)(pCL->
getControlBlock(i)->
getState(0)-1.0f))>=FLT_EPSILON) {
00129 setTestResult(
TEST_FAILURE,
"Reset failed");
00130
return;
00131 }
00132 }
00133
00134 setTestResult(
TEST_SUCCESS,
"Test Successful");
00135
return;
00136 }