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

TestCaseSampleR3Database_1.cpp

00001 00002 // 00003 // Copyright 2003 P&P Software GmbH - All Rights Reserved 00004 // 00005 // TestCaseSampleR3Database_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_SampleR3Database.h" 00014 #include "TestCaseSampleR3Database_1.h" 00015 #include "../Utilities/TestCaseWithEvtCheck.h" 00016 00017 #include <math.h> 00018 #include <float.h> 00019 00020 TestCaseSampleR3Database_1::TestCaseSampleR3Database_1(): 00021 TestCaseWithEvtCheck(ID_SAMPLER3DATABASE*10+1,"TestCaseSampleR3Database_1") { 00022 return; 00023 } 00024 00025 void TestCaseSampleR3Database_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 = 80; 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 *(short*)uc = (short)1; 00045 uc = (defaultTable+8); 00046 *(unsigned short*)uc = (unsigned short)2; 00047 uc = (defaultTable+16); 00048 *(int*)uc = (int)3; 00049 uc = (defaultTable+24); 00050 *(unsigned int*)uc = (unsigned int)4; 00051 uc = (defaultTable+32); 00052 *(char*)uc = (char)5; 00053 uc = (defaultTable+40); 00054 *(unsigned char*)uc = (unsigned char)6; 00055 uc = (defaultTable+48); 00056 *(float*)uc = (float)7; 00057 uc = (defaultTable+56); 00058 *(double*)uc = (double)8; 00059 uc = (defaultTable+64); 00060 *(bool*)uc = (bool)9; 00061 00062 // Get current number of events in event repository 00063 unsigned int nEvt; 00064 nEvt = getNumberOfEvents(); 00065 00066 // Initialize the operational database to all zeros 00067 for (unsigned int i=0; i<dbLength; i++) 00068 operationalTable[i]=0; 00069 00070 // Instantiate parameter database 00071 DC_SampleR3Database* pDB = new DC_SampleR3Database(); 00072 00073 // Variable to hold the maximum parId 00074 TD_DatabaseId maxParId; 00075 maxParId = 9; 00076 00077 // Variable to hold the lowest illegal parId 00078 TD_DatabaseId illegalParId; 00079 illegalParId = 10; 00080 00081 // Verify correctness of class ID 00082 if (pDB->getClassId() != ID_SAMPLER3DATABASE) 00083 { setTestResult(TEST_FAILURE, "Wrong class ID"); 00084 return; 00085 } 00086 00087 // Check that database is not yet configured 00088 if ( pDB->isObjectConfigured() != NOT_CONFIGURED ) 00089 { setTestResult(TEST_FAILURE, "Incorrect configuration status at creation"); 00090 return; 00091 } 00092 00093 // Configure database 00094 pDB->setDefaultTable((char*)defaultTable); 00095 pDB->setOperationalTable((char*)operationalTable); 00096 pDB->reset(); 00097 00098 // Check that database is configured 00099 if ( pDB->isObjectConfigured() != CONFIGURED ) 00100 { setTestResult(TEST_FAILURE, "Incorrect configuration status after configuration was completed"); 00101 return; 00102 } 00103 00104 // Check the pointer getter methods 00105 00106 if ((unsigned char*)pDB->getParameterPointerShort(1)!=operationalTable+0) 00107 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00108 return; 00109 } 00110 if ((unsigned char*)pDB->getParameterPointerUnsignedShort(2)!=operationalTable+8) 00111 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00112 return; 00113 } 00114 if ((unsigned char*)pDB->getParameterPointerInt(3)!=operationalTable+16) 00115 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00116 return; 00117 } 00118 if ((unsigned char*)pDB->getParameterPointerUnsignedInt(4)!=operationalTable+24) 00119 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00120 return; 00121 } 00122 if ((unsigned char*)pDB->getParameterPointerChar(5)!=operationalTable+32) 00123 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00124 return; 00125 } 00126 if ((unsigned char*)pDB->getParameterPointerUnsignedChar(6)!=operationalTable+40) 00127 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00128 return; 00129 } 00130 if ((unsigned char*)pDB->getParameterPointerFloat(7)!=operationalTable+48) 00131 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00132 return; 00133 } 00134 if ((unsigned char*)pDB->getParameterPointerDouble(8)!=operationalTable+56) 00135 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00136 return; 00137 } 00138 if ((unsigned char*)pDB->getParameterPointerBool(9)!=operationalTable+64) 00139 { setTestResult(TEST_FAILURE, "Incorrect pointer value for parameter"); 00140 return; 00141 } 00142 00143 // Check that non-real paramaters have the correct value 00144 00145 if (pDB->getParameterShort(1)!=(short)1) 00146 { setTestResult(TEST_FAILURE, "Incorrect parameter value"); 00147 return; 00148 } 00149 if (pDB->getParameterUnsignedShort(2)!=(unsigned short)2) 00150 { setTestResult(TEST_FAILURE, "Incorrect parameter value"); 00151 return; 00152 } 00153 if (pDB->getParameterInt(3)!=(int)3) 00154 { setTestResult(TEST_FAILURE, "Incorrect parameter value"); 00155 return; 00156 } 00157 if (pDB->getParameterUnsignedInt(4)!=(unsigned int)4) 00158 { setTestResult(TEST_FAILURE, "Incorrect parameter value"); 00159 return; 00160 } 00161 if (pDB->getParameterChar(5)!=(char)5) 00162 { setTestResult(TEST_FAILURE, "Incorrect parameter value"); 00163 return; 00164 } 00165 if (pDB->getParameterUnsignedChar(6)!=(unsigned char)6) 00166 { setTestResult(TEST_FAILURE, "Incorrect parameter value"); 00167 return; 00168 } 00169 if (pDB->getParameterBool(9)!=(bool)9) 00170 { setTestResult(TEST_FAILURE, "Incorrect parameter value"); 00171 return; 00172 } 00173 00174 // Check that real parameters have the correct value 00175 00176 if (fabs(pDB->getParameterFloat(7)-7) > DBL_EPSILON) 00177 { setTestResult(TEST_FAILURE, "Incorrect value for parameter"); 00178 return; 00179 } 00180 if (fabs(pDB->getParameterDouble(8)-8) > DBL_EPSILON) 00181 { setTestResult(TEST_FAILURE, "Incorrect value for parameter"); 00182 return; 00183 } 00184 00185 // Update the value of all parameters by setting it equal to their (parId+1) 00186 00187 pDB->setParameter(1,(short)(1+1)); 00188 pDB->setParameter(2,(unsigned short)(2+1)); 00189 pDB->setParameter(3,(int)(3+1)); 00190 pDB->setParameter(4,(unsigned int)(4+1)); 00191 pDB->setParameter(5,(char)(5+1)); 00192 pDB->setParameter(6,(unsigned char)(6+1)); 00193 pDB->setParameter(7,(float)(7+1)); 00194 pDB->setParameter(8,(double)(8+1)); 00195 pDB->setParameter(9,(bool)(9+1)); 00196 00197 // Check that non-real paramaters have the correct value 00198 00199 if (pDB->getParameterShort(1)!=(short)(1+1)) 00200 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 1"); 00201 return; 00202 } 00203 if (pDB->getParameterUnsignedShort(2)!=(unsigned short)(2+1)) 00204 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 2"); 00205 return; 00206 } 00207 if (pDB->getParameterInt(3)!=(int)(3+1)) 00208 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 3"); 00209 return; 00210 } 00211 if (pDB->getParameterUnsignedInt(4)!=(unsigned int)(4+1)) 00212 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 4"); 00213 return; 00214 } 00215 if (pDB->getParameterChar(5)!=(char)(5+1)) 00216 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 5"); 00217 return; 00218 } 00219 if (pDB->getParameterUnsignedChar(6)!=(unsigned char)(6+1)) 00220 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 6"); 00221 return; 00222 } 00223 if (pDB->getParameterBool(9)!=(bool)(9+1)) 00224 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 9"); 00225 return; 00226 } 00227 00228 // Check that real paramaters have the correct value 00229 00230 if (fabs(pDB->getParameterFloat(7)-(7+1)) > DBL_EPSILON) 00231 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 7"); 00232 return; 00233 } 00234 if (fabs(pDB->getParameterDouble(8)-(8+1)) > DBL_EPSILON) 00235 { setTestResult(TEST_FAILURE, "Incorrect value for parameter 8"); 00236 return; 00237 } 00238 // Check the setter and pointer methods generate event reports when they are accessed either 00239 // with an out-of-range parameter value or with an illegal parameter value 00240 if (isNonNominalCheckAllowed()) { 00241 char* dummy_1; 00242 00243 pDB->setParameter(maxParId+1,(int)0); 00244 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00245 return; 00246 nEvt++; 00247 00248 pDB->setParameter(illegalParId,(int)0); 00249 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00250 return; 00251 nEvt++; 00252 00253 dummy_1 = (char*)pDB->getParameterPointerInt(maxParId+1); 00254 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00255 return; 00256 nEvt++; 00257 00258 dummy_1 = (char*)pDB->getParameterPointerInt(illegalParId); 00259 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00260 return; 00261 nEvt++; 00262 pDB->setParameter(maxParId+1,(unsigned int)0); 00263 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00264 return; 00265 nEvt++; 00266 00267 pDB->setParameter(illegalParId,(unsigned int)0); 00268 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00269 return; 00270 nEvt++; 00271 00272 dummy_1 = (char*)pDB->getParameterPointerUnsignedInt(maxParId+1); 00273 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00274 return; 00275 nEvt++; 00276 00277 dummy_1 = (char*)pDB->getParameterPointerUnsignedInt(illegalParId); 00278 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00279 return; 00280 nEvt++; 00281 pDB->setParameter(maxParId+1,(short)0); 00282 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00283 return; 00284 nEvt++; 00285 00286 pDB->setParameter(illegalParId,(short)0); 00287 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00288 return; 00289 nEvt++; 00290 00291 dummy_1 = (char*)pDB->getParameterPointerShort(maxParId+1); 00292 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00293 return; 00294 nEvt++; 00295 00296 dummy_1 = (char*)pDB->getParameterPointerShort(illegalParId); 00297 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00298 return; 00299 nEvt++; 00300 pDB->setParameter(maxParId+1,(unsigned short)0); 00301 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00302 return; 00303 nEvt++; 00304 00305 pDB->setParameter(illegalParId,(unsigned short)0); 00306 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00307 return; 00308 nEvt++; 00309 00310 dummy_1 = (char*)pDB->getParameterPointerUnsignedShort(maxParId+1); 00311 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00312 return; 00313 nEvt++; 00314 00315 dummy_1 = (char*)pDB->getParameterPointerUnsignedShort(illegalParId); 00316 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00317 return; 00318 nEvt++; 00319 pDB->setParameter(maxParId+1,(char)0); 00320 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00321 return; 00322 nEvt++; 00323 00324 pDB->setParameter(illegalParId,(char)0); 00325 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00326 return; 00327 nEvt++; 00328 00329 dummy_1 = (char*)pDB->getParameterPointerChar(maxParId+1); 00330 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00331 return; 00332 nEvt++; 00333 00334 dummy_1 = (char*)pDB->getParameterPointerChar(illegalParId); 00335 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00336 return; 00337 nEvt++; 00338 pDB->setParameter(maxParId+1,(unsigned char)0); 00339 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00340 return; 00341 nEvt++; 00342 00343 pDB->setParameter(illegalParId,(unsigned char)0); 00344 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00345 return; 00346 nEvt++; 00347 00348 dummy_1 = (char*)pDB->getParameterPointerUnsignedChar(maxParId+1); 00349 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00350 return; 00351 nEvt++; 00352 00353 dummy_1 = (char*)pDB->getParameterPointerUnsignedChar(illegalParId); 00354 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00355 return; 00356 nEvt++; 00357 pDB->setParameter(maxParId+1,(bool)0); 00358 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00359 return; 00360 nEvt++; 00361 00362 pDB->setParameter(illegalParId,(bool)0); 00363 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00364 return; 00365 nEvt++; 00366 00367 dummy_1 = (char*)pDB->getParameterPointerBool(maxParId+1); 00368 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00369 return; 00370 nEvt++; 00371 00372 dummy_1 = (char*)pDB->getParameterPointerBool(illegalParId); 00373 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00374 return; 00375 nEvt++; 00376 pDB->setParameter(maxParId+1,(float)0); 00377 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00378 return; 00379 nEvt++; 00380 00381 pDB->setParameter(illegalParId,(float)0); 00382 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00383 return; 00384 nEvt++; 00385 00386 dummy_1 = (char*)pDB->getParameterPointerFloat(maxParId+1); 00387 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00388 return; 00389 nEvt++; 00390 00391 dummy_1 = (char*)pDB->getParameterPointerFloat(illegalParId); 00392 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00393 return; 00394 nEvt++; 00395 pDB->setParameter(maxParId+1,(double)0); 00396 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00397 return; 00398 nEvt++; 00399 00400 pDB->setParameter(illegalParId,(double)0); 00401 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00402 return; 00403 nEvt++; 00404 00405 dummy_1 = (char*)pDB->getParameterPointerDouble(maxParId+1); 00406 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00407 return; 00408 nEvt++; 00409 00410 dummy_1 = (char*)pDB->getParameterPointerDouble(illegalParId); 00411 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00412 return; 00413 nEvt++; 00414 } 00415 00416 // Check the getter methods generate errors when they are accessed either 00417 // with an out-of-range parameter value or with an illegal parameter value 00418 if (isNonNominalCheckAllowed()) { 00419 double dummy_2; 00420 00421 dummy_2 = (double)pDB->getParameterInt(maxParId+1); 00422 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00423 return; 00424 nEvt++; 00425 00426 dummy_2 = (double)pDB->getParameterInt(illegalParId); 00427 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00428 return; 00429 nEvt++; 00430 00431 dummy_2 = (double)pDB->getParameterUnsignedInt(maxParId+1); 00432 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00433 return; 00434 nEvt++; 00435 00436 dummy_2 = (double)pDB->getParameterUnsignedInt(illegalParId); 00437 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00438 return; 00439 nEvt++; 00440 00441 dummy_2 = (double)pDB->getParameterShort(maxParId+1); 00442 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00443 return; 00444 nEvt++; 00445 00446 dummy_2 = (double)pDB->getParameterShort(illegalParId); 00447 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00448 return; 00449 nEvt++; 00450 00451 dummy_2 = (double)pDB->getParameterUnsignedShort(maxParId+1); 00452 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00453 return; 00454 nEvt++; 00455 00456 dummy_2 = (double)pDB->getParameterUnsignedShort(illegalParId); 00457 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00458 return; 00459 nEvt++; 00460 00461 dummy_2 = (double)pDB->getParameterChar(maxParId+1); 00462 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00463 return; 00464 nEvt++; 00465 00466 dummy_2 = (double)pDB->getParameterChar(illegalParId); 00467 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00468 return; 00469 nEvt++; 00470 00471 dummy_2 = (double)pDB->getParameterUnsignedChar(maxParId+1); 00472 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00473 return; 00474 nEvt++; 00475 00476 dummy_2 = (double)pDB->getParameterUnsignedChar(illegalParId); 00477 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00478 return; 00479 nEvt++; 00480 00481 dummy_2 = (double)pDB->getParameterBool(maxParId+1); 00482 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00483 return; 00484 nEvt++; 00485 00486 dummy_2 = (double)pDB->getParameterBool(illegalParId); 00487 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00488 return; 00489 nEvt++; 00490 00491 dummy_2 = (double)pDB->getParameterFloat(maxParId+1); 00492 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00493 return; 00494 nEvt++; 00495 00496 dummy_2 = (double)pDB->getParameterFloat(illegalParId); 00497 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00498 return; 00499 nEvt++; 00500 00501 dummy_2 = (double)pDB->getParameterDouble(maxParId+1); 00502 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00503 return; 00504 nEvt++; 00505 00506 dummy_2 = (double)pDB->getParameterDouble(illegalParId); 00507 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_DB_ACCESS) ) 00508 return; 00509 nEvt++; 00510 00511 } 00512 00513 setTestResult(TEST_SUCCESS,"Test Successful"); 00514 return; 00515 }
Copyright 2003 P&P Software GmbH - All Rights Reserved