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_BasicDatabase.h"
00014
#include "TestCaseBasicDatabase_1.h"
00015
00016
#include <math.h>
00017
#include <float.h>
00018
00019 TestCaseBasicDatabase_1::TestCaseBasicDatabase_1(
void) :
00020
TestCaseGenericSetUp(ID_BASICDATABASE*10+1,"
TestCaseBasicDatabase_1") {
00021
return;
00022 }
00023
00024 void TestCaseBasicDatabase_1::runTestCase(
void) {
00025
00026
00027
00028
00029
00030
00031
double shadowDefaultTable[3];
00032
unsigned int* defaultTable = (
unsigned int*)shadowDefaultTable;
00033
00034
00035
00036
00037
00038 defaultTable[0] = 0xAABBCCDD;
00039 defaultTable[1] = 0x11223344;
00040 defaultTable[2] = 0x55667788;
00041
00042
00043
00044
const TD_DatabaseId PD_T1 = 0;
00045
const TD_DatabaseId PD_T2 = 4;
00046
const TD_DatabaseId PD_T3 = 8;
00047
00048
00049
00050
00051
double shadowOperationalTable[3];
00052
int* operationalTable = (
int*)shadowOperationalTable;
00053
00054
00055
DC_BasicDatabase* pDB =
new DC_BasicDatabase();
00056
00057
00058
if (pDB->
getClassId() != ID_BASICDATABASE)
00059 { setTestResult(
TEST_FAILURE,
"Wrong class ID");
00060
return;
00061 }
00062
00063
00064
if ( pDB->
isObjectConfigured() !=
NOT_CONFIGURED )
00065 { setTestResult(
TEST_FAILURE,
"Incorrect configuration status at creation");
00066
return;
00067 }
00068
00069
00070 pDB->
setTableLength(12);
00071
if ( pDB->
getTableLength() != 12 )
00072 { setTestResult(
TEST_FAILURE,
"Incorrect table length");
00073
return;
00074 }
00075
00076
00077 pDB->
setDefaultTable((
char*)defaultTable);
00078 pDB->
setOperationalTable((
char*)operationalTable);
00079 pDB->
reset();
00080
00081
00082
if ( pDB->
isObjectConfigured() !=
CONFIGURED )
00083 { setTestResult(
TEST_FAILURE,
"Incorrect configuration status after configuration was completed");
00084
return;
00085 }
00086
00087
00088
if ( pDB->
getParameterUnsignedInt(PD_T1) != defaultTable[0] )
00089 { setTestResult(
TEST_FAILURE,
"Incorrect initialization of operational table");
00090
return;
00091 }
00092
if ( pDB->
getParameterUnsignedInt(PD_T2) != defaultTable[1] )
00093 { setTestResult(
TEST_FAILURE,
"Incorrect initialization of operational table");
00094
return;
00095 }
00096
if ( pDB->
getParameterUnsignedInt(PD_T3) != defaultTable[2] )
00097 { setTestResult(
TEST_FAILURE,
"Incorrect initialization of operational table");
00098
return;
00099 }
00100
00101
00102
double d = 0.2;
00103 pDB->
setParameter(PD_T1,d);
00104
if (fabs(pDB->
getParameterDouble(PD_T1)-d)>DBL_EPSILON)
00105 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for double parameter");
00106
return;
00107 }
00108
if (fabs((*pDB->
getParameterPointerDouble(PD_T1))-d)>DBL_EPSILON)
00109 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to double parameter");
00110
return;
00111 }
00112
00113
float f = (
float)0.4;
00114 pDB->
setParameter(PD_T2,f);
00115
if (fabs(pDB->
getParameterFloat(PD_T2)-f)>FLT_EPSILON)
00116 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for float parameter");
00117
return;
00118 }
00119
if (fabs((*pDB->
getParameterPointerFloat(PD_T2))-f)>FLT_EPSILON)
00120 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to float parameter");
00121
return;
00122 }
00123
00124
unsigned int ui = 10;
00125 pDB->
setParameter(PD_T2,ui);
00126
if (pDB->
getParameterUnsignedInt(PD_T2)!=ui)
00127 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for unsigned int parameter");
00128
return;
00129 }
00130
if ((*pDB->
getParameterPointerUnsignedInt(PD_T2))!=ui)
00131 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to unsigned int parameter");
00132
return;
00133 }
00134
00135
int i = 20;
00136 pDB->
setParameter(PD_T2,i);
00137
if (pDB->
getParameterInt(PD_T2)!=i)
00138 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for int parameter");
00139
return;
00140 }
00141
if ((*pDB->
getParameterPointerInt(PD_T2))!=i)
00142 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to int parameter");
00143
return;
00144 }
00145
00146
unsigned short us = 40;
00147 pDB->
setParameter(PD_T2,us);
00148
if (pDB->
getParameterUnsignedShort(PD_T2)!=us)
00149 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for unsigned short parameter");
00150
return;
00151 }
00152
if ((*pDB->
getParameterPointerUnsignedShort(PD_T2))!=us)
00153 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to unsigned short parameter");
00154
return;
00155 }
00156
00157
short s = 30;
00158 pDB->
setParameter(PD_T2,s);
00159
if (pDB->
getParameterShort(PD_T2)!=s)
00160 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for short parameter");
00161
return;
00162 }
00163
if ((*pDB->
getParameterPointerShort(PD_T2))!=s)
00164 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to short parameter");
00165
return;
00166 }
00167
00168
unsigned char uc = 4;
00169 pDB->
setParameter(PD_T2,uc);
00170
if (pDB->
getParameterUnsignedChar(PD_T2)!=uc)
00171 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for unsigned char parameter");
00172
return;
00173 }
00174
if ((*pDB->
getParameterPointerUnsignedChar(PD_T2))!=uc)
00175 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to unsigned char parameter");
00176
return;
00177 }
00178
00179
char c = 2;
00180 pDB->
setParameter(PD_T2,c);
00181
if (pDB->
getParameterUnsignedChar(PD_T2)!=c)
00182 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for char parameter");
00183
return;
00184 }
00185
if ((*pDB->
getParameterPointerChar(PD_T2))!=c)
00186 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to char parameter");
00187
return;
00188 }
00189
00190
bool b =
true;
00191 pDB->
setParameter(PD_T2,b);
00192
if (pDB->
getParameterBool(PD_T2)!=b)
00193 { setTestResult(
TEST_FAILURE,
"Incorrect write/read cycle for boolean parameter");
00194
return;
00195 }
00196
if ((*pDB->
getParameterPointerBool(PD_T2))!=b)
00197 { setTestResult(
TEST_FAILURE,
"Incorrect getter method for pointer to boolean parameter");
00198
return;
00199 }
00200
00201
00202 setTestResult(
TEST_SUCCESS,
"Test Successful");
00203
return;
00204 }