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

TestCaseSampleR1Database_1.cpp

00001 00002 // 00003 // Copyright 2003 P&P Software GmbH - All Rights Reserved 00004 // 00005 // TestCaseSampleR1Database_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_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 // 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_SampleR1Database* pDB = new DC_SampleR1Database(); 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_SAMPLER1DATABASE) 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 setTestResult(TEST_SUCCESS,"Test Successful"); 00164 return; 00165 }
Copyright 2003 P&P Software GmbH - All Rights Reserved