Inheritance diagram for CalcTestInfo< T >:
Public Member Functions | |
CalcTestInfo (StandardTypeDescriptorOrdinal type) | |
virtual | ~CalcTestInfo () |
void | add (string desc, T *pV, TProgramCounter pc, uint line=0) |
void | add (string desc, T v, TProgramCounter pc, uint line=0) |
void | addRegister (string desc, TProgramCounter pc) |
void | addWarning (const char *msg, TProgramCounter pc) |
void | add (string desc, const char *error, TProgramCounter pc, uint line=0) |
void | setTupleData (TupleData &tuple) |
virtual bool | checkResult (Calculator &calc, TupleData &outputTuple) |
Public Attributes | |
vector< RegisterTestInfo< T > > | mOutRegInfo |
deque< CalcMessage > | mWarnings |
StandardTypeDescriptorOrdinal | typeOrdinal |
Definition at line 164 of file CalcAssemblerTest.cpp.
CalcTestInfo< T >::CalcTestInfo | ( | StandardTypeDescriptorOrdinal | type | ) | [inline, explicit] |
virtual CalcTestInfo< T >::~CalcTestInfo | ( | ) | [inline, virtual] |
void CalcTestInfo< T >::add | ( | string | desc, | |
T * | pV, | |||
TProgramCounter | pc, | |||
uint | line = 0 | |||
) | [inline] |
Definition at line 172 of file CalcAssemblerTest.cpp.
References CalcTestInfo< T >::mOutRegInfo.
Referenced by CalcAssemblerTest::testIntegralNativeInstructions(), and CalcAssemblerTest::testNativeInstructions().
00173 { 00174 if (line) { 00175 ostringstream ostr(""); 00176 ostr << " Line: " << line; 00177 desc += ostr.str(); 00178 } 00179 mOutRegInfo.push_back(RegisterTestInfo<T>(desc, pV, pc)); 00180 }
void CalcTestInfo< T >::add | ( | string | desc, | |
T | v, | |||
TProgramCounter | pc, | |||
uint | line = 0 | |||
) | [inline] |
Definition at line 182 of file CalcAssemblerTest.cpp.
References CalcTestInfo< T >::mOutRegInfo.
00183 { 00184 if (line) { 00185 ostringstream ostr(""); 00186 ostr << " Line: " << line; 00187 desc += ostr.str(); 00188 } 00189 mOutRegInfo.push_back(RegisterTestInfo<T>(desc, v, pc)); 00190 }
void CalcTestInfo< T >::addRegister | ( | string | desc, | |
TProgramCounter | pc | |||
) | [inline] |
Definition at line 192 of file CalcAssemblerTest.cpp.
References CalcTestInfo< T >::mOutRegInfo.
Referenced by CalcTestInfo< T >::add(), and CalcAssemblerTest::testIntegralNativeInstructions().
00193 { 00194 mOutRegInfo.push_back(RegisterTestInfo<T>(desc, pc)); 00195 }
void CalcTestInfo< T >::addWarning | ( | const char * | msg, | |
TProgramCounter | pc | |||
) | [inline] |
Definition at line 197 of file CalcAssemblerTest.cpp.
References CalcTestInfo< T >::mWarnings.
Referenced by CalcTestInfo< T >::add().
00198 { 00199 mWarnings.push_back(CalcMessage(msg, pc)); 00200 }
void CalcTestInfo< T >::add | ( | string | desc, | |
const char * | error, | |||
TProgramCounter | pc, | |||
uint | line = 0 | |||
) | [inline] |
Definition at line 202 of file CalcAssemblerTest.cpp.
References CalcTestInfo< T >::addRegister(), and CalcTestInfo< T >::addWarning().
00203 { 00204 if (line) { 00205 ostringstream ostr(""); 00206 ostr << " Line: " << line; 00207 desc += ostr.str(); 00208 } 00209 addRegister(desc, pc); 00210 if (error != NULL) { 00211 addWarning(error, pc); 00212 } 00213 }
void CalcTestInfo< T >::setTupleData | ( | TupleData & | tuple | ) | [inline] |
Definition at line 215 of file CalcAssemblerTest.cpp.
References CalcTestInfo< T >::mOutRegInfo.
Referenced by CalcAssemblerTest::testIntegralNativeInstructions(), and CalcAssemblerTest::testNativeInstructions().
00216 { 00217 assert(tuple.size() == mOutRegInfo.size()); 00218 00219 // Check type of output registers and value 00220 for (uint i = 0; i < tuple.size(); i++) { 00221 mOutRegInfo[i].setTupleDatum(tuple[i]); 00222 } 00223 }
virtual bool CalcTestInfo< T >::checkResult | ( | Calculator & | calc, | |
TupleData & | outputTuple | |||
) | [inline, virtual] |
Implements CalcChecker.
Definition at line 225 of file CalcAssemblerTest.cpp.
References Calculator::getOutputRegisterDescriptor(), CalcTestInfo< T >::mOutRegInfo, CalcTestInfo< T >::mWarnings, Calculator::mWarnings, and CalcTestInfo< T >::typeOrdinal.
00226 { 00227 TupleDescriptor outputTupleDesc = calc.getOutputRegisterDescriptor(); 00228 // Verify the output descriptor 00229 assert(outputTupleDesc.size() == outputTuple.size()); 00230 00231 // Check number of output registers 00232 if (outputTupleDesc.size() != mOutRegInfo.size()) { 00233 ostringstream message(""); 00234 message << "Mismatch of output register number: Expected "; 00235 message << outputTupleDesc.size(); 00236 message << ", Actual " << mOutRegInfo.size(); 00237 BOOST_ERROR(message.str()); 00238 return false; 00239 } 00240 00241 // Check type of output registers and value 00242 for (uint i = 0; i < outputTupleDesc.size(); i++) { 00243 if (outputTupleDesc[i].pTypeDescriptor->getOrdinal() != 00244 static_cast<StoredTypeDescriptor::Ordinal>(typeOrdinal)) 00245 { 00246 ostringstream message(""); 00247 message << "Type ordinal mismatch: Expected "; 00248 message << outputTupleDesc[i].pTypeDescriptor->getOrdinal(); 00249 message << ", Actual"; 00250 message << static_cast<StoredTypeDescriptor::Ordinal>( 00251 typeOrdinal); 00252 BOOST_ERROR(message.str()); 00253 return false; 00254 } 00255 00256 if (!mOutRegInfo[i].checkTupleDatum(outputTuple[i])) { 00257 ostringstream message(""); 00258 message << "Tuple datum mismatch: Register " << i 00259 << " should be " << mOutRegInfo[i].toString() 00260 << "."; 00261 BOOST_ERROR(message.str()); 00262 return false; 00263 } 00264 } 00265 00266 // Check warnings 00267 if (calc.mWarnings.size() != mWarnings.size()) { 00268 ostringstream message(""); 00269 message << "# of warnings should be " << mWarnings.size() 00270 << " not " << calc.mWarnings.size(); 00271 BOOST_ERROR(message.str()); 00272 return false; 00273 } 00274 00275 for (uint i = 0; i < mWarnings.size(); i++) { 00276 if (calc.mWarnings[i].pc != mWarnings[i].pc) { 00277 ostringstream message(""); 00278 message << "Warning expected at PC=" << mWarnings[i].pc 00279 << ". Got warning at PC=" 00280 << calc.mWarnings[i].pc; 00281 BOOST_ERROR(message.str()); 00282 return false; 00283 } 00284 00285 if (strcmp(calc.mWarnings[i].str, mWarnings[i].str)) { 00286 ostringstream message(""); 00287 message << "Message should be |" << mWarnings[i].str 00288 << "| not |" << calc.mWarnings[i].str << "| at PC=" 00289 << mWarnings[i].pc ; 00290 BOOST_ERROR(message.str()); 00291 return false; 00292 } 00293 } 00294 00295 return true; 00296 }
vector< RegisterTestInfo<T> > CalcTestInfo< T >::mOutRegInfo |
Definition at line 300 of file CalcAssemblerTest.cpp.
Referenced by CalcTestInfo< T >::add(), CalcTestInfo< T >::addRegister(), CalcTestInfo< T >::checkResult(), and CalcTestInfo< T >::setTupleData().
deque<CalcMessage> CalcTestInfo< T >::mWarnings |
Definition at line 303 of file CalcAssemblerTest.cpp.
Referenced by CalcTestInfo< T >::addWarning(), and CalcTestInfo< T >::checkResult().
StandardTypeDescriptorOrdinal CalcTestInfo< T >::typeOrdinal |
Definition at line 305 of file CalcAssemblerTest.cpp.
Referenced by CalcTestInfo< T >::checkResult().