Public Member Functions | |
CalcAssemblerTestCase (uint line, const char *desc, const char *code) | |
~CalcAssemblerTestCase () | |
void | fail (const char *exp, const char *actual) |
void | passed (const char *exp, const char *actual) |
bool | assemble () |
bool | test (CalcChecker *pChecker=NULL) |
void | expectAssemblerError (const char *err) |
void | writeMaxData (TupleDatum &datum, uint typeOrdinal) |
void | writeMinData (TupleDatum &datum, uint typeOrdinal) |
string | toLiteralString (TupleDatum &datum, uint typeOrdinal) |
void | setTupleDatumMax (TupleDatum &datum, TupleAttributeDescriptor &desc) |
void | setTupleDatumMin (TupleDatum &datum, TupleAttributeDescriptor &desc) |
void | setTupleDatumNull (TupleDatum &datum) |
template<typename T> | |
void | setTupleDatum (TupleDatum &datum, T value) |
template<typename T> | |
void | setTupleDatum (TupleDatum &datum, TupleAttributeDescriptor &desc, T *buf, uint buflen) |
void | setInputMin (uint index) |
void | setInputMax (uint index) |
void | setInputNull (uint index) |
template<typename T> | |
void | setInput (uint index, T value) |
template<typename T> | |
void | setInput (uint index, T *buf, uint buflen) |
string | getInput (uint index) |
TupleData * | getInputTuple () |
void | setExpectedOutputNull (uint index) |
void | setExpectedOutputMax (uint index) |
void | setExpectedOutputMin (uint index) |
template<typename T> | |
void | setExpectedOutput (uint index, T value) |
template<typename T> | |
void | setExpectedOutput (uint index, T *buf, uint buflen) |
string | getExpectedOutput (uint index) |
TupleData * | getExpectedOutputTuple () |
bool | failed () |
Static Public Member Functions | |
static uint | getFailedNumber () |
static uint | getPassedNumber () |
static uint | getTestNumber () |
static string | tupleToString (TupleDescriptor const &tupleDesc, TupleData *tuple) |
Static Public Attributes | |
static const uint | MAX_WIDTH = 512 |
Protected Attributes | |
const char * | mDescription |
const char * | mProgram |
const char * | mAssemblerError |
TupleData * | mInputTuple |
TupleData * | mExpectedOutputTuple |
FixedBuffer * | mInputBuf |
FixedBuffer * | mExpOutputBuf |
bool | mFailed |
bool | mAssembled |
uint | mID |
uint | mLine |
Calculator | mCalc |
Static Protected Attributes | |
static uint | testID |
static uint | nFailed |
static uint | nPassed |
Definition at line 308 of file CalcAssemblerTest.cpp.
CalcAssemblerTestCase::CalcAssemblerTestCase | ( | uint | line, | |
const char * | desc, | |||
const char * | code | |||
) | [inline, explicit] |
Definition at line 314 of file CalcAssemblerTest.cpp.
00315 : mDescription(desc), mProgram(code), mAssemblerError(NULL), 00316 mInputTuple(NULL), mExpectedOutputTuple(NULL), mInputBuf(NULL), 00317 mExpOutputBuf(NULL), mFailed(false), mAssembled(false), 00318 mID(++testID), mLine(line), mCalc(0) 00319 { 00320 }
CalcAssemblerTestCase::~CalcAssemblerTestCase | ( | ) | [inline] |
Definition at line 322 of file CalcAssemblerTest.cpp.
References mExpectedOutputTuple, mExpOutputBuf, mInputBuf, and mInputTuple.
00323 { 00324 if (mInputTuple) { 00325 delete mInputTuple; 00326 } 00327 if (mExpectedOutputTuple) { 00328 delete mExpectedOutputTuple; 00329 } 00330 if (mInputBuf) { 00331 delete[] mInputBuf; 00332 } 00333 if (mExpOutputBuf) { 00334 delete[] mExpOutputBuf; 00335 } 00336 }
static uint CalcAssemblerTestCase::getFailedNumber | ( | ) | [inline, static] |
Definition at line 338 of file CalcAssemblerTest.cpp.
References nFailed.
Referenced by main().
00339 { 00340 return nFailed; 00341 }
static uint CalcAssemblerTestCase::getPassedNumber | ( | ) | [inline, static] |
Definition at line 343 of file CalcAssemblerTest.cpp.
References nPassed.
Referenced by main().
00344 { 00345 return nPassed; 00346 }
static uint CalcAssemblerTestCase::getTestNumber | ( | ) | [inline, static] |
Definition at line 348 of file CalcAssemblerTest.cpp.
References testID.
Referenced by main().
00349 { 00350 return testID; 00351 }
void CalcAssemblerTestCase::fail | ( | const char * | exp, | |
const char * | actual | |||
) | [inline] |
Definition at line 353 of file CalcAssemblerTest.cpp.
References mDescription, mFailed, mID, mLine, and nFailed.
Referenced by assemble(), and test().
00354 { 00355 assert(exp); 00356 assert(actual); 00357 assert(mDescription); 00358 ostringstream message(""); 00359 message << "test " << mID << " failed: | "; 00360 message << mDescription << " | Got \"" << actual << "\" | "; 00361 message << "Expected \"" << exp << "\" | line " << mLine; 00362 BOOST_ERROR(message.str()); 00363 mFailed = true; 00364 nFailed++; 00365 }
void CalcAssemblerTestCase::passed | ( | const char * | exp, | |
const char * | actual | |||
) | [inline] |
Definition at line 367 of file CalcAssemblerTest.cpp.
References mDescription, mID, mLine, nPassed, and verbose.
Referenced by assemble(), and test().
00368 { 00369 assert(exp); 00370 assert(actual); 00371 assert(mDescription); 00372 if (verbose) { 00373 ostringstream message(""); 00374 message << "test " << mID << " passed: | "; 00375 message << mDescription << " | Got \"" << actual << "\" | "; 00376 message << "Expected \"" << exp << "\" | line " << mLine; 00377 BOOST_MESSAGE(message.str()); 00378 } 00379 nPassed++; 00380 }
bool CalcAssemblerTestCase::assemble | ( | ) | [inline] |
Definition at line 382 of file CalcAssemblerTest.cpp.
References Calculator::assemble(), CalcAssembler::createTupleData(), fail(), CalcAssemblerException::getCode(), CalcAssemblerException::getCodeSnippet(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), mAssembled, mAssemblerError, mCalc, mExpectedOutputTuple, mExpOutputBuf, mFailed, mInputBuf, mInputTuple, mProgram, Calculator::outputRegisterByReference(), passed(), and showProgram.
Referenced by CalcAssemblerTest::testAdd(), CalcAssemblerTest::testBool(), CalcAssemblerTest::testComments(), CalcAssemblerTest::testExtended(), CalcAssemblerTest::testInvalidPrograms(), CalcAssemblerTest::testJump(), CalcAssemblerTest::testLiteralBinding(), CalcAssemblerTest::testPointer(), and CalcAssemblerTest::testReturn().
00383 { 00384 assert(!mFailed && !mAssembled); 00385 assert(mProgram != NULL); 00386 try { 00387 mCalc.outputRegisterByReference(false); 00388 mCalc.assemble(mProgram); 00389 00390 TupleDescriptor inputTupleDesc = mCalc.getInputRegisterDescriptor(); 00391 TupleDescriptor outputTupleDesc = 00392 mCalc.getOutputRegisterDescriptor(); 00393 00394 mInputTuple = CalcAssembler::createTupleData( 00395 inputTupleDesc, &mInputBuf); 00396 mExpectedOutputTuple = CalcAssembler::createTupleData( 00397 outputTupleDesc, &mExpOutputBuf); 00398 00399 // Successfully assembled the test program 00400 mAssembled = true; 00401 00402 if (mAssemblerError) { 00403 // Hmmm, we were expecting an error while assembling 00404 // What happened? 00405 string errorStr = "Error assembling program: "; 00406 errorStr += mAssemblerError; 00407 fail(errorStr.c_str(), "Program assembled."); 00408 } 00409 } catch (CalcAssemblerException& ex) { 00410 if (mAssemblerError) { 00411 // We are expecting an error 00412 // Things okay 00413 00414 // Let's check if the error message is kind of what we expected 00415 if (ex.getMessage().find(mAssemblerError) == string::npos) { 00416 // Error message doesn't have the expected string 00417 fail(mAssemblerError, ex.getMessage().c_str()); 00418 } else { 00419 // Error message is okay 00420 passed(mAssemblerError, ex.getMessage().c_str()); 00421 } 00422 } else { 00423 string errorStr = "Error assembling program: "; 00424 errorStr += ex.getMessage(); 00425 fail("Success assembling program", errorStr.c_str()); 00426 00427 if (showProgram) { 00428 // Dump out program 00429 ostringstream prog(""); 00430 prog << "Program Code: " << endl; 00431 prog << ex.getCode() << endl; 00432 prog << "Program Snippet: " << endl; 00433 prog << ex.getCodeSnippet() << endl; 00434 BOOST_MESSAGE(prog.str()); 00435 } 00436 } 00437 } 00438 00439 // Everything good? 00440 return (mAssembled && !mFailed); 00441 }
static string CalcAssemblerTestCase::tupleToString | ( | TupleDescriptor const & | tupleDesc, | |
TupleData * | tuple | |||
) | [inline, static] |
Definition at line 443 of file CalcAssemblerTest.cpp.
References TuplePrinter::print().
Referenced by test().
00446 { 00447 assert(tuple != NULL); 00448 ostringstream ostr(""); 00449 TuplePrinter tuplePrinter; 00450 tuplePrinter.print(ostr, tupleDesc, *tuple); 00451 return ostr.str(); 00452 }
bool CalcAssemblerTestCase::test | ( | CalcChecker * | pChecker = NULL |
) | [inline] |
Definition at line 454 of file CalcAssemblerTest.cpp.
References Calculator::bind(), CalcAssembler::createTupleData(), Calculator::exec(), fail(), FixedBuffer, Calculator::getInputRegisterDescriptor(), Calculator::getOutputRegisterDescriptor(), mAssembled, mCalc, mExpectedOutputTuple, mInputTuple, Calculator::mWarnings, passed(), and tupleToString().
Referenced by CalcAssemblerTest::testAdd(), CalcAssemblerTest::testBool(), CalcAssemblerTest::testComments(), CalcAssemblerTest::testExtended(), CalcAssemblerTest::testJump(), CalcAssemblerTest::testLiteralBinding(), CalcAssemblerTest::testPointer(), and CalcAssemblerTest::testReturn().
00455 { 00456 assert(mAssembled); 00457 bool res = true; 00458 00459 TupleDescriptor inputTupleDesc = mCalc.getInputRegisterDescriptor(); 00460 TupleDescriptor outputTupleDesc = mCalc.getOutputRegisterDescriptor(); 00461 00462 FixedBuffer* outputBuf; 00463 TupleData* outputTuple = CalcAssembler::createTupleData( 00464 outputTupleDesc, &outputBuf); 00465 00466 mCalc.bind(mInputTuple, outputTuple); 00467 00468 mCalc.exec(); 00469 00470 string instr = tupleToString(inputTupleDesc, mInputTuple); 00471 string outstr = tupleToString(outputTupleDesc, outputTuple); 00472 string expoutstr = tupleToString(outputTupleDesc, mExpectedOutputTuple); 00473 00474 if (pChecker == NULL) { 00475 // For now, let's just use the string representation of 00476 // the tuples for comparison 00477 res = (expoutstr == outstr); 00478 00479 // Make sure there are no warnings 00480 if (!mCalc.mWarnings.empty()) { 00481 res = false; 00482 fail(expoutstr.c_str(), "Calculator warnings"); 00483 //TEMP LATER 00484 //for (uint i=0; i < mCalc.mWarnings.size(); i++) { 00485 //printf( "Calc warning [%s]\n", mCalc.mWarnings[i].str ); 00486 //} 00487 } 00488 } else { 00489 res = pChecker->checkResult(mCalc, *outputTuple); 00490 } 00491 00492 if (res) { 00493 // Everything good and matches 00494 string resStr = instr + " -> " + outstr; 00495 passed(expoutstr.c_str(), resStr.c_str()); 00496 } else { 00497 string errorStr = "Calculator result: " ; 00498 errorStr += instr + " -> " + outstr; 00499 fail(expoutstr.c_str(), errorStr.c_str()); 00500 } 00501 00502 delete outputTuple; 00503 delete[] outputBuf; 00504 return res; 00505 }
void CalcAssemblerTestCase::expectAssemblerError | ( | const char * | err | ) | [inline] |
Definition at line 507 of file CalcAssemblerTest.cpp.
References mAssemblerError.
Referenced by CalcAssemblerTest::testAdd(), CalcAssemblerTest::testComments(), CalcAssemblerTest::testExtended(), CalcAssemblerTest::testInvalidPrograms(), CalcAssemblerTest::testJump(), and CalcAssemblerTest::testLiteralBinding().
00508 { 00509 mAssemblerError = err; 00510 }
void CalcAssemblerTestCase::writeMaxData | ( | TupleDatum & | datum, | |
uint | typeOrdinal | |||
) |
Definition at line 859 of file CalcAssemblerTest.cpp.
References TupleDatum::cbData, max(), MAX_WIDTH, TupleDatum::pData, STANDARD_TYPE_BINARY, STANDARD_TYPE_BOOL, STANDARD_TYPE_CHAR, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_INT_8, STANDARD_TYPE_REAL, STANDARD_TYPE_UINT_16, STANDARD_TYPE_UINT_32, STANDARD_TYPE_UINT_64, STANDARD_TYPE_UINT_8, STANDARD_TYPE_VARBINARY, and STANDARD_TYPE_VARCHAR.
Referenced by setTupleDatumMax().
00860 { 00861 PBuffer pData = const_cast<PBuffer>(datum.pData); 00862 switch (typeOrdinal) { 00863 case STANDARD_TYPE_BOOL: 00864 *(reinterpret_cast<bool *>(pData)) = true; 00865 break; 00866 case STANDARD_TYPE_INT_8: 00867 *(reinterpret_cast<int8_t *>(pData)) = 00868 std::numeric_limits<int8_t>::max(); 00869 break; 00870 case STANDARD_TYPE_UINT_8: 00871 *(reinterpret_cast<uint8_t *>(pData)) = 00872 std::numeric_limits<uint8_t>::max(); 00873 break; 00874 case STANDARD_TYPE_INT_16: 00875 *(reinterpret_cast<int16_t *>(pData)) = 00876 std::numeric_limits<int16_t>::max(); 00877 break; 00878 case STANDARD_TYPE_UINT_16: 00879 *(reinterpret_cast<uint16_t *>(pData)) = 00880 std::numeric_limits<uint16_t>::max(); 00881 break; 00882 case STANDARD_TYPE_INT_32: 00883 *(reinterpret_cast<int32_t *>(pData)) = 00884 std::numeric_limits<int32_t>::max(); 00885 break; 00886 case STANDARD_TYPE_UINT_32: 00887 *(reinterpret_cast<uint32_t *>(pData)) = 00888 std::numeric_limits<uint32_t>::max(); 00889 break; 00890 case STANDARD_TYPE_INT_64: 00891 *(reinterpret_cast<int64_t *>(pData)) = 00892 std::numeric_limits<int64_t>::max(); 00893 break; 00894 case STANDARD_TYPE_UINT_64: 00895 *(reinterpret_cast<uint64_t *>(pData)) = 00896 std::numeric_limits<uint64_t>::max(); 00897 break; 00898 case STANDARD_TYPE_REAL: 00899 *(reinterpret_cast<float *>(pData)) = 00900 std::numeric_limits<float>::max(); 00901 break; 00902 case STANDARD_TYPE_DOUBLE: 00903 *(reinterpret_cast<double *>(pData)) = 00904 std::numeric_limits<double>::max(); 00905 break; 00906 case STANDARD_TYPE_BINARY: 00907 memset(pData,0xFF,datum.cbData); 00908 break; 00909 case STANDARD_TYPE_CHAR: 00910 memset(pData,'z',datum.cbData); 00911 break; 00912 case STANDARD_TYPE_VARCHAR: 00913 datum.cbData = MAX_WIDTH; 00914 memset(pData,'z',datum.cbData); 00915 break; 00916 case STANDARD_TYPE_VARBINARY: 00917 datum.cbData = MAX_WIDTH; 00918 memset(pData,0xFF,datum.cbData); 00919 break; 00920 default: 00921 permAssert(false); 00922 } 00923 }
void CalcAssemblerTestCase::writeMinData | ( | TupleDatum & | datum, | |
uint | typeOrdinal | |||
) |
Definition at line 926 of file CalcAssemblerTest.cpp.
References TupleDatum::cbData, min(), TupleDatum::pData, STANDARD_TYPE_BINARY, STANDARD_TYPE_BOOL, STANDARD_TYPE_CHAR, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_INT_8, STANDARD_TYPE_REAL, STANDARD_TYPE_UINT_16, STANDARD_TYPE_UINT_32, STANDARD_TYPE_UINT_64, STANDARD_TYPE_UINT_8, STANDARD_TYPE_VARBINARY, and STANDARD_TYPE_VARCHAR.
Referenced by setTupleDatumMin().
00927 { 00928 PBuffer pData = const_cast<PBuffer>(datum.pData); 00929 switch (typeOrdinal) { 00930 case STANDARD_TYPE_BOOL: 00931 *(reinterpret_cast<bool *>(pData)) = false; 00932 break; 00933 case STANDARD_TYPE_INT_8: 00934 *(reinterpret_cast<int8_t *>(pData)) = 00935 std::numeric_limits<int8_t>::min(); 00936 break; 00937 case STANDARD_TYPE_UINT_8: 00938 *(reinterpret_cast<uint8_t *>(pData)) = 00939 std::numeric_limits<uint8_t>::min(); 00940 break; 00941 case STANDARD_TYPE_INT_16: 00942 *(reinterpret_cast<int16_t *>(pData)) = 00943 std::numeric_limits<int16_t>::min(); 00944 break; 00945 case STANDARD_TYPE_UINT_16: 00946 *(reinterpret_cast<uint16_t *>(pData)) = 00947 std::numeric_limits<uint16_t>::min(); 00948 break; 00949 case STANDARD_TYPE_INT_32: 00950 *(reinterpret_cast<int32_t *>(pData)) = 00951 std::numeric_limits<int32_t>::min(); 00952 break; 00953 case STANDARD_TYPE_UINT_32: 00954 *(reinterpret_cast<uint32_t *>(pData)) = 00955 std::numeric_limits<uint32_t>::min(); 00956 break; 00957 case STANDARD_TYPE_INT_64: 00958 *(reinterpret_cast<int64_t *>(pData)) = 00959 std::numeric_limits<int64_t>::min(); 00960 break; 00961 case STANDARD_TYPE_UINT_64: 00962 *(reinterpret_cast<uint64_t *>(pData)) = 00963 std::numeric_limits<uint64_t>::min(); 00964 break; 00965 case STANDARD_TYPE_REAL: 00966 *(reinterpret_cast<float *>(pData)) = 00967 std::numeric_limits<float>::min(); 00968 break; 00969 case STANDARD_TYPE_DOUBLE: 00970 *(reinterpret_cast<double *>(pData)) = 00971 std::numeric_limits<double>::min(); 00972 break; 00973 case STANDARD_TYPE_BINARY: 00974 memset(pData,0,datum.cbData); 00975 break; 00976 case STANDARD_TYPE_CHAR: 00977 memset(pData,'A',datum.cbData); 00978 break; 00979 case STANDARD_TYPE_VARCHAR: 00980 case STANDARD_TYPE_VARBINARY: 00981 datum.cbData = 0; 00982 break; 00983 default: 00984 permAssert(false); 00985 } 00986 }
string CalcAssemblerTestCase::toLiteralString | ( | TupleDatum & | datum, | |
uint | typeOrdinal | |||
) |
Definition at line 795 of file CalcAssemblerTest.cpp.
References TupleDatum::cbData, TupleDatum::pData, STANDARD_TYPE_BINARY, STANDARD_TYPE_BOOL, STANDARD_TYPE_CHAR, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_INT_8, STANDARD_TYPE_REAL, STANDARD_TYPE_UINT_16, STANDARD_TYPE_UINT_32, STANDARD_TYPE_UINT_64, STANDARD_TYPE_UINT_8, STANDARD_TYPE_VARBINARY, STANDARD_TYPE_VARCHAR, and stringToHex().
Referenced by getExpectedOutput(), and getInput().
00798 { 00799 // NOTE jvs 25-May-2007: casts to int64_t below are required 00800 // for a 64-bit build to pass 00801 00802 ostringstream ostr(""); 00803 if (datum.pData != NULL) { 00804 switch (typeOrdinal) { 00805 case STANDARD_TYPE_BOOL: 00806 if (*reinterpret_cast<const bool*>(datum.pData)) { 00807 ostr << "1"; 00808 } else { 00809 ostr << "0"; 00810 } 00811 break; 00812 case STANDARD_TYPE_INT_8: 00813 ostr << (int64_t) (*reinterpret_cast<const int8_t*>(datum.pData)); 00814 break; 00815 case STANDARD_TYPE_UINT_8: 00816 ostr << (int64_t) (*reinterpret_cast<const uint8_t*>(datum.pData)); 00817 break; 00818 case STANDARD_TYPE_INT_16: 00819 ostr << (int64_t) (*reinterpret_cast<const int16_t*>(datum.pData)); 00820 break; 00821 case STANDARD_TYPE_UINT_16: 00822 ostr << (int64_t) (*reinterpret_cast<const uint16_t*>(datum.pData)); 00823 break; 00824 case STANDARD_TYPE_INT_32: 00825 ostr << (int64_t) (*reinterpret_cast<const int32_t*>(datum.pData)); 00826 break; 00827 case STANDARD_TYPE_UINT_32: 00828 ostr << (int64_t) (*reinterpret_cast<const uint32_t*>(datum.pData)); 00829 break; 00830 case STANDARD_TYPE_INT_64: 00831 ostr << (*reinterpret_cast<const int64_t*>(datum.pData)); 00832 break; 00833 case STANDARD_TYPE_UINT_64: 00834 ostr << (*reinterpret_cast<const uint64_t*>(datum.pData)); 00835 break; 00836 case STANDARD_TYPE_REAL: 00837 ostr << (*reinterpret_cast<const float*>(datum.pData)); 00838 break; 00839 case STANDARD_TYPE_DOUBLE: 00840 ostr << (*reinterpret_cast<const double*>(datum.pData)); 00841 break; 00842 case STANDARD_TYPE_BINARY: 00843 case STANDARD_TYPE_CHAR: 00844 case STANDARD_TYPE_VARCHAR: 00845 case STANDARD_TYPE_VARBINARY: 00846 ostr << "0x"; 00847 ostr << stringToHex( 00848 (reinterpret_cast<const char*>(datum.pData)), 00849 datum.cbData); 00850 break; 00851 default: 00852 permAssert(false); 00853 } 00854 } 00855 return ostr.str(); 00856 }
void CalcAssemblerTestCase::setTupleDatumMax | ( | TupleDatum & | datum, | |
TupleAttributeDescriptor & | desc | |||
) | [inline] |
Definition at line 516 of file CalcAssemblerTest.cpp.
References StoredTypeDescriptor::getOrdinal(), TupleAttributeDescriptor::pTypeDescriptor, and writeMaxData().
Referenced by setExpectedOutputMax(), and setInputMax().
00517 { 00518 StoredTypeDescriptor::Ordinal type = desc.pTypeDescriptor->getOrdinal(); 00519 writeMaxData(datum, type); 00520 }
void CalcAssemblerTestCase::setTupleDatumMin | ( | TupleDatum & | datum, | |
TupleAttributeDescriptor & | desc | |||
) | [inline] |
Definition at line 522 of file CalcAssemblerTest.cpp.
References StoredTypeDescriptor::getOrdinal(), TupleAttributeDescriptor::pTypeDescriptor, and writeMinData().
Referenced by setExpectedOutputMin(), and setInputMin().
00523 { 00524 StoredTypeDescriptor::Ordinal type = desc.pTypeDescriptor->getOrdinal(); 00525 writeMinData(datum, type); 00526 }
void CalcAssemblerTestCase::setTupleDatumNull | ( | TupleDatum & | datum | ) | [inline] |
Definition at line 528 of file CalcAssemblerTest.cpp.
References TupleDatum::pData.
Referenced by setExpectedOutputNull(), and setInputNull().
00529 { 00530 datum.pData = NULL; 00531 }
void CalcAssemblerTestCase::setTupleDatum | ( | TupleDatum & | datum, | |
T | value | |||
) | [inline] |
Definition at line 534 of file CalcAssemblerTest.cpp.
References TupleDatum::pData.
Referenced by setExpectedOutput(), and setInput().
00535 { 00536 *(reinterpret_cast<T*>(const_cast<PBuffer>(datum.pData))) = value; 00537 }
void CalcAssemblerTestCase::setTupleDatum | ( | TupleDatum & | datum, | |
TupleAttributeDescriptor & | desc, | |||
T * | buf, | |||
uint | buflen | |||
) | [inline] |
Definition at line 540 of file CalcAssemblerTest.cpp.
References TupleDatum::cbData, TupleAttributeDescriptor::cbStorage, StoredTypeDescriptor::getOrdinal(), TupleDatum::pData, TupleAttributeDescriptor::pTypeDescriptor, STANDARD_TYPE_BINARY, STANDARD_TYPE_CHAR, STANDARD_TYPE_VARBINARY, and STANDARD_TYPE_VARCHAR.
00545 { 00546 assert(buf != NULL); 00547 StoredTypeDescriptor::Ordinal type = desc.pTypeDescriptor->getOrdinal(); 00548 00549 T* ptr = reinterpret_cast<T*>(const_cast<PBuffer>(datum.pData)); 00550 switch (type) { 00551 case STANDARD_TYPE_CHAR: 00552 case STANDARD_TYPE_BINARY: 00553 // Fixed length storage 00554 assert(buflen <= datum.cbData); 00555 memset((void*) ptr, 0, datum.cbData); // Fill with 0 00556 memcpy((void*) ptr, buf, buflen); 00557 break; 00558 00559 case STANDARD_TYPE_VARCHAR: 00560 case STANDARD_TYPE_VARBINARY: 00561 // Variable length storage 00562 assert(buflen <= desc.cbStorage); 00563 memset((void*)ptr, 'I', desc.cbStorage); // Fill with junk 00564 memcpy((void*)ptr, buf, buflen); 00565 datum.cbData = buflen; 00566 break; 00567 00568 default: 00569 permAssert(false); 00570 } 00571 }
void CalcAssemblerTestCase::setInputMin | ( | uint | index | ) | [inline] |
Definition at line 573 of file CalcAssemblerTest.cpp.
References Calculator::getInputRegisterDescriptor(), mCalc, mInputTuple, and setTupleDatumMin().
00574 { 00575 assert(mInputTuple != NULL); 00576 assert(index < mInputTuple->size()); 00577 TupleDescriptor inputTupleDesc = mCalc.getInputRegisterDescriptor(); 00578 setTupleDatumMin((*mInputTuple)[index], inputTupleDesc[index]); 00579 }
void CalcAssemblerTestCase::setInputMax | ( | uint | index | ) | [inline] |
Definition at line 581 of file CalcAssemblerTest.cpp.
References Calculator::getInputRegisterDescriptor(), mCalc, mInputTuple, and setTupleDatumMax().
00582 { 00583 assert(mInputTuple != NULL); 00584 assert(index < mInputTuple->size()); 00585 TupleDescriptor inputTupleDesc = mCalc.getInputRegisterDescriptor(); 00586 setTupleDatumMax((*mInputTuple)[index], inputTupleDesc[index]); 00587 }
void CalcAssemblerTestCase::setInputNull | ( | uint | index | ) | [inline] |
Definition at line 589 of file CalcAssemblerTest.cpp.
References mInputTuple, and setTupleDatumNull().
00590 { 00591 assert(mInputTuple != NULL); 00592 assert(index < mInputTuple->size()); 00593 setTupleDatumNull((*mInputTuple)[index]); 00594 }
void CalcAssemblerTestCase::setInput | ( | uint | index, | |
T | value | |||
) | [inline] |
Definition at line 597 of file CalcAssemblerTest.cpp.
References mInputTuple, and setTupleDatum().
Referenced by CalcAssemblerTest::testAdd(), CalcAssemblerTest::testComments(), CalcAssemblerTest::testExtended(), CalcAssemblerTest::testJump(), CalcAssemblerTest::testPointer(), and CalcAssemblerTest::testReturn().
00598 { 00599 assert(mInputTuple != NULL); 00600 assert(index < mInputTuple->size()); 00601 setTupleDatum((*mInputTuple)[index], value); 00602 }
void CalcAssemblerTestCase::setInput | ( | uint | index, | |
T * | buf, | |||
uint | buflen | |||
) | [inline] |
Definition at line 605 of file CalcAssemblerTest.cpp.
References Calculator::getInputRegisterDescriptor(), mCalc, mInputTuple, and setTupleDatum().
00606 { 00607 assert(mInputTuple != NULL); 00608 assert(index < mInputTuple->size()); 00609 TupleDescriptor inputTupleDesc = mCalc.getInputRegisterDescriptor(); 00610 setTupleDatum( 00611 (*mInputTuple)[index], 00612 inputTupleDesc[index], 00613 buf, 00614 buflen); 00615 }
string CalcAssemblerTestCase::getInput | ( | uint | index | ) | [inline] |
Definition at line 617 of file CalcAssemblerTest.cpp.
References Calculator::getInputRegisterDescriptor(), mCalc, mInputTuple, and toLiteralString().
00618 { 00619 assert(mInputTuple != NULL); 00620 assert(index < mInputTuple->size()); 00621 TupleDescriptor inputTupleDesc = mCalc.getInputRegisterDescriptor(); 00622 return toLiteralString( 00623 (*mInputTuple)[index], 00624 inputTupleDesc[index].pTypeDescriptor->getOrdinal()); 00625 }
TupleData* CalcAssemblerTestCase::getInputTuple | ( | ) | [inline] |
Definition at line 627 of file CalcAssemblerTest.cpp.
References mInputTuple.
00628 { 00629 return mInputTuple; 00630 }
void CalcAssemblerTestCase::setExpectedOutputNull | ( | uint | index | ) | [inline] |
Definition at line 633 of file CalcAssemblerTest.cpp.
References mExpectedOutputTuple, and setTupleDatumNull().
00634 { 00635 assert(mExpectedOutputTuple != NULL); 00636 assert(index < mExpectedOutputTuple->size()); 00637 setTupleDatumNull((*mExpectedOutputTuple)[index]); 00638 }
void CalcAssemblerTestCase::setExpectedOutputMax | ( | uint | index | ) | [inline] |
Definition at line 640 of file CalcAssemblerTest.cpp.
References Calculator::getOutputRegisterDescriptor(), mCalc, mExpectedOutputTuple, and setTupleDatumMax().
00641 { 00642 assert(mExpectedOutputTuple != NULL); 00643 assert(index < mExpectedOutputTuple->size()); 00644 TupleDescriptor outputTupleDesc = mCalc.getOutputRegisterDescriptor(); 00645 setTupleDatumMax( 00646 (*mExpectedOutputTuple)[index], 00647 outputTupleDesc[index]); 00648 }
void CalcAssemblerTestCase::setExpectedOutputMin | ( | uint | index | ) | [inline] |
Definition at line 649 of file CalcAssemblerTest.cpp.
References Calculator::getOutputRegisterDescriptor(), mCalc, mExpectedOutputTuple, and setTupleDatumMin().
00650 { 00651 assert(mExpectedOutputTuple != NULL); 00652 assert(index < mExpectedOutputTuple->size()); 00653 TupleDescriptor outputTupleDesc = mCalc.getOutputRegisterDescriptor(); 00654 setTupleDatumMin( 00655 (*mExpectedOutputTuple)[index], 00656 outputTupleDesc[index]); 00657 }
void CalcAssemblerTestCase::setExpectedOutput | ( | uint | index, | |
T | value | |||
) | [inline] |
Definition at line 660 of file CalcAssemblerTest.cpp.
References mExpectedOutputTuple, and setTupleDatum().
Referenced by CalcAssemblerTest::testAdd(), CalcAssemblerTest::testBool(), CalcAssemblerTest::testComments(), CalcAssemblerTest::testExtended(), CalcAssemblerTest::testJump(), CalcAssemblerTest::testLiteralBinding(), CalcAssemblerTest::testPointer(), and CalcAssemblerTest::testReturn().
00661 { 00662 assert(mExpectedOutputTuple != NULL); 00663 assert(index < mExpectedOutputTuple->size()); 00664 setTupleDatum((*mExpectedOutputTuple)[index], value); 00665 }
void CalcAssemblerTestCase::setExpectedOutput | ( | uint | index, | |
T * | buf, | |||
uint | buflen | |||
) | [inline] |
Definition at line 668 of file CalcAssemblerTest.cpp.
References Calculator::getOutputRegisterDescriptor(), mCalc, mExpectedOutputTuple, and setTupleDatum().
00669 { 00670 assert(mExpectedOutputTuple != NULL); 00671 assert(index < mExpectedOutputTuple->size()); 00672 TupleDescriptor outputTupleDesc = mCalc.getOutputRegisterDescriptor(); 00673 setTupleDatum( 00674 (*mExpectedOutputTuple)[index], 00675 outputTupleDesc[index], 00676 buf, 00677 buflen); 00678 }
string CalcAssemblerTestCase::getExpectedOutput | ( | uint | index | ) | [inline] |
Definition at line 680 of file CalcAssemblerTest.cpp.
References Calculator::getOutputRegisterDescriptor(), mCalc, mExpectedOutputTuple, and toLiteralString().
00681 { 00682 assert(mExpectedOutputTuple != NULL); 00683 assert(index < mExpectedOutputTuple->size()); 00684 TupleDescriptor outputTupleDesc = mCalc.getOutputRegisterDescriptor(); 00685 return toLiteralString( 00686 (*mExpectedOutputTuple)[index], 00687 outputTupleDesc[index].pTypeDescriptor->getOrdinal()); 00688 }
TupleData* CalcAssemblerTestCase::getExpectedOutputTuple | ( | ) | [inline] |
Definition at line 690 of file CalcAssemblerTest.cpp.
References mExpectedOutputTuple.
00691 { 00692 return mExpectedOutputTuple; 00693 }
bool CalcAssemblerTestCase::failed | ( | ) | [inline] |
Definition at line 695 of file CalcAssemblerTest.cpp.
References mFailed.
00696 { 00697 return mFailed; 00698 }
const uint CalcAssemblerTestCase::MAX_WIDTH = 512 [static] |
Definition at line 311 of file CalcAssemblerTest.cpp.
Referenced by CalcAssemblerTest::testBoolInstructions(), CalcAssemblerTest::testIntegralNativeInstructions(), CalcAssemblerTest::testNativeInstructions(), CalcAssemblerTest::testStandardTypes(), and writeMaxData().
const char* CalcAssemblerTestCase::mDescription [protected] |
const char* CalcAssemblerTestCase::mProgram [protected] |
const char* CalcAssemblerTestCase::mAssemblerError [protected] |
Definition at line 703 of file CalcAssemblerTest.cpp.
Referenced by assemble(), and expectAssemblerError().
TupleData* CalcAssemblerTestCase::mInputTuple [protected] |
Definition at line 704 of file CalcAssemblerTest.cpp.
Referenced by assemble(), getInput(), getInputTuple(), setInput(), setInputMax(), setInputMin(), setInputNull(), test(), and ~CalcAssemblerTestCase().
TupleData* CalcAssemblerTestCase::mExpectedOutputTuple [protected] |
Definition at line 705 of file CalcAssemblerTest.cpp.
Referenced by assemble(), getExpectedOutput(), getExpectedOutputTuple(), setExpectedOutput(), setExpectedOutputMax(), setExpectedOutputMin(), setExpectedOutputNull(), test(), and ~CalcAssemblerTestCase().
FixedBuffer* CalcAssemblerTestCase::mInputBuf [protected] |
Definition at line 706 of file CalcAssemblerTest.cpp.
Referenced by assemble(), and ~CalcAssemblerTestCase().
FixedBuffer* CalcAssemblerTestCase::mExpOutputBuf [protected] |
Definition at line 707 of file CalcAssemblerTest.cpp.
Referenced by assemble(), and ~CalcAssemblerTestCase().
bool CalcAssemblerTestCase::mFailed [protected] |
Definition at line 708 of file CalcAssemblerTest.cpp.
Referenced by assemble(), fail(), and failed().
bool CalcAssemblerTestCase::mAssembled [protected] |
uint CalcAssemblerTestCase::mID [protected] |
uint CalcAssemblerTestCase::mLine [protected] |
Calculator CalcAssemblerTestCase::mCalc [protected] |
Definition at line 713 of file CalcAssemblerTest.cpp.
Referenced by assemble(), getExpectedOutput(), getInput(), setExpectedOutput(), setExpectedOutputMax(), setExpectedOutputMin(), setInput(), setInputMax(), setInputMin(), and test().
uint CalcAssemblerTestCase::testID [static, protected] |
uint CalcAssemblerTestCase::nFailed [static, protected] |
uint CalcAssemblerTestCase::nPassed [static, protected] |
Definition at line 716 of file CalcAssemblerTest.cpp.
Referenced by getPassedNumber(), and passed().