00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "../GeneralInclude/CompilerSwitches.h"
00011
#include "../GeneralInclude/ClassId.h"
00012
#include "../GeneralInclude/Constants.h"
00013
#include "../Data/DC_SampleR1Database.h"
00014
#include "TestCaseSampleR1Database_1.h"
00015
#include "../Utilities/TestCaseWithEvtCheck.h"
00016
00017
#include <math.h>
00018
#include <float.h>
00019
00020 TestCaseSampleR1Database_1::TestCaseSampleR1Database_1():
00021
TestCaseWithEvtCheck(ID_SAMPLER1DATABASE*10+1,"
TestCaseSampleR1Database_1") {
00022
return;
00023 }
00024
00025 void TestCaseSampleR1Database_1::runTestCase() {
00026
00027
00028
00029
00030
unsigned int dbLength = 50;
00031
unsigned char* defaultTable =
new unsigned char[dbLength];
00032
unsigned char* operationalTable =
new unsigned char[dbLength];
00033
00034
00035
00036
00037
00038
00039
00040
00041
unsigned char* uc;
00042
00043 uc = (defaultTable+0);
00044 *(
float*)uc = (
float)1;
00045 uc = (defaultTable+8);
00046 *(
float*)uc = (
float)2;
00047 uc = (defaultTable+16);
00048 *(
float*)uc = (
float)3;
00049 uc = (defaultTable+24);
00050 *(
float*)uc = (
float)4;
00051
00052
00053
unsigned int nEvt;
00054 nEvt =
getNumberOfEvents();
00055
00056
00057
for (
unsigned int i=0; i<dbLength; i++)
00058 operationalTable[i]=0;
00059
00060
00061
DC_SampleR1Database* pDB =
new DC_SampleR1Database();
00062
00063
00064
TD_DatabaseId maxParId;
00065 maxParId = 4;
00066
00067
00068
TD_DatabaseId illegalParId;
00069 illegalParId = 5;
00070
00071
00072
if (pDB->
getClassId() != ID_SAMPLER1DATABASE)
00073 { setTestResult(
TEST_FAILURE,
"Wrong class ID");
00074
return;
00075 }
00076
00077
00078
if ( pDB->
isObjectConfigured() !=
NOT_CONFIGURED )
00079 { setTestResult(
TEST_FAILURE,
"Incorrect configuration status at creation");
00080
return;
00081 }
00082
00083
00084 pDB->
setDefaultTable((
char*)defaultTable);
00085 pDB->
setOperationalTable((
char*)operationalTable);
00086 pDB->
reset();
00087
00088
00089
if ( pDB->
isObjectConfigured() !=
CONFIGURED )
00090 { setTestResult(
TEST_FAILURE,
"Incorrect configuration status after configuration was completed");
00091
return;
00092 }
00093
00094
00095
00096
if ((
unsigned char*)pDB->
getParameterPointerFloat(1)!=operationalTable+0)
00097 { setTestResult(
TEST_FAILURE,
"Incorrect pointer value for parameter");
00098
return;
00099 }
00100
if ((
unsigned char*)pDB->
getParameterPointerFloat(2)!=operationalTable+8)
00101 { setTestResult(
TEST_FAILURE,
"Incorrect pointer value for parameter");
00102
return;
00103 }
00104
if ((
unsigned char*)pDB->
getParameterPointerFloat(3)!=operationalTable+16)
00105 { setTestResult(
TEST_FAILURE,
"Incorrect pointer value for parameter");
00106
return;
00107 }
00108
if ((
unsigned char*)pDB->
getParameterPointerFloat(4)!=operationalTable+24)
00109 { setTestResult(
TEST_FAILURE,
"Incorrect pointer value for parameter");
00110
return;
00111 }
00112
00113
00114
00115
00116
00117
00118
if (fabs(pDB->
getParameterFloat(1)-1) > DBL_EPSILON)
00119 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter");
00120
return;
00121 }
00122
if (fabs(pDB->
getParameterFloat(2)-2) > DBL_EPSILON)
00123 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter");
00124
return;
00125 }
00126
if (fabs(pDB->
getParameterFloat(3)-3) > DBL_EPSILON)
00127 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter");
00128
return;
00129 }
00130
if (fabs(pDB->
getParameterFloat(4)-4) > DBL_EPSILON)
00131 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter");
00132
return;
00133 }
00134
00135
00136
00137 pDB->
setParameter(1,(
float)(1+1));
00138 pDB->
setParameter(2,(
float)(2+1));
00139 pDB->
setParameter(3,(
float)(3+1));
00140 pDB->
setParameter(4,(
float)(4+1));
00141
00142
00143
00144
00145
00146
00147
if (fabs(pDB->
getParameterFloat(1)-(1+1)) > DBL_EPSILON)
00148 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter 1");
00149
return;
00150 }
00151
if (fabs(pDB->
getParameterFloat(2)-(2+1)) > DBL_EPSILON)
00152 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter 2");
00153
return;
00154 }
00155
if (fabs(pDB->
getParameterFloat(3)-(3+1)) > DBL_EPSILON)
00156 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter 3");
00157
return;
00158 }
00159
if (fabs(pDB->
getParameterFloat(4)-(4+1)) > DBL_EPSILON)
00160 { setTestResult(
TEST_FAILURE,
"Incorrect value for parameter 4");
00161
return;
00162 }
00163 setTestResult(
TEST_SUCCESS,
"Test Successful");
00164
return;
00165 }