00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "../GeneralInclude/CompilerSwitches.h"
00013
#include "../GeneralInclude/ClassId.h"
00014
#include "../GeneralInclude/Constants.h"
00015
#include "../Data/DC_SampleMonitoredDataPool.h"
00016
#include "../Data/DC_DataItem.h"
00017
#include "../System/DC_DummyObsClock.h"
00018
#include "../FDIR/DC_NullProfile.h"
00019
#include "../FDIR/DC_NullRecoveryAction.h"
00020
#include "TestCaseSampleMonitoredDataPool_1.h"
00021
#include "../Utilities/TestCaseWithEvtCheck.h"
00022
00023
#include <math.h>
00024
#include <float.h>
00025
00026 TestCaseSampleMonitoredDataPool_1::TestCaseSampleMonitoredDataPool_1():
00027
TestCaseWithEvtCheck(ID_SAMPLEMONITOREDDATAPOOL*10+1,"
TestCaseSampleMonitoredDataPool_1") {
00028
return;
00029 }
00030
00031 void TestCaseSampleMonitoredDataPool_1::runTestCase() {
00032
00033
00034
unsigned int nEvt;
00035 nEvt =
getNumberOfEvents();
00036
00037
00038
TD_DataPoolId numberOfPar = 8;
00039
00040
00041
DC_SampleMonitoredDataPool* pDP =
new DC_SampleMonitoredDataPool();
00042
00043
00044
TD_DataPoolId maxParId;
00045 maxParId = 11;
00046
00047
00048
TD_DataPoolId id;
00049
id = 0;
00050
00051
00052
TD_DataPoolId lowestIllegalParId;
00053 lowestIllegalParId = (
TD_DataPoolId)3;
00054
00055
00056
if (pDP->
getClassId() != ID_SAMPLEMONITOREDDATAPOOL)
00057 { setTestResult(
TEST_FAILURE,
"Wrong class ID");
00058
return;
00059 }
00060
00061
00062
00063
if ( !pDP->
isValid(1) )
00064 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 1");
00065
return;
00066 }
00067
00068
if ( !pDP->
isValid(2) )
00069 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 2");
00070
return;
00071 }
00072
00073
if ( !pDP->
isValid(4) )
00074 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 4");
00075
return;
00076 }
00077
00078
if ( !pDP->
isValid(5) )
00079 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 5");
00080
return;
00081 }
00082
00083
if ( !pDP->
isValid(7) )
00084 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 7");
00085
return;
00086 }
00087
00088
if ( !pDP->
isValid(8) )
00089 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 8");
00090
return;
00091 }
00092
00093
if ( !pDP->
isValid(10) )
00094 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 10");
00095
return;
00096 }
00097
00098
if ( !pDP->
isValid(11) )
00099 { setTestResult(
TEST_FAILURE,
"Wrong default validity status on data item 11");
00100
return;
00101 }
00102
00103
00104
if ( pDP->
isObjectConfigured() !=
NOT_CONFIGURED )
00105 { setTestResult(
TEST_FAILURE,
"Incorrect configuration status at creation");
00106
return;
00107 }
00108
00109
00110
DC_NullProfile* pNP =
new DC_NullProfile();
00111 pDP->
setMonitoringProfile(1,pNP);
00112
if (pDP->
getMonitoringProfile(1)!=pNP)
00113 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00114
return;
00115 }
00116
00117 pDP->
setMonitoringProfile(2,pNP);
00118
if (pDP->
getMonitoringProfile(2)!=pNP)
00119 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00120
return;
00121 }
00122
00123 pDP->
setMonitoringProfile(4,pNP);
00124
if (pDP->
getMonitoringProfile(4)!=pNP)
00125 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00126
return;
00127 }
00128
00129 pDP->
setMonitoringProfile(5,pNP);
00130
if (pDP->
getMonitoringProfile(5)!=pNP)
00131 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00132
return;
00133 }
00134
00135 pDP->
setMonitoringProfile(7,pNP);
00136
if (pDP->
getMonitoringProfile(7)!=pNP)
00137 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00138
return;
00139 }
00140
00141 pDP->
setMonitoringProfile(8,pNP);
00142
if (pDP->
getMonitoringProfile(8)!=pNP)
00143 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00144
return;
00145 }
00146
00147 pDP->
setMonitoringProfile(10,pNP);
00148
if (pDP->
getMonitoringProfile(10)!=pNP)
00149 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00150
return;
00151 }
00152
00153 pDP->
setMonitoringProfile(11,pNP);
00154
if (pDP->
getMonitoringProfile(11)!=pNP)
00155 { setTestResult(
TEST_FAILURE,
"Failure to read back monitoring profile");
00156
return;
00157 }
00158
00159
00160
if ( pDP->
isObjectConfigured() !=
CONFIGURED )
00161 { setTestResult(
TEST_FAILURE,
"Incorrect configuration status");
00162
return;
00163 }
00164
00165
00166
00167
00168
id = 2;
00169 pDP->
setValue(
id,(
TD_Float)
id);
00170
if ( fabs((
float)(pDP->
getFloatValue(
id)-
id))>FLT_EPSILON )
00171 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00172
return;
00173 }
00174
if ( fabs((
float)((*pDP->
getPointerFloatValue(
id))-
id))>FLT_EPSILON )
00175 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00176
return;
00177 }
00178
id = 5;
00179 pDP->
setValue(
id,(
TD_Float)
id);
00180
if ( fabs((
float)(pDP->
getFloatValue(
id)-
id))>FLT_EPSILON )
00181 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00182
return;
00183 }
00184
if ( fabs((
float)((*pDP->
getPointerFloatValue(
id))-
id))>FLT_EPSILON )
00185 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00186
return;
00187 }
00188
id = 8;
00189 pDP->
setValue(
id,(
TD_Float)
id);
00190
if ( fabs((
float)(pDP->
getFloatValue(
id)-
id))>FLT_EPSILON )
00191 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00192
return;
00193 }
00194
if ( fabs((
float)((*pDP->
getPointerFloatValue(
id))-
id))>FLT_EPSILON )
00195 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00196
return;
00197 }
00198
id = 11;
00199 pDP->
setValue(
id,(
TD_Float)
id);
00200
if ( fabs((
float)(pDP->
getFloatValue(
id)-
id))>FLT_EPSILON )
00201 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00202
return;
00203 }
00204
if ( fabs((
float)((*pDP->
getPointerFloatValue(
id))-
id))>FLT_EPSILON )
00205 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00206
return;
00207 }
00208
id = 1;
00209 pDP->
setValue(
id,(
TD_Integer)
id);
00210
if ( pDP->
getIntegerValue(
id)!=
id )
00211 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00212
return;
00213 }
00214
if ( (*pDP->
getPointerIntegerValue(
id))!=
id )
00215 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00216
return;
00217 }
00218
id = 4;
00219 pDP->
setValue(
id,(
TD_Integer)
id);
00220
if ( pDP->
getIntegerValue(
id)!=
id )
00221 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00222
return;
00223 }
00224
if ( (*pDP->
getPointerIntegerValue(
id))!=
id )
00225 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00226
return;
00227 }
00228
id = 7;
00229 pDP->
setValue(
id,(
TD_Integer)
id);
00230
if ( pDP->
getIntegerValue(
id)!=
id )
00231 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00232
return;
00233 }
00234
if ( (*pDP->
getPointerIntegerValue(
id))!=
id )
00235 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00236
return;
00237 }
00238
id = 10;
00239 pDP->
setValue(
id,(
TD_Integer)
id);
00240
if ( pDP->
getIntegerValue(
id)!=
id )
00241 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00242
return;
00243 }
00244
if ( (*pDP->
getPointerIntegerValue(
id))!=
id )
00245 { setTestResult(
TEST_FAILURE,
"Failure to read back data pool item with ID: id");
00246
return;
00247 }
00248
00249
id = 1;
00250 pDP->
setValidityStatus(
id,
false);
00251
if ( pDP->
isValid(
id) )
00252 { setTestResult(
TEST_FAILURE,
"Wrong validity status");
00253
return;
00254 }
00255
00256
00257
if (
isNonNominalCheckAllowed()) {
00258 pDP->
setValidityStatus(11+1,
false);
00259
if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DP_ACCESS) )
00260
return;
00261 nEvt = nEvt+1;
00262 }
00263
00264
00265
id = 1;
00266 pDP->
setValidityStatus(
id,
false);
00267 pDP->
reset();
00268
if ( !pDP->
isValid(
id) )
00269 { setTestResult(
TEST_FAILURE,
"Reset failure");
00270
return;
00271 }
00272
00273
00274
00275
id = 1;
00276
TD_Integer oldValue = pDP->
getIntegerValue(
id);
00277 pDP->
setValidityStatus(
id,
false);
00278 pDP->
setValue(
id,(
TD_Integer)(oldValue+1));
00279
if ( pDP->
getIntegerValue(
id)!=oldValue )
00280 { setTestResult(
TEST_FAILURE,
"Back-up value failure");
00281
return;
00282 }
00283
if ( pDP->
getDataItem(
id)->
getIntegerValue()!=oldValue )
00284 { setTestResult(
TEST_FAILURE,
"Back-up value failure");
00285
return;
00286 }
00287 pDP->
setValidityStatus(
id,
true);
00288 pDP->
setValue(
id,(
TD_Integer)(oldValue+1));
00289
if ( pDP->
getIntegerValue(
id)!=(oldValue+1) )
00290 { setTestResult(
TEST_FAILURE,
"Back-up value failure");
00291
return;
00292 }
00293
if ( pDP->
getDataItem(
id)->
getIntegerValue()!=(oldValue+1) )
00294 { setTestResult(
TEST_FAILURE,
"Back-up value failure");
00295
return;
00296 }
00297
00298
00299
id = 2;
00300
TD_Float fOldValue = pDP->
getFloatValue(
id);
00301 pDP->
setValidityStatus(
id,
false);
00302 pDP->
setValue(
id,(
TD_Float)(fOldValue+1.0));
00303
if ( fabs( (
float)(pDP->
getFloatValue(
id)-fOldValue) )>FLT_EPSILON )
00304 { setTestResult(
TEST_FAILURE,
"Back-up value failure");
00305
return;
00306 }
00307 pDP->
setValidityStatus(
id,
true);
00308 pDP->
setValue(
id,(
TD_Float)(fOldValue+1.0));
00309
if ( fabs( (
float)(pDP->
getFloatValue(
id)-(fOldValue+1.0)) )>FLT_EPSILON )
00310 { setTestResult(
TEST_FAILURE,
"Back-up value failure");
00311
return;
00312 }
00313
00314
00315
TD_DataPoolId counter = 0;
00316
for (
TD_DataPoolId i=pDP->
firstIdentifier(); !pDP->
isLastIdentifier(); i=pDP->
nextIdentifier()) {
00317 counter++;
00318 pDP->
setValidityStatus(i,
false);
00319 }
00320
if ( counter!=numberOfPar )
00321 { setTestResult(
TEST_FAILURE,
"Error in data pool iteration");
00322
return;
00323 }
00324
00325 setTestResult(
TEST_SUCCESS,
"Test Successful");
00326
return;
00327 }