Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCaseSampleR2Database_1.cpp

00001 00002 // 00003 // Copyright 2003 P&P Software GmbH - All Rights Reserved 00004 // 00005 // TestCaseSampleR2Database_1.cpp 00006 // 00007 // This file was automatically generated by an XSL program 00008 // 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../Data/DC_SampleR2Database.h" 00014 #include "TestCaseSampleR2Database_1.h" 00015 #include "../Utilities/TestCaseWithEvtCheck.h" 00016 00017 #include <math.h> 00018 #include <float.h> 00019 00020 TestCaseSampleR2Database_1::TestCaseSampleR2Database_1(): 00021 TestCaseWithEvtCheck(ID_SAMPLER2DATABASE*10+1,"TestCaseSampleR2Database_1") { 00022 return; 00023 } 00024 00025 void TestCaseSampleR2Database_1::runTestCase() { 00026 00027 // Data structures to simulate the default and operational tables 00028 // (The size of the database is read from the Parameter Database 00029 // Descriptor file). 00030 unsigned int dbLength = 50; 00031 unsigned char* defaultTable = new unsigned char[dbLength]; 00032 unsigned char* operationalTable = new unsigned char[dbLength]; 00033 00034 // Initialize the default database. Each parameter is given a 00035 // value equal to its parameter ID. The parameter ID is read from 00036 // the Parameter Database Descriptor File. Note that this 00037 // strategy will sometimes result in an attempt to assign to a 00038 // parameter a value that is inconsistent with its type (e.g. a 00039 // a parameter of type 'char' might have a parameter ID greater than 00040 // 256). 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 // Get current number of events in event repository 00053 unsigned int nEvt; 00054 nEvt = getNumberOfEvents(); 00055 00056 // Initialize the operational database to all zeros 00057 for (unsigned int i=0; i<dbLength; i++) 00058 operationalTable[i]=0; 00059 00060 // Instantiate parameter database 00061 DC_SampleR2Database* pDB = new DC_SampleR2Database(); 00062 00063 // Variable to hold the maximum parId 00064 TD_DatabaseId maxParId; 00065 maxParId = 4; 00066 00067 // Variable to hold the lowest illegal parId 00068 TD_DatabaseId illegalParId; 00069 illegalParId = 5; 00070 00071 // Verify correctness of class ID 00072 if (pDB->getClassId() != ID_SAMPLER2DATABASE) 00073 { setTestResult(TEST_FAILURE, "Wrong class ID"); 00074 return; 00075 } 00076 00077 // Check that database is not yet configured 00078 if ( pDB->isObjectConfigured() != NOT_CONFIGURED ) 00079 { setTestResult(TEST_FAILURE, "Incorrect configuration status at creation"); 00080 return; 00081 } 00082 00083 // Configure database 00084 pDB->setDefaultTable((char*)defaultTable); 00085 pDB->setOperationalTable((char*)operationalTable); 00086 pDB->reset(); 00087 00088 // Check that database is configured 00089 if ( pDB->isObjectConfigured() != CONFIGURED ) 00090 { setTestResult(TEST_FAILURE, "Incorrect configuration status after configuration was completed"); 00091 return; 00092 } 00093 00094 // Check the pointer getter methods 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 // Check that non-real paramaters have the correct value 00114 00115 00116 // Check that real parameters have the correct value 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 // Update the value of all parameters by setting it equal to their (parId+1) 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 // Check that non-real paramaters have the correct value 00143 00144 00145 // Check that real paramaters have the correct value 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 // Check the setter and pointer methods generate event reports when they are accessed either 00164 // with an out-of-range parameter value or with an illegal parameter value 00165 if (isNonNominalCheckAllowed()) { 00166 char* dummy_1; 00167 00168 pDB->setParameter(maxParId+1,(int)0); 00169 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00170 return; 00171 nEvt++; 00172 00173 pDB->setParameter(illegalParId,(int)0); 00174 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00175 return; 00176 nEvt++; 00177 00178 dummy_1 = (char*)pDB->getParameterPointerInt(maxParId+1); 00179 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00180 return; 00181 nEvt++; 00182 00183 dummy_1 = (char*)pDB->getParameterPointerInt(illegalParId); 00184 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00185 return; 00186 nEvt++; 00187 pDB->setParameter(maxParId+1,(unsigned int)0); 00188 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00189 return; 00190 nEvt++; 00191 00192 pDB->setParameter(illegalParId,(unsigned int)0); 00193 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00194 return; 00195 nEvt++; 00196 00197 dummy_1 = (char*)pDB->getParameterPointerUnsignedInt(maxParId+1); 00198 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00199 return; 00200 nEvt++; 00201 00202 dummy_1 = (char*)pDB->getParameterPointerUnsignedInt(illegalParId); 00203 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00204 return; 00205 nEvt++; 00206 pDB->setParameter(maxParId+1,(short)0); 00207 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00208 return; 00209 nEvt++; 00210 00211 pDB->setParameter(illegalParId,(short)0); 00212 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00213 return; 00214 nEvt++; 00215 00216 dummy_1 = (char*)pDB->getParameterPointerShort(maxParId+1); 00217 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00218 return; 00219 nEvt++; 00220 00221 dummy_1 = (char*)pDB->getParameterPointerShort(illegalParId); 00222 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00223 return; 00224 nEvt++; 00225 pDB->setParameter(maxParId+1,(unsigned short)0); 00226 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00227 return; 00228 nEvt++; 00229 00230 pDB->setParameter(illegalParId,(unsigned short)0); 00231 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00232 return; 00233 nEvt++; 00234 00235 dummy_1 = (char*)pDB->getParameterPointerUnsignedShort(maxParId+1); 00236 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00237 return; 00238 nEvt++; 00239 00240 dummy_1 = (char*)pDB->getParameterPointerUnsignedShort(illegalParId); 00241 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00242 return; 00243 nEvt++; 00244 pDB->setParameter(maxParId+1,(char)0); 00245 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00246 return; 00247 nEvt++; 00248 00249 pDB->setParameter(illegalParId,(char)0); 00250 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00251 return; 00252 nEvt++; 00253 00254 dummy_1 = (char*)pDB->getParameterPointerChar(maxParId+1); 00255 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00256 return; 00257 nEvt++; 00258 00259 dummy_1 = (char*)pDB->getParameterPointerChar(illegalParId); 00260 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00261 return; 00262 nEvt++; 00263 pDB->setParameter(maxParId+1,(unsigned char)0); 00264 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00265 return; 00266 nEvt++; 00267 00268 pDB->setParameter(illegalParId,(unsigned char)0); 00269 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00270 return; 00271 nEvt++; 00272 00273 dummy_1 = (char*)pDB->getParameterPointerUnsignedChar(maxParId+1); 00274 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00275 return; 00276 nEvt++; 00277 00278 dummy_1 = (char*)pDB->getParameterPointerUnsignedChar(illegalParId); 00279 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00280 return; 00281 nEvt++; 00282 pDB->setParameter(maxParId+1,(bool)0); 00283 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00284 return; 00285 nEvt++; 00286 00287 pDB->setParameter(illegalParId,(bool)0); 00288 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00289 return; 00290 nEvt++; 00291 00292 dummy_1 = (char*)pDB->getParameterPointerBool(maxParId+1); 00293 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00294 return; 00295 nEvt++; 00296 00297 dummy_1 = (char*)pDB->getParameterPointerBool(illegalParId); 00298 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00299 return; 00300 nEvt++; 00301 pDB->setParameter(maxParId+1,(float)0); 00302 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00303 return; 00304 nEvt++; 00305 00306 pDB->setParameter(illegalParId,(float)0); 00307 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00308 return; 00309 nEvt++; 00310 00311 dummy_1 = (char*)pDB->getParameterPointerFloat(maxParId+1); 00312 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00313 return; 00314 nEvt++; 00315 00316 dummy_1 = (char*)pDB->getParameterPointerFloat(illegalParId); 00317 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00318 return; 00319 nEvt++; 00320 pDB->setParameter(maxParId+1,(double)0); 00321 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00322 return; 00323 nEvt++; 00324 00325 pDB->setParameter(illegalParId,(double)0); 00326 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00327 return; 00328 nEvt++; 00329 00330 dummy_1 = (char*)pDB->getParameterPointerDouble(maxParId+1); 00331 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00332 return; 00333 nEvt++; 00334 00335 dummy_1 = (char*)pDB->getParameterPointerDouble(illegalParId); 00336 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00337 return; 00338 nEvt++; 00339 } 00340 00341 setTestResult(TEST_SUCCESS,"Test Successful"); 00342 return; 00343 }
Copyright 2003 P&P Software GmbH - All Rights Reserved