Inheritance diagram for CalcExtCastTest:
Public Member Functions | |
CalcExtCastTest () | |
virtual | ~CalcExtCastTest () |
TestSuite * | releaseTestSuite () |
void | beforeTestCase (std::string testCaseName) |
void | afterTestCase (std::string testCaseName) |
virtual void | testCaseSetUp () |
Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked. | |
virtual void | testCaseTearDown () |
Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked. | |
virtual void | notifyTrace (std::string source, TraceLevel level, std::string message) |
Receives notification when a trace event occurs. | |
virtual TraceLevel | getSourceTraceLevel (std::string source) |
Gets the level at which a particular source should be traced. | |
virtual void | initTraceSource (SharedTraceTarget pTraceTarget, std::string name) |
For use when initialization has to be deferred until after construction. | |
void | trace (TraceLevel level, std::string message) const |
Records a trace message. | |
bool | isTracing () const |
| |
bool | isTracingLevel (TraceLevel level) const |
Determines whether a particular level is being traced. | |
TraceTarget & | getTraceTarget () const |
| |
SharedTraceTarget | getSharedTraceTarget () const |
| |
std::string | getTraceSourceName () const |
Gets the name of this source. | |
void | setTraceSourceName (std::string const &n) |
Sets the name of this source. | |
TraceLevel | getMinimumTraceLevel () const |
void | disableTracing () |
Static Public Member Functions | |
static void | readParams (int argc, char **argv) |
Parses the command line. | |
Static Public Attributes | |
static ParamName | paramTestSuiteName |
static ParamName | paramTraceFileName |
static ParamName | paramDictionaryFileName |
static ParamName | paramTraceLevel |
static ParamName | paramStatsFileName |
static ParamName | paramTraceStdout |
static ParamName | paramDegreeOfParallelism |
static ConfigMap | configMap |
Configuration parameters. | |
Protected Member Functions | |
void | snooze (uint nSeconds) |
Protected Attributes | |
TestSuite * | pTestSuite |
Boost test suite. | |
boost::shared_ptr< TestBase > | pTestObj |
std::ofstream | traceStream |
Output file stream for tracing. | |
StrictMutex | traceMutex |
Protects traceStream. | |
std::string | testName |
Name of test. | |
TraceLevel | traceLevel |
Level at which to trace test execution. | |
FileStatsTarget | statsTarget |
Output for stats. | |
StatsTimer | statsTimer |
Timer for stats collection. | |
bool | traceStdout |
Copy trace output to stdout. | |
bool | traceFile |
Copy trace output to file. | |
TestCaseGroup | defaultTests |
TestCaseGroup | extraTests |
Static Protected Attributes | |
static bool | runAll |
Run all test cases, including the extra tests. | |
static std::string | runSingle |
Run only the test case of this name. | |
Private Member Functions | |
void | testCalcExtCastStringToChar () |
void | testCalcExtCastStringToVarChar () |
void | testCalcExtCastBooleanToChar () |
void | testCalcExtCastBooleanToVarChar () |
void | testCalcExtCastExactToChar () |
void | testCalcExtCastExactToVarChar () |
void | testCalcExtCastDecimalToChar () |
void | testCalcExtCastDecimalToVarChar () |
void | testCalcExtCastBigExactToString () |
void | testCalcExtCastExactToStringTruncates () |
void | testCalcExtCastDecimalToStringTruncates () |
void | testCalcExtCastCharToBoolean () |
void | testCalcExtCastVarCharToBoolean () |
void | testCalcExtCastCharToExact () |
void | testCalcExtCastVarCharToExact () |
void | testCalcExtCastCharToDecimal () |
void | testCalcExtCastVarCharToDecimal () |
void | testCalcExtCastStringToExactFails () |
void | testCalcExtCastStringToDecimalFails () |
void | testCalcExtCastStringToDecimalMinMax () |
void | testCalcExtCastStringToDecimalRange () |
void | testCalcExtCastStringToApprox () |
void | testCalcExtCastApproxToString () |
int | cmpTupStr (TupleDatum const &tup, char const *const str) |
int | cmpTupStr (TupleDatum const &tup, const string &str) |
int | cmpTupBool (TupleDatum const &tup, bool val) |
int | cmpTupInt (TupleDatum const &tup, int val) |
int | cmpTupInt64 (TupleDatum const &tup, int64_t val) |
int | cmpTupNull (TupleDatum const &tup) |
int | cmpTupDouble (TupleDatum const &tup, double val) |
void | printOutput (TupleData const &tup, Calculator const &calc) |
void | refLocalOutput (ostringstream &pg, int count) |
string | minInt64String () |
string | maxInt64String () |
string | rpad (string s, int size, char pad= ' ') |
Static Private Attributes | |
static const bool | verbose = true |
static const char * | truncErr |
static const char * | invalidCharErr |
static const char * | outOfRangeErr |
Definition at line 43 of file CalcExtCastTest.cpp.
CalcExtCastTest::CalcExtCastTest | ( | ) | [inline, explicit] |
Definition at line 92 of file CalcExtCastTest.cpp.
References CalcInit::instance(), testCalcExtCastApproxToString(), testCalcExtCastBigExactToString(), testCalcExtCastBooleanToChar(), testCalcExtCastBooleanToVarChar(), testCalcExtCastCharToBoolean(), testCalcExtCastCharToDecimal(), testCalcExtCastCharToExact(), testCalcExtCastDecimalToChar(), testCalcExtCastDecimalToStringTruncates(), testCalcExtCastDecimalToVarChar(), testCalcExtCastExactToChar(), testCalcExtCastExactToStringTruncates(), testCalcExtCastExactToVarChar(), testCalcExtCastStringToApprox(), testCalcExtCastStringToChar(), testCalcExtCastStringToDecimalFails(), testCalcExtCastStringToDecimalMinMax(), testCalcExtCastStringToDecimalRange(), testCalcExtCastStringToExactFails(), testCalcExtCastStringToVarChar(), testCalcExtCastVarCharToBoolean(), testCalcExtCastVarCharToDecimal(), and testCalcExtCastVarCharToExact().
00093 : TraceSource(shared_from_this(),"CalcExtCastTest") 00094 { 00095 srand(time(NULL)); 00096 CalcInit::instance(); 00097 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastStringToChar); 00098 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastStringToVarChar); 00099 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastBooleanToVarChar); 00100 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastBooleanToChar); 00101 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastExactToVarChar); 00102 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastExactToChar); 00103 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastDecimalToChar); 00104 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastDecimalToVarChar); 00105 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastBigExactToString); 00106 FENNEL_UNIT_TEST_CASE( 00107 CalcExtCastTest, testCalcExtCastExactToStringTruncates); // errors 00108 FENNEL_UNIT_TEST_CASE( 00109 CalcExtCastTest, testCalcExtCastDecimalToStringTruncates); // errors 00110 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastCharToBoolean); 00111 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastVarCharToBoolean); 00112 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastCharToExact); 00113 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastVarCharToExact); 00114 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastCharToDecimal); 00115 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastVarCharToDecimal); 00116 FENNEL_UNIT_TEST_CASE( 00117 CalcExtCastTest, testCalcExtCastStringToExactFails); 00118 FENNEL_UNIT_TEST_CASE( 00119 CalcExtCastTest, testCalcExtCastStringToDecimalFails); 00120 FENNEL_UNIT_TEST_CASE( 00121 CalcExtCastTest, testCalcExtCastStringToDecimalMinMax); 00122 FENNEL_UNIT_TEST_CASE( 00123 CalcExtCastTest, testCalcExtCastStringToDecimalRange); 00124 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastStringToApprox); 00125 FENNEL_UNIT_TEST_CASE(CalcExtCastTest, testCalcExtCastApproxToString); 00126 }
virtual CalcExtCastTest::~CalcExtCastTest | ( | ) | [inline, virtual] |
void CalcExtCastTest::testCalcExtCastStringToChar | ( | ) | [private] |
Definition at line 269 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
00270 { 00271 ostringstream pg(""), outloc(""); 00272 00273 outloc << "c,5, c,5, c,5, c,5, c,5, c,5, c,5, c,5;" << endl; 00274 00275 pg << "O " << outloc.str(); 00276 pg << "L " << outloc.str(); 00277 pg << "C vc,3, vc,8, c,3, c,8, vc,8, c,8, vc,8, c,8;" << endl; 00278 pg << "V 0x" << stringToHex("ABC"); 00279 pg << ", 0x" << stringToHex("DEFGH"); 00280 pg << ", 0x" << stringToHex("ZYX"); 00281 pg << ", 0x" << stringToHex("WVUTS "); 00282 pg << ", 0x" << stringToHex("IJKLMNOP"); 00283 pg << ", 0x" << stringToHex("RQPONMLK"); 00284 pg << ",,;" << endl; 00285 pg << "T;" << endl; 00286 00287 // vc(3) -> c(5) 00288 pg << "CALL 'castA(L0, C0);" << endl; 00289 00290 // vc(8), length5 -> c(5) 00291 pg << "CALL 'castA(L1, C1);" << endl; 00292 00293 // c(3) -> c(5) 00294 pg << "CALL 'castA(L2, C2);" << endl; 00295 00296 // c(8) -> c(5) 00297 pg << "CALL 'castA(L3, C3);" << endl; 00298 00299 // vc(8), length 8 -> c(5) = 22001 00300 pg << "CALL 'castA(L4, C4);" << endl; 00301 00302 // c(8) -> c(5) = 22001 00303 pg << "CALL 'castA(L5, C5);" << endl; 00304 00305 // null vc(8) -> c(5) 00306 pg << "CALL 'castA(L6, C6);" << endl; 00307 00308 // null c(8) -> c(5) 00309 pg << "CALL 'castA(L7, C7);" << endl; 00310 00311 // make output available 00312 refLocalOutput(pg, 8); 00313 00314 Calculator calc(0); 00315 00316 try { 00317 calc.assemble(pg.str().c_str()); 00318 } catch (FennelExcn& ex) { 00319 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00320 BOOST_MESSAGE(pg.str()); 00321 BOOST_REQUIRE(0); 00322 } 00323 00324 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00325 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00326 00327 calc.bind(&inTuple, &outTuple); 00328 calc.exec(); 00329 printOutput(outTuple, calc); 00330 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00331 00332 // vc(3) -> c(5) 00333 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[0], "ABC ")); 00334 00335 // vc(8), length 5 -> c(5) 00336 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], "DEFGH")); 00337 00338 // c(3) - > c(5) 00339 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], "ZYX ")); 00340 00341 // c(8) -> c(5) 00342 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], "WVUTS")); 00343 00344 // vc(8), length 8 -> c(5) = 22001 00345 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[4], "IJKLM")); 00346 // TODO: when 22001 is thrown as a warning, re-enable this 00347 // BOOST_CHECK_EQUAL(iter->pc, 4); 00348 // BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 00349 // iter++; 00350 00351 // c(8) -> c(5) = 22001 00352 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[5], "RQPON")); 00353 // TODO: when 22001 is thrown as a warning, re-enable this 00354 // BOOST_CHECK_EQUAL(iter->pc, 5); 00355 // BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 00356 // iter++; 00357 00358 // null vc(8) -> c(5) 00359 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[6])); 00360 00361 // null c(8) -> c(5) 00362 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[7])); 00363 00364 BOOST_CHECK(iter == calc.mWarnings.end()); 00365 }
void CalcExtCastTest::testCalcExtCastStringToVarChar | ( | ) | [private] |
Definition at line 369 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
00370 { 00371 ostringstream pg(""), outloc(""); 00372 00373 outloc << "vc,5, vc,5, vc,5, vc,5, vc,5, vc,5, vc,5, vc,5;" << endl; 00374 00375 pg << "O " << outloc.str(); 00376 pg << "L " << outloc.str(); 00377 pg << "C vc,3, vc,8, c,3, c,8, vc,8, c,8, vc,8, c,8;" << endl; 00378 pg << "V 0x" << stringToHex("ABC"); 00379 pg << ", 0x" << stringToHex("DEFGH"); 00380 pg << ", 0x" << stringToHex("ZYX"); 00381 pg << ", 0x" << stringToHex("WVUTS "); 00382 pg << ", 0x" << stringToHex("IJKLMNOP"); 00383 pg << ", 0x" << stringToHex("RQPONMLK"); 00384 pg << ",,;" << endl; 00385 pg << "T;" << endl; 00386 00387 // vc(3) -> vc(5) 00388 pg << "CALL 'castA(L0, C0);" << endl; 00389 00390 // vc(8), length5 -> vc(5) 00391 pg << "CALL 'castA(L1, C1);" << endl; 00392 00393 // c(3) -> vc(5) 00394 pg << "CALL 'castA(L2, C2);" << endl; 00395 00396 // c(8) -> vc(5) 00397 pg << "CALL 'castA(L3, C3);" << endl; 00398 00399 // vc(8), length 8 -> vc(5) = 22001 00400 pg << "CALL 'castA(L4, C4);" << endl; 00401 00402 // c(8) -> vc(5) = 22001 00403 pg << "CALL 'castA(L5, C5);" << endl; 00404 00405 // null vc(8) -> vc(5) 00406 pg << "CALL 'castA(L6, C6);" << endl; 00407 00408 // null c(8) -> vc(5) 00409 pg << "CALL 'castA(L7, C7);" << endl; 00410 00411 // make output available 00412 refLocalOutput(pg, 8); 00413 00414 Calculator calc(0); 00415 00416 try { 00417 calc.assemble(pg.str().c_str()); 00418 } catch (FennelExcn& ex) { 00419 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00420 BOOST_MESSAGE(pg.str()); 00421 BOOST_REQUIRE(0); 00422 } 00423 00424 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00425 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00426 00427 calc.bind(&inTuple, &outTuple); 00428 calc.exec(); 00429 printOutput(outTuple, calc); 00430 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00431 00432 // vc(3) -> vc(5) 00433 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[0], "ABC")); 00434 00435 // vc(8), length 5 -> vc(5) 00436 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], "DEFGH")); 00437 00438 // c(3) - > vc(5) 00439 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], "ZYX")); 00440 00441 // c(8) -> vc(5) 00442 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], "WVUTS")); 00443 00444 // vc(8), length 8 -> vc(5) = 22001 00445 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[4], "IJKLM")); 00446 // TODO: when 22001 is thrown as a warning, re-enable this 00447 // BOOST_CHECK_EQUAL(iter->pc, 4); 00448 // BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 00449 // iter++; 00450 00451 // c(8) -> vc(5) = 22001 00452 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[5], "RQPON")); 00453 // TODO: when 22001 is thrown as a warning, re-enable this 00454 // BOOST_CHECK_EQUAL(iter->pc, 5); 00455 // BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 00456 // iter++; 00457 00458 // null vc(8) -> vc(5) 00459 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[6])); 00460 00461 // null c(8) -> vc(5) 00462 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[7])); 00463 00464 BOOST_CHECK(iter == calc.mWarnings.end()); 00465 }
void CalcExtCastTest::testCalcExtCastBooleanToChar | ( | ) | [private] |
Definition at line 469 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), invalidCharErr, Calculator::mWarnings, printOutput(), and refLocalOutput().
Referenced by CalcExtCastTest().
00470 { 00471 // int8 test values: (null, true, false), 00472 // cast to CHAR(3) and CHAR(4) and CHAR(5) 00473 ostringstream pg(""), outloc(""); 00474 outloc << "c,3, c,3, c,3, c,4, c,4, c,4, c,5, c,5, c,5;" << endl; 00475 pg << "O " << outloc.str(); 00476 pg << "L " << outloc.str(); 00477 pg << "C bo, bo, bo;" << endl; 00478 pg << "V , 1, 0;" << endl; 00479 pg << "T;" << endl; 00480 // cast all to CHAR(3) 00481 for (int i = 0; i < 3; i++) { 00482 pg << "CALL 'castA(L" << i << ", C" << i << ");" << endl; 00483 } 00484 // cast all to CHAR(4) 00485 for (int i = 0; i < 3; i++) { 00486 pg << "CALL 'castA(L" << (i + 3) << ", C" << i << ");" << endl; 00487 } 00488 // cast all to CHAR(5) 00489 for (int i = 0; i < 3; i++) { 00490 pg << "CALL 'castA(L" << (i + 6) << ", C" << i << ");" << endl; 00491 } 00492 refLocalOutput(pg, 9); // make output available 00493 00494 Calculator calc(0); 00495 try { 00496 calc.assemble(pg.str().c_str()); 00497 } catch (FennelExcn& ex) { 00498 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00499 BOOST_MESSAGE(pg.str()); 00500 BOOST_REQUIRE(0); 00501 } 00502 00503 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00504 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00505 calc.bind(&inTuple, &outTuple); 00506 calc.exec(); 00507 printOutput(outTuple, calc); 00508 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00509 00510 // check results: 00511 BOOST_CHECK(cmpTupNull(outTuple[0])); 00512 00513 // true -> c(3) = invalid char 00514 BOOST_CHECK_EQUAL(iter->pc, 1); 00515 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 00516 iter++; 00517 00518 // false -> c(3) = invalid char 00519 BOOST_CHECK_EQUAL(iter->pc, 2); 00520 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 00521 iter++; 00522 00523 BOOST_CHECK(cmpTupNull(outTuple[3])); 00524 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[4], "TRUE")); 00525 00526 // false -> c(4) = invalid char 00527 BOOST_CHECK_EQUAL(iter->pc, 5); 00528 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 00529 iter++; 00530 00531 BOOST_CHECK(cmpTupNull(outTuple[6])); 00532 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[7], "TRUE ")); 00533 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[8], "FALSE")); 00534 BOOST_CHECK(iter == calc.mWarnings.end()); 00535 }
void CalcExtCastTest::testCalcExtCastBooleanToVarChar | ( | ) | [private] |
Definition at line 539 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), invalidCharErr, Calculator::mWarnings, printOutput(), and refLocalOutput().
Referenced by CalcExtCastTest().
00540 { 00541 // int8 test values: (null, true, false), 00542 // cast to VARCHAR(3) and VARCHAR(4) and VARCHAR(5) 00543 ostringstream pg(""), outloc(""); 00544 outloc << "vc,3, vc,3, vc,3, vc,4, vc,4, vc,4, vc,5, vc,5, vc,5;" << endl; 00545 pg << "O " << outloc.str(); 00546 pg << "L " << outloc.str(); 00547 pg << "C bo, bo, bo;" << endl; 00548 pg << "V , 1, 0;" << endl; 00549 pg << "T;" << endl; 00550 // cast all to VARCHAR(3) 00551 for (int i = 0; i < 3; i++) { 00552 pg << "CALL 'castA(L" << i << ", C" << i << ");" << endl; 00553 } 00554 // cast all to VARCHAR(4) 00555 for (int i = 0; i < 3; i++) { 00556 pg << "CALL 'castA(L" << (i + 3) << ", C" << i << ");" << endl; 00557 } 00558 // cast all to VARCHAR(5) 00559 for (int i = 0; i < 3; i++) { 00560 pg << "CALL 'castA(L" << (i + 6) << ", C" << i << ");" << endl; 00561 } 00562 refLocalOutput(pg, 9); // make output available 00563 00564 Calculator calc(0); 00565 try { 00566 calc.assemble(pg.str().c_str()); 00567 } catch (FennelExcn& ex) { 00568 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00569 BOOST_MESSAGE(pg.str()); 00570 BOOST_REQUIRE(0); 00571 } 00572 00573 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00574 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00575 calc.bind(&inTuple, &outTuple); 00576 calc.exec(); 00577 printOutput(outTuple, calc); 00578 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00579 00580 // check results: 00581 BOOST_CHECK(cmpTupNull(outTuple[0])); 00582 00583 // true -> vc(3) = invalid char 00584 BOOST_CHECK_EQUAL(iter->pc, 1); 00585 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 00586 iter++; 00587 00588 // false -> vc(3) = invalid char 00589 BOOST_CHECK_EQUAL(iter->pc, 2); 00590 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 00591 iter++; 00592 00593 BOOST_CHECK(cmpTupNull(outTuple[3])); 00594 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[4], "TRUE")); 00595 00596 // false -> vc(4) = invalid char 00597 BOOST_CHECK_EQUAL(iter->pc, 5); 00598 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 00599 iter++; 00600 00601 BOOST_CHECK(cmpTupNull(outTuple[6])); 00602 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[7], "TRUE")); 00603 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[8], "FALSE")); 00604 BOOST_CHECK(iter == calc.mWarnings.end()); 00605 }
void CalcExtCastTest::testCalcExtCastExactToChar | ( | ) | [private] |
Definition at line 609 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), and refLocalOutput().
Referenced by CalcExtCastTest().
00610 { 00611 // int8 test values: (null, 0, 10, -10), cast to CHAR(3) and CHAR(16) 00612 ostringstream pg(""), outloc(""); 00613 outloc << "c,3, c,3, c,3, c,3, c,16, c,16, c,16, c,16;" << endl; 00614 pg << "O " << outloc.str(); 00615 pg << "L " << outloc.str(); 00616 pg << "C s8, s8, s8, s8;" << endl; 00617 pg << "V , 0, 10, -10;" << endl; 00618 pg << "T;" << endl; 00619 // cast all to CHAR(3) 00620 for (int i = 0; i < 4; i++) { 00621 pg << "CALL 'castA(L" << i << ", C" << i << ");" << endl; 00622 } 00623 // cast all to CHAR(16) 00624 for (int i = 0; i < 4; i++) { 00625 pg << "CALL 'castA(L" << (i + 4) << ", C" << i << ");" << endl; 00626 } 00627 refLocalOutput(pg, 8); // make output available 00628 00629 Calculator calc(0); 00630 try { 00631 calc.assemble(pg.str().c_str()); 00632 } catch (FennelExcn& ex) { 00633 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00634 BOOST_MESSAGE(pg.str()); 00635 BOOST_REQUIRE(0); 00636 } 00637 00638 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00639 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00640 calc.bind(&inTuple, &outTuple); 00641 calc.exec(); 00642 printOutput(outTuple, calc); 00643 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00644 00645 // check results: 00646 BOOST_CHECK(cmpTupNull(outTuple[0])); 00647 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], "0 ")); 00648 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], "10 ")); 00649 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], "-10")); 00650 BOOST_CHECK(cmpTupNull(outTuple[4])); 00651 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[5], "0 ")); 00652 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[6], "10 ")); 00653 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[7], "-10 ")); 00654 BOOST_CHECK(iter == calc.mWarnings.end()); 00655 }
void CalcExtCastTest::testCalcExtCastExactToVarChar | ( | ) | [private] |
Definition at line 659 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), and refLocalOutput().
Referenced by CalcExtCastTest().
00660 { 00661 // int8 test values: (null, 0, 10, -10), cast to VARCHAR(3) and VARCHAR(16). 00662 ostringstream pg(""), outloc(""); 00663 outloc << "vc,3, vc,3, vc,3, vc,3, vc,16, vc,16, vc,16, vc,16;" << endl; 00664 pg << "O " << outloc.str(); 00665 pg << "L " << outloc.str(); 00666 pg << "C s8, s8, s8, s8;" << endl; 00667 pg << "V , 0, 10, -10;" << endl; 00668 pg << "T;" << endl; 00669 // cast all to VARCHAR(3) 00670 for (int i = 0; i < 4; i++) { 00671 pg << "CALL 'castA(L" << i << ", C" << i << ");" << endl; 00672 } 00673 // cast all to VARCHAR(16) 00674 for (int i = 0; i < 4; i++) { 00675 pg << "CALL 'castA(L" << (i + 4) << ", C" << i << ");" << endl; 00676 } 00677 refLocalOutput(pg, 8); // make output available 00678 00679 Calculator calc(0); 00680 try { 00681 calc.assemble(pg.str().c_str()); 00682 } catch (FennelExcn& ex) { 00683 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00684 BOOST_MESSAGE(pg.str()); 00685 BOOST_REQUIRE(0); 00686 } 00687 00688 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00689 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00690 calc.bind(&inTuple, &outTuple); 00691 calc.exec(); 00692 printOutput(outTuple, calc); 00693 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00694 00695 // check results: 00696 BOOST_CHECK(cmpTupNull(outTuple[0])); 00697 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], "0")); 00698 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], "10")); 00699 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], "-10")); 00700 BOOST_CHECK(cmpTupNull(outTuple[4])); 00701 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[5], "0")); 00702 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[6], "10")); 00703 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[7], "-10")); 00704 BOOST_CHECK(iter == calc.mWarnings.end()); 00705 }
void CalcExtCastTest::testCalcExtCastDecimalToChar | ( | ) | [private] |
Definition at line 709 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), and refLocalOutput().
Referenced by CalcExtCastTest().
00710 { 00711 // decimal(5,2) test values: (null, 0, 10, -10.90, 4.30, -.09, .30), 00712 // cast to CHAR(6) and CHAR(16) 00713 00714 // decimal(5,0) test values: (null, 0, 1000, -1090, 430, -9, 30), 00715 // cast to CHAR(5) and CHAR(16) 00716 00717 // decimal(5,-2) test values: (null, 0, 100000, -109000, 43000, -900, 3000), 00718 // cast to CHAR(7) and CHAR(16) 00719 00720 ostringstream pg(""), outloc(""); 00721 outloc << "c,6, c,6, c,6, c,6, c,6, c,6, c,6, " 00722 << "c,16, c,16, c,16, c,16, c,16, c,16, c,16, " 00723 << "c,5, c,5, c,5, c,5, c,5, c,5, c,5, " 00724 << "c,16, c,16, c,16, c,16, c,16, c,16, c,16, " 00725 << "c,7, c,7, c,7, c,7, c,7, c,7, c,7, " 00726 << "c,16, c,16, c,16, c,16, c,16, c,16, c,16;" << endl; 00727 pg << "O " << outloc.str(); 00728 pg << "L " << outloc.str(); 00729 pg << "C s8, s8, s8, s8, s8, s8, s8, s4, s4, s4, s4;" << endl; 00730 pg << "V , 0, 1000, -1090, 430, -9, 30, 5, 2, 0, -2;" << endl; 00731 pg << "T;" << endl; 00732 // cast decimal(5,2) to CHAR(6) 00733 for (int i = 0; i < 7; i++) { 00734 pg << "CALL 'castA(L" << i << ", C" << i << ", C7, C8 );" << endl; 00735 } 00736 // cast decimal(5,2) to CHAR(16) 00737 for (int i = 0; i < 7; i++) { 00738 pg << "CALL 'castA(L" << (i + 7) << ", C" << i << ", C7, C8 );" << endl; 00739 } 00740 00741 // cast decimal(5,0) to CHAR(5) 00742 for (int i = 0; i < 7; i++) { 00743 pg << "CALL 'castA(L" << (i + 14) << ", C" << i << ", C7, C9 );" 00744 << endl; 00745 } 00746 // cast decimal(5,0) to CHAR(16) 00747 for (int i = 0; i < 7; i++) { 00748 pg << "CALL 'castA(L" << (i + 21) << ", C" << i << ", C7, C9 );" 00749 << endl; 00750 } 00751 00752 // cast decimal(5,-2) to CHAR(7) 00753 for (int i = 0; i < 7; i++) { 00754 pg << "CALL 'castA(L" << (i + 28) << ", C" << i << ", C7, C10 );" 00755 << endl; 00756 } 00757 // cast decimal(5,-2) to CHAR(16) 00758 for (int i = 0; i < 7; i++) { 00759 pg << "CALL 'castA(L" << (i + 35) << ", C" << i << ", C7, C10 );" 00760 << endl; 00761 } 00762 00763 refLocalOutput(pg, 7*6); // make output available 00764 00765 Calculator calc(0); 00766 try { 00767 calc.assemble(pg.str().c_str()); 00768 } catch (FennelExcn& ex) { 00769 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00770 BOOST_MESSAGE(pg.str()); 00771 BOOST_REQUIRE(0); 00772 } 00773 00774 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00775 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00776 calc.bind(&inTuple, &outTuple); 00777 calc.exec(); 00778 printOutput(outTuple, calc); 00779 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00780 00781 // check results: 00782 // decimal(5,2) 00783 BOOST_CHECK(cmpTupNull(outTuple[0])); 00784 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], ".00 ")); 00785 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], "10.00 ")); 00786 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], "-10.90")); 00787 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[4], "4.30 ")); 00788 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[5], "-.09 ")); 00789 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[6], ".30 ")); 00790 BOOST_CHECK(cmpTupNull(outTuple[7])); 00791 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[8], ".00 ")); 00792 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[9], "10.00 ")); 00793 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[10], "-10.90 ")); 00794 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[11], "4.30 ")); 00795 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[12], "-.09 ")); 00796 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[13], ".30 ")); 00797 00798 // decimal(5,0) 00799 BOOST_CHECK(cmpTupNull(outTuple[14])); 00800 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[15], "0 ")); 00801 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[16], "1000 ")); 00802 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[17], "-1090")); 00803 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[18], "430 ")); 00804 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[19], "-9 ")); 00805 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[20], "30 ")); 00806 BOOST_CHECK(cmpTupNull(outTuple[21])); 00807 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[22], "0 ")); 00808 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[23], "1000 ")); 00809 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[24], "-1090 ")); 00810 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[25], "430 ")); 00811 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[26], "-9 ")); 00812 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[27], "30 ")); 00813 00814 // decimal(5,-2) 00815 BOOST_CHECK(cmpTupNull(outTuple[28])); 00816 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[29], "0 ")); 00817 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[30], "100000 ")); 00818 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[31], "-109000")); 00819 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[32], "43000 ")); 00820 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[33], "-900 ")); 00821 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[34], "3000 ")); 00822 BOOST_CHECK(cmpTupNull(outTuple[35])); 00823 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[36], "0 ")); 00824 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[37], "100000 ")); 00825 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[38], "-109000 ")); 00826 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[39], "43000 ")); 00827 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[40], "-900 ")); 00828 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[41], "3000 ")); 00829 }
void CalcExtCastTest::testCalcExtCastDecimalToVarChar | ( | ) | [private] |
Definition at line 833 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), and refLocalOutput().
Referenced by CalcExtCastTest().
00834 { 00835 // decimal(5,2) test values: (null, 0, 10, -10.90, 4.30, -.09, .30), 00836 // cast to VARCHAR(6) and VARCHAR(16) 00837 00838 // decimal(5,0) test values: (null, 0, 1000, -1090, 430, -9, 30), 00839 // cast to VARCHAR(5) and VARCHAR(16) 00840 00841 // decimal(5,-2) test values: (null, 0, 100000, -109000, 43000, -900, 3000), 00842 // cast to VARCHAR(7) and VARCHAR(16) 00843 00844 ostringstream pg(""), outloc(""); 00845 outloc << "vc,6, vc,6, vc,6, vc,6, vc,6, vc,6, vc,6, " 00846 << "vc,16, vc,16, vc,16, vc,16, vc,16, vc,16, vc,16, " 00847 << "vc,5, vc,5, vc,5, vc,5, vc,5, vc,5, vc,5, " 00848 << "vc,16, vc,16, vc,16, vc,16, vc,16, vc,16, vc,16, " 00849 << "vc,7, vc,7, vc,7, vc,7, vc,7, vc,7, vc,7, " 00850 << "vc,16, vc,16, vc,16, vc,16, vc,16, vc,16, vc,16;" << endl; 00851 pg << "O " << outloc.str(); 00852 pg << "L " << outloc.str(); 00853 pg << "C s8, s8, s8, s8, s8, s8, s8, s4, s4, s4, s4;" << endl; 00854 pg << "V , 0, 1000, -1090, 430, -9, 30, 5, 2, 0, -2;" << endl; 00855 pg << "T;" << endl; 00856 // cast decimal(5,2) to VARCHAR(6) 00857 for (int i = 0; i < 7; i++) { 00858 pg << "CALL 'castA(L" << i << ", C" << i << ", C7, C8 );" << endl; 00859 } 00860 // cast decimal(5,2) to VARCHAR(16) 00861 for (int i = 0; i < 7; i++) { 00862 pg << "CALL 'castA(L" << (i + 7) << ", C" << i << ", C7, C8 );" << endl; 00863 } 00864 // cast decimal(5,0) to VARCHAR(5) 00865 for (int i = 0; i < 7; i++) { 00866 pg << "CALL 'castA(L" << (i + 14) << ", C" << i << ", C7, C9 );" 00867 << endl; 00868 } 00869 // cast decimal(5,0) to VARCHAR(16) 00870 for (int i = 0; i < 7; i++) { 00871 pg << "CALL 'castA(L" << (i + 21) << ", C" << i << ", C7, C9 );" 00872 << endl; 00873 } 00874 // cast decimal(5,-2) to VARCHAR(7) 00875 for (int i = 0; i < 7; i++) { 00876 pg << "CALL 'castA(L" << (i + 28) << ", C" << i << ", C7, C10 );" 00877 << endl; 00878 } 00879 // cast decimal(5,-2) to VARCHAR(16) 00880 for (int i = 0; i < 7; i++) { 00881 pg << "CALL 'castA(L" << (i + 35) << ", C" << i << ", C7, C10 );" 00882 << endl; 00883 } 00884 refLocalOutput(pg, 7 * 6); // make output available 00885 00886 Calculator calc(0); 00887 try { 00888 calc.assemble(pg.str().c_str()); 00889 } catch (FennelExcn& ex) { 00890 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00891 BOOST_MESSAGE(pg.str()); 00892 BOOST_REQUIRE(0); 00893 } 00894 00895 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00896 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00897 calc.bind(&inTuple, &outTuple); 00898 calc.exec(); 00899 printOutput(outTuple, calc); 00900 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00901 00902 // check results: 00903 // decimal(5,2) 00904 BOOST_CHECK(cmpTupNull(outTuple[0])); 00905 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], ".00")); 00906 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], "10.00")); 00907 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], "-10.90")); 00908 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[4], "4.30")); 00909 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[5], "-.09")); 00910 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[6], ".30")); 00911 BOOST_CHECK(cmpTupNull(outTuple[7])); 00912 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[8], ".00")); 00913 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[9], "10.00")); 00914 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[10], "-10.90")); 00915 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[11], "4.30")); 00916 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[12], "-.09")); 00917 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[13], ".30")); 00918 00919 // decimal(5,0) 00920 BOOST_CHECK(cmpTupNull(outTuple[14])); 00921 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[15], "0")); 00922 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[16], "1000")); 00923 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[17], "-1090")); 00924 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[18], "430")); 00925 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[19], "-9")); 00926 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[20], "30")); 00927 BOOST_CHECK(cmpTupNull(outTuple[21])); 00928 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[22], "0")); 00929 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[23], "1000")); 00930 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[24], "-1090")); 00931 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[25], "430")); 00932 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[26], "-9")); 00933 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[27], "30")); 00934 00935 // decimal(5,-2) 00936 BOOST_CHECK(cmpTupNull(outTuple[28])); 00937 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[29], "0")); 00938 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[30], "100000")); 00939 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[31], "-109000")); 00940 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[32], "43000")); 00941 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[33], "-900")); 00942 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[34], "3000")); 00943 BOOST_CHECK(cmpTupNull(outTuple[35])); 00944 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[36], "0")); 00945 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[37], "100000")); 00946 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[38], "-109000")); 00947 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[39], "43000")); 00948 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[40], "-900")); 00949 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[41], "3000")); 00950 }
void CalcExtCastTest::testCalcExtCastBigExactToString | ( | ) | [private] |
Definition at line 954 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), maxInt64String(), minInt64String(), Calculator::mWarnings, printOutput(), refLocalOutput(), and rpad().
Referenced by CalcExtCastTest().
00955 { 00956 // int8 test values: (MAX, MIN) cast to CHAR(32) and VARCHAR(32); 00957 ostringstream pg(""), outloc(""); 00958 outloc << "vc,32, vc,32, c,32, c,32;" << endl; 00959 pg << "O " << outloc.str(); 00960 pg << "L " << outloc.str(); 00961 pg << "C s8, s8;" << endl; 00962 pg << "V " << maxInt64String() << ", " << minInt64String() << ";" << endl; 00963 pg << "T;" << endl; 00964 pg << "CALL 'castA(L0, C0);" << endl; 00965 pg << "CALL 'castA(L1, C1);" << endl; 00966 pg << "CALL 'castA(L2, C0);" << endl; 00967 pg << "CALL 'castA(L3, C1);" << endl; 00968 refLocalOutput(pg, 4); // make output available 00969 00970 Calculator calc(0); 00971 try { 00972 calc.assemble(pg.str().c_str()); 00973 } catch (FennelExcn& ex) { 00974 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 00975 BOOST_MESSAGE(pg.str()); 00976 BOOST_REQUIRE(0); 00977 } 00978 00979 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 00980 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 00981 calc.bind(&inTuple, &outTuple); 00982 calc.exec(); 00983 printOutput(outTuple, calc); 00984 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 00985 00986 // check results: 00987 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[0], maxInt64String())); 00988 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], minInt64String())); 00989 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], rpad(maxInt64String(), 32))); 00990 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], rpad(minInt64String(), 32))); 00991 BOOST_CHECK(iter == calc.mWarnings.end()); 00992 }
void CalcExtCastTest::testCalcExtCastExactToStringTruncates | ( | ) | [private] |
Definition at line 996 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), refLocalOutput(), and truncErr.
Referenced by CalcExtCastTest().
00997 { 00998 // int8 test values (1666, -1666) cast to VARCHAR(3) and CHAR(3) 00999 ostringstream pg(""), outloc(""); 01000 outloc << "vc,3, vc,3, c,3, c,3;" << endl; 01001 pg << "O " << outloc.str(); 01002 pg << "L " << outloc.str(); 01003 pg << "C s8, s8;" << endl; 01004 pg << "V 1666, -1666;" << endl; 01005 pg << "T;" << endl; 01006 pg << "CALL 'castA(L0, C0);" << endl; 01007 pg << "CALL 'castA(L1, C1);" << endl; 01008 pg << "CALL 'castA(L2, C0);" << endl; 01009 pg << "CALL 'castA(L3, C1);" << endl; 01010 refLocalOutput(pg, 4); // make output available 01011 01012 Calculator calc(0); 01013 try { 01014 calc.assemble(pg.str().c_str()); 01015 } catch (FennelExcn& ex) { 01016 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01017 BOOST_MESSAGE(pg.str()); 01018 BOOST_REQUIRE(0); 01019 } 01020 01021 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01022 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01023 calc.bind(&inTuple, &outTuple); 01024 calc.exec(); 01025 printOutput(outTuple, calc); 01026 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01027 01028 // check results: 01029 // 1666 -> vc(3) = truncates 01030 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[0], "166")); 01031 BOOST_CHECK_EQUAL(iter->pc, 0); 01032 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01033 iter++; 01034 01035 // -1666 -> vc(3) = truncates 01036 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[1], "-16")); 01037 BOOST_CHECK_EQUAL(iter->pc, 1); 01038 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01039 iter++; 01040 01041 // 1666 -> c(3) = truncates 01042 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], "166")); 01043 BOOST_CHECK_EQUAL(iter->pc, 2); 01044 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01045 iter++; 01046 01047 // -1666 -> c(3) = truncates 01048 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[3], "-16")); 01049 BOOST_CHECK_EQUAL(iter->pc, 3); 01050 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01051 iter++; 01052 BOOST_CHECK(iter == calc.mWarnings.end()); 01053 }
void CalcExtCastTest::testCalcExtCastDecimalToStringTruncates | ( | ) | [private] |
Definition at line 1058 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), refLocalOutput(), and truncErr.
Referenced by CalcExtCastTest().
01059 { 01060 // decimal(5,2) test values: (-10.9, -.09, .30), 01061 // decimal(5,0) test values: (-1090, -9, 30), 01062 // decimal(5,-2) test values: (-109000, -900, 3000), 01063 01064 // cast to VARCHAR(3) and CHAR(3) 01065 ostringstream pg(""), outloc(""); 01066 outloc << "vc,3, vc,3, vc,3, c,3, c,3, c,3, " 01067 << "vc,3, vc,3, vc,3, c,3, c,3, c,3, " 01068 << "vc,3, vc,3, vc,3, c,3, c,3, c,3;" << endl; 01069 pg << "O " << outloc.str(); 01070 pg << "L " << outloc.str(); 01071 pg << "C s8, s8, s8, s4, s4, s4, s4;" << endl; 01072 pg << "V -1090, -9, 30, 5, 2, 0, -2;" << endl; 01073 pg << "T;" << endl; 01074 01075 pg << "CALL 'castA(L0, C0, C3, C4);" << endl; 01076 pg << "CALL 'castA(L1, C1, C3, C4);" << endl; 01077 pg << "CALL 'castA(L2, C2, C3, C4);" << endl; 01078 pg << "CALL 'castA(L3, C0, C3, C4);" << endl; 01079 pg << "CALL 'castA(L4, C1, C3, C4);" << endl; 01080 pg << "CALL 'castA(L5, C2, C3, C4);" << endl; 01081 01082 pg << "CALL 'castA(L6, C0, C3, C5);" << endl; 01083 pg << "CALL 'castA(L7, C1, C3, C5);" << endl; 01084 pg << "CALL 'castA(L8, C2, C3, C5);" << endl; 01085 pg << "CALL 'castA(L9, C0, C3, C5);" << endl; 01086 pg << "CALL 'castA(L10, C1, C3, C5);" << endl; 01087 pg << "CALL 'castA(L11, C2, C3, C5);" << endl; 01088 01089 pg << "CALL 'castA(L12, C0, C3, C6);" << endl; 01090 pg << "CALL 'castA(L13, C1, C3, C6);" << endl; 01091 pg << "CALL 'castA(L14, C2, C3, C6);" << endl; 01092 pg << "CALL 'castA(L15, C0, C3, C6);" << endl; 01093 pg << "CALL 'castA(L16, C1, C3, C6);" << endl; 01094 pg << "CALL 'castA(L17, C2, C3, C6);" << endl; 01095 01096 refLocalOutput(pg, 18); // make output available 01097 01098 Calculator calc(0); 01099 try { 01100 calc.assemble(pg.str().c_str()); 01101 } catch (FennelExcn& ex) { 01102 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01103 BOOST_MESSAGE(pg.str()); 01104 BOOST_REQUIRE(0); 01105 } 01106 01107 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01108 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01109 calc.bind(&inTuple, &outTuple); 01110 calc.exec(); 01111 printOutput(outTuple, calc); 01112 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01113 01114 // check results: 01115 // decimal(5,2) 01116 // -10.9 -> vc(3) = truncates 01117 BOOST_CHECK_EQUAL(iter->pc, 0); 01118 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01119 iter++; 01120 01121 // -.09 -> vc(3) = truncates 01122 BOOST_CHECK_EQUAL(iter->pc, 1); 01123 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01124 iter++; 01125 01126 // .30 - > vc(3) = ok 01127 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[2], ".30")); 01128 01129 // -10.9 -> c(3) = truncates 01130 BOOST_CHECK_EQUAL(iter->pc, 3); 01131 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01132 iter++; 01133 01134 // -.09 -> c(3) = truncates 01135 BOOST_CHECK_EQUAL(iter->pc, 4); 01136 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01137 iter++; 01138 01139 // .30 - > c(3) = ok 01140 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[5], ".30")); 01141 01142 // decimal(5,0) 01143 // -1090 -> vc(3) = truncates 01144 BOOST_CHECK_EQUAL(iter->pc, 6); 01145 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01146 iter++; 01147 01148 // -9 -> vc(3) = ok 01149 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[7], "-9")); 01150 01151 // 30 - > vc(3) = ok 01152 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[8], "30")); 01153 01154 // -1090 -> c(3) = truncates 01155 BOOST_CHECK_EQUAL(iter->pc, 9); 01156 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01157 iter++; 01158 01159 // -9 -> c(3) = ok 01160 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[10], "-9 ")); 01161 01162 // 30 - > c(3) = ok 01163 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[11], "30 ")); 01164 01165 // decimal(5,-2) 01166 // -109000 -> vc(3) = truncates 01167 BOOST_CHECK_EQUAL(iter->pc, 12); 01168 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01169 iter++; 01170 01171 // -900 -> vc(3) = truncates 01172 BOOST_CHECK_EQUAL(iter->pc, 13); 01173 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01174 iter++; 01175 01176 // 3000 -> vc(3) = truncates 01177 BOOST_CHECK_EQUAL(iter->pc, 14); 01178 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01179 iter++; 01180 01181 // -109000 -> c(3) = truncates 01182 BOOST_CHECK_EQUAL(iter->pc, 15); 01183 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01184 iter++; 01185 01186 // -900 -> c(3) = truncates 01187 BOOST_CHECK_EQUAL(iter->pc, 16); 01188 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01189 iter++; 01190 01191 // 3000 -> c(3) = truncates 01192 BOOST_CHECK_EQUAL(iter->pc, 17); 01193 BOOST_CHECK_EQUAL(0, strcmp(iter->str, truncErr)); 01194 iter++; 01195 01196 BOOST_CHECK(iter == calc.mWarnings.end()); 01197 }
void CalcExtCastTest::testCalcExtCastCharToBoolean | ( | ) | [private] |
Definition at line 1199 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupBool(), cmpTupNull(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), invalidCharErr, Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01200 { 01201 // test values: null, true, false, unknown, invalid; same with spaces. 01202 ostringstream pg(""), outloc(""); 01203 outloc << "bo, bo, bo, bo, bo, bo, bo, bo;" << endl; 01204 pg << "O " << outloc.str(); 01205 pg << "L " << outloc.str(); 01206 pg << "C c,4, c,4, c,8, c,5, c,9, c,7, c,11, c,13;" << endl; 01207 pg << "V " // a null 01208 << ", 0x" << stringToHex("tRUe") 01209 << ", 0x" << stringToHex(" true ") 01210 << ", 0x" << stringToHex("faLSe") 01211 << ", 0x" << stringToHex(" FALSE ") 01212 << ", 0x" << stringToHex("UnknowN") 01213 << ", 0x" << stringToHex(" UnknowN ") 01214 << ", 0x" << stringToHex(" Invalid ") 01215 << ";" << endl; 01216 pg << "T;" << endl; 01217 for (int i = 0; i < 8; i++) { 01218 pg << "CALL 'castA(L"<<i<<",C"<<i<<");"<< endl; 01219 } 01220 refLocalOutput(pg, 8); // make output available 01221 01222 Calculator calc(0); 01223 try { 01224 calc.assemble(pg.str().c_str()); 01225 } catch (FennelExcn& ex) { 01226 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01227 BOOST_MESSAGE(pg.str()); 01228 BOOST_REQUIRE(0); 01229 } 01230 01231 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01232 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01233 calc.bind(&inTuple, &outTuple); 01234 calc.exec(); 01235 printOutput(outTuple, calc); 01236 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01237 01238 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[0])); 01239 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[1], true)); 01240 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[2], true)); 01241 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[3], false)); 01242 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[4], false)); 01243 01244 // TODO: SQL2003 says 'unknown' should be treated as null 01245 // For now, unknown -> bool = invalid char 01246 BOOST_CHECK_EQUAL(iter->pc, 5); 01247 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01248 iter++; 01249 01250 BOOST_CHECK_EQUAL(iter->pc, 6); 01251 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01252 iter++; 01253 01254 // invalid -> bool = invalid char 01255 BOOST_CHECK_EQUAL(iter->pc, 7); 01256 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01257 iter++; 01258 01259 BOOST_CHECK(iter == calc.mWarnings.end()); 01260 }
void CalcExtCastTest::testCalcExtCastVarCharToBoolean | ( | ) | [private] |
Definition at line 1262 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupBool(), cmpTupNull(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), invalidCharErr, Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01263 { 01264 // test values: null, true, false, unknown, invalid; same with spaces. 01265 ostringstream pg(""), outloc(""); 01266 outloc << "bo, bo, bo, bo, bo, bo, bo, bo;" << endl; 01267 pg << "O " << outloc.str(); 01268 pg << "L " << outloc.str(); 01269 pg << "C vc,4, vc,8, vc,8, vc,9, vc,9, vc,7, vc,11, vc,13;" << endl; 01270 pg << "V " // a null 01271 << ", 0x" << stringToHex("tRUe") 01272 << ", 0x" << stringToHex(" true ") 01273 << ", 0x" << stringToHex("faLSe") 01274 << ", 0x" << stringToHex(" FALSE ") 01275 << ", 0x" << stringToHex("UnknowN") 01276 << ", 0x" << stringToHex(" UnknowN ") 01277 << ", 0x" << stringToHex(" Invalid ") 01278 << ";" << endl; 01279 pg << "T;" << endl; 01280 for (int i = 0; i < 8; i++) { 01281 pg << "CALL 'castA(L" << i << ",C" << i << ");" << endl; 01282 } 01283 refLocalOutput(pg, 8); // make output available 01284 01285 Calculator calc(0); 01286 try { 01287 calc.assemble(pg.str().c_str()); 01288 } catch (FennelExcn& ex) { 01289 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01290 BOOST_MESSAGE(pg.str()); 01291 BOOST_REQUIRE(0); 01292 } 01293 01294 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01295 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01296 calc.bind(&inTuple, &outTuple); 01297 calc.exec(); 01298 printOutput(outTuple, calc); 01299 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01300 01301 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[0])); 01302 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[1], true)); 01303 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[2], true)); 01304 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[3], false)); 01305 BOOST_CHECK_EQUAL(1, cmpTupBool(outTuple[4], false)); 01306 01307 // TODO: SQL2003 says 'unknown' should be treated as null 01308 // For now, unknown -> bool = invalid char 01309 BOOST_CHECK_EQUAL(iter->pc, 5); 01310 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01311 iter++; 01312 01313 BOOST_CHECK_EQUAL(iter->pc, 6); 01314 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01315 iter++; 01316 01317 // invalid -> bool = invalid char 01318 BOOST_CHECK_EQUAL(iter->pc, 7); 01319 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01320 iter++; 01321 01322 BOOST_CHECK(iter == calc.mWarnings.end()); 01323 }
void CalcExtCastTest::testCalcExtCastCharToExact | ( | ) | [private] |
Definition at line 1380 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupInt(), cmpTupInt64(), cmpTupNull(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), max(), maxInt64String(), min(), minInt64String(), Calculator::mWarnings, printOutput(), refLocalOutput(), rpad(), and stringToHex().
Referenced by CalcExtCastTest().
01381 { 01382 // test values: null; 123, -123, MAX and MIN; same with trailing spaces. 01383 ostringstream pg(""), outloc(""); 01384 outloc << "s8, s8, s8, s8, s8, s8, s8, s8, s8;" << endl; 01385 pg << "O " << outloc.str(); 01386 pg << "L " << outloc.str(); 01387 pg << "C c,3, c,3, c,4, c,19, c,20, c,8, c,8, c,32, c,32;" << endl; 01388 pg << "V " // a null 01389 << ", 0x" << stringToHex("123") << ", 0x" << stringToHex("-123") 01390 << ", 0x" << stringToHex(maxInt64String()) 01391 << ", 0x" << stringToHex(minInt64String()) 01392 << ", 0x" << stringToHex("123 ") << ", 0x" << stringToHex("-123 ") 01393 << ", 0x" << stringToHex(rpad(maxInt64String(), 32)) 01394 << ", 0x" << stringToHex(rpad(minInt64String(), 32)) 01395 << ";" << endl; 01396 pg << "T;" << endl; 01397 for (int i = 0; i < 9; i++) { 01398 pg << "CALL 'castA(L" << i << ",C" << i << ");" << endl; 01399 } 01400 refLocalOutput(pg, 9); // make output available 01401 01402 Calculator calc(0); 01403 try { 01404 calc.assemble(pg.str().c_str()); 01405 } catch (FennelExcn& ex) { 01406 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01407 BOOST_MESSAGE(pg.str()); 01408 BOOST_REQUIRE(0); 01409 } 01410 01411 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01412 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01413 calc.bind(&inTuple, &outTuple); 01414 calc.exec(); 01415 printOutput(outTuple, calc); 01416 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01417 01418 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[0])); 01419 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[1], 123)); 01420 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[2], -123)); 01421 BOOST_CHECK_EQUAL( 01422 0, cmpTupInt64(outTuple[3], numeric_limits<int64_t>::max())); 01423 BOOST_CHECK_EQUAL( 01424 0, cmpTupInt64(outTuple[4], numeric_limits<int64_t>::min())); 01425 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[5], 123)); 01426 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[6], -123)); 01427 BOOST_CHECK_EQUAL( 01428 0, cmpTupInt64(outTuple[7], numeric_limits<int64_t>::max())); 01429 BOOST_CHECK_EQUAL( 01430 0, cmpTupInt64(outTuple[8], numeric_limits<int64_t>::min())); 01431 BOOST_CHECK(iter == calc.mWarnings.end()); 01432 }
void CalcExtCastTest::testCalcExtCastVarCharToExact | ( | ) | [private] |
Definition at line 1326 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupInt(), cmpTupInt64(), cmpTupNull(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), max(), maxInt64String(), min(), minInt64String(), Calculator::mWarnings, printOutput(), refLocalOutput(), rpad(), and stringToHex().
Referenced by CalcExtCastTest().
01327 { 01328 // test values: null; 123, -123, MAX and MIN; same with trailing spaces. 01329 ostringstream pg(""), outloc(""); 01330 outloc << "s8, s8, s8, s8, s8, s8, s8, s8, s8;" << endl; 01331 pg << "O " << outloc.str(); 01332 pg << "L " << outloc.str(); 01333 pg << "C vc,4, vc,4, vc,4, vc,20, vc,21, vc,8, vc,8, vc,32, vc,32;" << endl; 01334 pg << "V " // a null 01335 << ", 0x" << stringToHex("123") << ", 0x" << stringToHex("-123") 01336 << ", 0x" << stringToHex(maxInt64String()) 01337 << ", 0x" << stringToHex(minInt64String()) 01338 << ", 0x" << stringToHex("123 ") << ", 0x" << stringToHex("-123 ") 01339 << ", 0x" << stringToHex(rpad(maxInt64String(), 32)) 01340 << ", 0x" << stringToHex(rpad(minInt64String(), 32)) 01341 << ";" << endl; 01342 pg << "T;" << endl; 01343 for (int i = 0; i < 9; i++) { 01344 pg << "CALL 'castA(L" << i << ",C" << i << ");" << endl; 01345 } 01346 refLocalOutput(pg, 9); // make output available 01347 01348 Calculator calc(0); 01349 try { 01350 calc.assemble(pg.str().c_str()); 01351 } catch (FennelExcn& ex) { 01352 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01353 BOOST_MESSAGE(pg.str()); 01354 BOOST_REQUIRE(0); 01355 } 01356 01357 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01358 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01359 calc.bind(&inTuple, &outTuple); 01360 calc.exec(); 01361 printOutput(outTuple, calc); 01362 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01363 01364 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[0])); 01365 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[1], 123)); 01366 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[2], -123)); 01367 BOOST_CHECK_EQUAL( 01368 0, cmpTupInt64(outTuple[3], numeric_limits<int64_t>::max())); 01369 BOOST_CHECK_EQUAL( 01370 0, cmpTupInt64(outTuple[4], numeric_limits<int64_t>::min())); 01371 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[5], 123)); 01372 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[6], -123)); 01373 BOOST_CHECK_EQUAL( 01374 0, cmpTupInt64(outTuple[7], numeric_limits<int64_t>::max())); 01375 BOOST_CHECK_EQUAL( 01376 0, cmpTupInt64(outTuple[8], numeric_limits<int64_t>::min())); 01377 BOOST_CHECK(iter == calc.mWarnings.end()); 01378 }
void CalcExtCastTest::testCalcExtCastCharToDecimal | ( | ) | [private] |
Definition at line 1525 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupInt(), cmpTupNull(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01526 { 01527 // test values: null, .8987, -0005.2, +980, 0.000000000000355e14 01528 // same with trailing spaces.to 01529 // decimal(5, 2) 01530 // decimal(5, 0) 01531 // decimal(5, -2) 01532 ostringstream pg(""), outloc(""); 01533 outloc << "s8, s8, s8, s8, s8, s8, s8, s8, s8, " 01534 << "s8, s8, s8, s8, s8, s8, s8, s8, s8, " 01535 << "s8, s8, s8, s8, s8, s8, s8, s8, s8;" 01536 << endl; 01537 pg << "O " << outloc.str(); 01538 pg << "L " << outloc.str(); 01539 pg << "C c,1, c,5, c,7, c,4, c,20, c,10, c,10, c,10, c,32, " 01540 << " s4, s4, s4, s4;" << endl; 01541 pg << "V " // a null 01542 << ", 0x" << stringToHex(".8987") 01543 << ", 0x" << stringToHex("-0005.2") 01544 << ", 0x" << stringToHex("+980") 01545 << ", 0x" << stringToHex("0.000000000000355e14") 01546 << ", 0x" << stringToHex(".8987 ") 01547 << ", 0x" << stringToHex("-0005.2 ") 01548 << ", 0x" << stringToHex("+980 ") 01549 << ", 0x" << stringToHex("0.000000000000355e14 ") 01550 << ", 5, 2, 0, -2;" << endl; 01551 pg << "T;" << endl; 01552 01553 for (int i = 0; i < 9; i++) { 01554 pg << "CALL 'castA(L" << i << ",C" << i << ",C9, C10);" << endl; 01555 } 01556 for (int i = 0; i < 9; i++) { 01557 pg << "CALL 'castA(L" << (i + 9) << ",C" << i << ",C9, C11);" << endl; 01558 } 01559 for (int i = 0; i < 9; i++) { 01560 pg << "CALL 'castA(L" << (i + 18) << ",C" << i << ",C9, C12);" << endl; 01561 } 01562 refLocalOutput(pg, 9*3); // make output available 01563 01564 Calculator calc(0); 01565 try { 01566 calc.assemble(pg.str().c_str()); 01567 } catch (FennelExcn& ex) { 01568 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01569 BOOST_MESSAGE(pg.str()); 01570 BOOST_REQUIRE(0); 01571 } 01572 01573 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01574 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01575 calc.bind(&inTuple, &outTuple); 01576 calc.exec(); 01577 printOutput(outTuple, calc); 01578 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01579 01580 // decimal(5,2) 01581 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[0])); 01582 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[1], 90)); 01583 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[2], -520)); 01584 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[3], 98000)); 01585 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[4], 3550)); 01586 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[5], 90)); 01587 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[6], -520)); 01588 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[7], 98000)); 01589 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[8], 3550)); 01590 01591 // decimal(5,0) 01592 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[9])); 01593 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[10], 1)); 01594 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[11], -5)); 01595 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[12], 980)); 01596 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[13], 36)); 01597 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[14], 1)); 01598 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[15], -5)); 01599 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[16], 980)); 01600 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[17], 36)); 01601 01602 // decimal(5,-2) 01603 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[18])); 01604 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[19], 0)); 01605 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[20], 0)); 01606 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[21], 10)); 01607 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[22], 0)); 01608 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[23], 0)); 01609 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[24], 0)); 01610 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[25], 10)); 01611 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[26], 0)); 01612 01613 BOOST_CHECK(iter == calc.mWarnings.end()); 01614 }
void CalcExtCastTest::testCalcExtCastVarCharToDecimal | ( | ) | [private] |
Definition at line 1434 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupInt(), cmpTupNull(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01435 { 01436 // test values: null, 99.99, -105.0e-3, 950.00, 234.446 01437 // same with trailing spaces.to 01438 // decimal(5, 2) 01439 // decimal(5, 0) 01440 // decimal(5, -2) 01441 ostringstream pg(""), outloc(""); 01442 outloc << "s8, s8, s8, s8, s8, s8, s8, s8, s8, " 01443 << "s8, s8, s8, s8, s8, s8, s8, s8, s8, " 01444 << "s8, s8, s8, s8, s8, s8, s8, s8, s8;" 01445 << endl; 01446 pg << "O " << outloc.str(); 01447 pg << "L " << outloc.str(); 01448 pg << "C vc,1, vc,5, vc,9, vc,6, vc,7, vc,10, vc,10, vc,10, vc,10, " 01449 << " s4, s4, s4, s4;" << endl; 01450 pg << "V " // a null 01451 << ", 0x" << stringToHex("99.99") 01452 << ", 0x" << stringToHex("-105.0e-3") 01453 << ", 0x" << stringToHex("950.00") 01454 << ", 0x" << stringToHex("234.446") 01455 << ", 0x" << stringToHex("99.99 ") 01456 << ", 0x" << stringToHex("-105.0e-3 ") 01457 << ", 0x" << stringToHex("950.00 ") 01458 << ", 0x" << stringToHex("234.446 ") 01459 << ", 5, 2, 0, -2;" << endl; 01460 pg << "T;" << endl; 01461 01462 for (int i = 0; i < 9; i++) { 01463 pg << "CALL 'castA(L" << i << ",C" << i << ",C9, C10);" << endl; 01464 } 01465 for (int i = 0; i < 9; i++) { 01466 pg << "CALL 'castA(L" << (i + 9) << ",C" << i << ",C9, C11);" << endl; 01467 } 01468 for (int i = 0; i < 9; i++) { 01469 pg << "CALL 'castA(L" << (i + 18) << ",C" << i << ",C9, C12);" << endl; 01470 } 01471 refLocalOutput(pg, 9*3); // make output available 01472 01473 Calculator calc(0); 01474 try { 01475 calc.assemble(pg.str().c_str()); 01476 } catch (FennelExcn& ex) { 01477 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01478 BOOST_MESSAGE(pg.str()); 01479 BOOST_REQUIRE(0); 01480 } 01481 01482 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01483 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01484 calc.bind(&inTuple, &outTuple); 01485 calc.exec(); 01486 printOutput(outTuple, calc); 01487 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01488 01489 // decimal(5,2) 01490 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[0])); 01491 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[1], 9999)); 01492 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[2], -11)); 01493 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[3], 95000)); 01494 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[4], 23445)); 01495 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[5], 9999)); 01496 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[6], -11)); 01497 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[7], 95000)); 01498 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[8], 23445)); 01499 01500 // decimal(5,0) 01501 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[9])); 01502 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[10], 100)); 01503 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[11], 0)); 01504 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[12], 950)); 01505 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[13], 234)); 01506 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[14], 100)); 01507 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[15], 0)); 01508 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[16], 950)); 01509 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[17], 234)); 01510 01511 // decimal(5,-2) 01512 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[18])); 01513 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[19], 1)); 01514 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[20], 0)); 01515 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[21], 10)); 01516 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[22], 2)); 01517 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[23], 1)); 01518 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[24], 0)); 01519 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[25], 10)); 01520 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[26], 2)); 01521 01522 BOOST_CHECK(iter == calc.mWarnings.end()); 01523 }
void CalcExtCastTest::testCalcExtCastStringToExactFails | ( | ) | [private] |
Definition at line 1616 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), invalidCharErr, Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01617 { 01618 // test invalid values abc, 12z 01619 ostringstream pg(""), outloc(""); 01620 outloc << "s8, s8, s8, s8;" << endl; 01621 pg << "O " << outloc.str(); 01622 pg << "L " << outloc.str(); 01623 pg << "C vc,3, vc,3, c,3, c,3;" << endl; 01624 pg << "V 0x" << stringToHex("abc") << ", 0x" << stringToHex("12z") 01625 << ", 0x" << stringToHex("abc") << ", 0x" << stringToHex("12z") 01626 << ";" << endl; 01627 pg << "T;" << endl; 01628 pg << "CALL 'castA(L0, C0);" << endl; 01629 pg << "CALL 'castA(L1, C1);" << endl; 01630 pg << "CALL 'castA(L2, C0);" << endl; 01631 pg << "CALL 'castA(L3, C1);" << endl; 01632 refLocalOutput(pg, 4); // make output available 01633 01634 Calculator calc(0); 01635 try { 01636 calc.assemble(pg.str().c_str()); 01637 } catch (FennelExcn& ex) { 01638 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01639 BOOST_MESSAGE(pg.str()); 01640 BOOST_REQUIRE(0); 01641 } 01642 01643 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01644 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01645 calc.bind(&inTuple, &outTuple); 01646 calc.exec(); 01647 printOutput(outTuple, calc); 01648 01649 // all the casts should have failed 01650 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01651 for (int pc = 0; pc < 4; pc++, iter++) { 01652 BOOST_CHECK_EQUAL(iter->pc, pc); 01653 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01654 } 01655 BOOST_CHECK(iter == calc.mWarnings.end()); 01656 }
void CalcExtCastTest::testCalcExtCastStringToDecimalFails | ( | ) | [private] |
Definition at line 1658 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), invalidCharErr, Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01659 { 01660 // test invalid values: 12c, 34.54.243, 342.342e453.23, 234e 23 01661 // cast to decimal(5,2) 01662 ostringstream pg(""), outloc(""); 01663 outloc << "s8, s8, s8, s8, s8, s8, s8, s8;" << endl; 01664 pg << "O " << outloc.str(); 01665 pg << "L " << outloc.str(); 01666 pg << "C vc,3, vc,9, vc,14, vc,7, c,3, c,9, c,14, c,7, " 01667 << " s4, s4;" << endl; 01668 pg << "V 0x" << stringToHex("12c") 01669 << ", 0x" << stringToHex("34.54.243") 01670 << ", 0x" << stringToHex("342.342e453.23") 01671 << ", 0x" << stringToHex("234e 23") 01672 << ", 0x" << stringToHex("12c") 01673 << ", 0x" << stringToHex("34.54.243") 01674 << ", 0x" << stringToHex("342.342e453.23") 01675 << ", 0x" << stringToHex("234e 23") 01676 << ", 5, 2;" << endl; 01677 pg << "T;" << endl; 01678 01679 for (int i = 0; i < 8; i++) { 01680 pg << "CALL 'castA(L" << i << ",C" << i << ",C8, C9);" << endl; 01681 } 01682 refLocalOutput(pg, 8); // make output available 01683 01684 Calculator calc(0); 01685 try { 01686 calc.assemble(pg.str().c_str()); 01687 } catch (FennelExcn& ex) { 01688 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01689 BOOST_MESSAGE(pg.str()); 01690 BOOST_REQUIRE(0); 01691 } 01692 01693 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01694 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01695 calc.bind(&inTuple, &outTuple); 01696 calc.exec(); 01697 printOutput(outTuple, calc); 01698 01699 // all the casts should have failed 01700 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01701 for (int pc = 0; pc < 8; pc++, iter++) { 01702 BOOST_CHECK_EQUAL(iter->pc, pc); 01703 BOOST_CHECK_EQUAL(0, strcmp(iter->str, invalidCharErr)); 01704 } 01705 BOOST_CHECK(iter == calc.mWarnings.end()); 01706 }
void CalcExtCastTest::testCalcExtCastStringToDecimalMinMax | ( | ) | [private] |
Definition at line 1708 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupInt64(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), max(), maxInt64String(), min(), minInt64String(), Calculator::mWarnings, outOfRangeErr, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01709 { 01710 // test values: MIN, MAX, 01711 // 9223372036854775808 (MAX+1), 01712 // 9223372036854775807.12345 01713 // 9223372036854775807.9 01714 // -9223372036854775809 01715 // -9223372036854775807.9 01716 // -9223372036854775808.9 01717 // 9323415432153452535 01718 // 9.78E+18 01719 // 9.78E+20 01720 // cast to decimal(19, 0) 01721 // cast to decimal(9, -10) 01722 ostringstream pg(""), outloc(""); 01723 outloc << "s8, s8, s8, s8, s8, s8, s8, s8, s8, s8, s8, " 01724 << "s8, s8, s8, s8, s8, s8, s8, s8, s8, s8, s8;" << endl; 01725 pg << "O " << outloc.str(); 01726 pg << "L " << outloc.str(); 01727 pg << "C vc,30, vc,30, vc,30, vc,30, vc,30, " 01728 << " vc,30, vc,30, vc,30, vc,30, vc,30, vc,30, " 01729 << " s4, s4, s4, s4;" << endl; 01730 pg << "V 0x" << stringToHex(minInt64String()) 01731 << ", 0x" << stringToHex(maxInt64String()) 01732 << ", 0x" << stringToHex("9223372036854775808") 01733 << ", 0x" << stringToHex("9223372036854775807.12345") 01734 << ", 0x" << stringToHex("9223372036854775807.9") 01735 << ", 0x" << stringToHex("-9223372036854775809") 01736 << ", 0x" << stringToHex("-9223372036854775807.9") 01737 << ", 0x" << stringToHex("-9223372036854775808.9") 01738 << ", 0x" << stringToHex("9323415432153452535") 01739 << ", 0x" << stringToHex("9.78E+18") 01740 << ", 0x" << stringToHex("9.78E+20") 01741 << ", 19, 0, 9, -10;" << endl; 01742 pg << "T;" << endl; 01743 01744 for (int i = 0; i < 11; i++) { 01745 pg << "CALL 'castA(L" << i << ",C" << i << ",C11, C12);" << endl; 01746 } 01747 for (int i = 0; i < 11; i++) { 01748 pg << "CALL 'castA(L" << (i + 11) << ",C" << i << ",C13, C14);" << endl; 01749 } 01750 refLocalOutput(pg, 22); // make output available 01751 01752 Calculator calc(0); 01753 try { 01754 calc.assemble(pg.str().c_str()); 01755 } catch (FennelExcn& ex) { 01756 cout << ex.getMessage(); 01757 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01758 BOOST_MESSAGE(pg.str()); 01759 BOOST_REQUIRE(0); 01760 } 01761 01762 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01763 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01764 calc.bind(&inTuple, &outTuple); 01765 calc.exec(); 01766 printOutput(outTuple, calc); 01767 01768 // check results: 01769 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01770 01771 // decimal(19,0) 01772 // MIN -> decimal(19,0) = ok 01773 BOOST_CHECK_EQUAL( 01774 0, cmpTupInt64(outTuple[0], std::numeric_limits<int64_t>::min())); 01775 01776 // MAX -> decimal(19,0) = ok 01777 BOOST_CHECK_EQUAL( 01778 0, cmpTupInt64(outTuple[1], std::numeric_limits<int64_t>::max())); 01779 01780 // MAX + 1 -> decimal(19,0) = out of range 01781 BOOST_CHECK_EQUAL(iter->pc, 2); 01782 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01783 iter++; 01784 01785 // MAX.12345 -> decimal(19, 0) = ok 01786 BOOST_CHECK_EQUAL( 01787 0, cmpTupInt64(outTuple[3], std::numeric_limits<int64_t>::max())); 01788 01789 // MAX.9 -> decimal(19, 0) = out of range 01790 BOOST_CHECK_EQUAL(iter->pc, 4); 01791 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01792 iter++; 01793 01794 // MIN - 1 -> decimal(19,0) = out of range 01795 BOOST_CHECK_EQUAL(iter->pc, 5); 01796 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01797 iter++; 01798 01799 // (MIN+1).9 -> decimal(19,0) = ok 01800 BOOST_CHECK_EQUAL( 01801 0, cmpTupInt64(outTuple[6], std::numeric_limits<int64_t>::min())); 01802 01803 // MIN.9 -> decimal(19,0) = out of range 01804 BOOST_CHECK_EQUAL(iter->pc, 7); 01805 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01806 iter++; 01807 01808 // 9323415432153452535 -> decimal(19,0) = out of range 01809 BOOST_CHECK_EQUAL(iter->pc, 8); 01810 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01811 iter++; 01812 01813 // 9.78E+18 -> decimal(19,0) = out of range 01814 BOOST_CHECK_EQUAL(iter->pc, 9); 01815 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01816 iter++; 01817 01818 // 9.78E+20 -> decimal(19,0) = out of range 01819 BOOST_CHECK_EQUAL(iter->pc, 10); 01820 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01821 iter++; 01822 01823 // decimal(9,-10) 01824 int64_t factor = 1; 01825 for (int i = 0; i < 10; i++) { 01826 factor *= 10; 01827 } 01828 int64_t smax = std::numeric_limits<int64_t>::max()/factor + 1; 01829 int64_t smin = std::numeric_limits<int64_t>::min()/factor - 1; 01830 01831 // MIN -> decimal(9,-10) = ok 01832 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[11], smin)); 01833 01834 // MAX -> decimal(9,-10) = ok 01835 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[12], smax)); 01836 01837 // MAX + 1 -> decimal(9,-10) = ok 01838 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[13], smax)); 01839 01840 // MAX.12345 -> decimal(19,-10) = ok 01841 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[14], smax)); 01842 01843 // MAX.9 -> decimal(19,-10) = ok 01844 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[15], smax)); 01845 01846 // MIN - 1 -> decimal(9,-10) = ok 01847 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[16], smin)); 01848 01849 // (MIN+1).9 -> decimal(9,-10) = ok 01850 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[17], smin)); 01851 01852 // MIN.9 -> decimal(9,-10) = ok 01853 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[18], smin)); 01854 01855 // 9323415432153452535 -> decimal(9,-10) = ok 01856 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[19], 932341543ll)); 01857 01858 // 9.78E+18 -> decimal(9,-10) = ok 01859 BOOST_CHECK_EQUAL(0, cmpTupInt64(outTuple[20], 978000000ll)); 01860 01861 // 9.78E+20 -> decimal(9,-10) = out of range 01862 BOOST_CHECK_EQUAL(iter->pc, 21); 01863 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01864 iter++; 01865 01866 BOOST_CHECK(iter == calc.mWarnings.end()); 01867 }
void CalcExtCastTest::testCalcExtCastStringToDecimalRange | ( | ) | [private] |
Definition at line 1870 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupInt(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, outOfRangeErr, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01871 { 01872 // test values: 1000 999.999, 999.991 9.99999e2 9.9999e2, 01873 // 99999999990000000000e-20, cast to decimal(5, 2) 01874 ostringstream pg(""), outloc(""); 01875 outloc << "s8, s8, s8, s8, s8, s8;" << endl; 01876 pg << "O " << outloc.str(); 01877 pg << "L " << outloc.str(); 01878 pg << "C vc,30, vc,30, vc,30, vc,30, vc,30, vc,30, " 01879 << " s4, s4;" << endl; 01880 pg << "V 0x" << stringToHex("1000") 01881 << ", 0x" << stringToHex("999.999") 01882 << ", 0x" << stringToHex("999.991") 01883 << ", 0x" << stringToHex("9.99999e2") 01884 << ", 0x" << stringToHex("9.9999e2") 01885 << ", 0x" << stringToHex("99999999990000000000e-20") 01886 << ", 5, 2;" << endl; 01887 pg << "T;" << endl; 01888 01889 for (int i = 0; i < 6; i++) { 01890 pg << "CALL 'castA(L" << i << ",C" << i << ",C6, C7);" << endl; 01891 } 01892 refLocalOutput(pg, 6); // make output available 01893 01894 Calculator calc(0); 01895 try { 01896 calc.assemble(pg.str().c_str()); 01897 } catch (FennelExcn& ex) { 01898 cout << ex.getMessage(); 01899 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01900 BOOST_MESSAGE(pg.str()); 01901 BOOST_REQUIRE(0); 01902 } 01903 01904 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01905 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01906 calc.bind(&inTuple, &outTuple); 01907 calc.exec(); 01908 printOutput(outTuple, calc); 01909 01910 // check results: 01911 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 01912 01913 // decimal(5,2) 01914 // 1000 -> decimal(5,2) = out of range 01915 BOOST_CHECK_EQUAL(iter->pc, 0); 01916 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01917 iter++; 01918 01919 // 999.999 -> decimal(5,2) = out of range 01920 BOOST_CHECK_EQUAL(iter->pc, 1); 01921 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01922 iter++; 01923 01924 // 999.991 -> decimal(5,2) = ok 01925 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[2], 99999)); 01926 01927 // 9.99999e2 -> decimal(5,2) = out of range 01928 BOOST_CHECK_EQUAL(iter->pc, 3); 01929 BOOST_CHECK_EQUAL(0, strcmp(iter->str, outOfRangeErr)); 01930 iter++; 01931 01932 // 9.9999e2 -> decimal(5,2) = ok 01933 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[4], 99999)); 01934 01935 // 99999999990000000000e-20 -> decimal(5,2) = ok 01936 BOOST_CHECK_EQUAL(0, cmpTupInt(outTuple[5], 100)); 01937 BOOST_CHECK(iter == calc.mWarnings.end()); 01938 }
void CalcExtCastTest::testCalcExtCastStringToApprox | ( | ) | [private] |
Definition at line 1941 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupDouble(), cmpTupNull(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), refLocalOutput(), and stringToHex().
Referenced by CalcExtCastTest().
01942 { 01943 // test values: null, 0, 0.0, .0, 1.98, -1.98, 0.001, 0.00100 01944 // as varchar(8), as trim chars, and as char(16). 01945 ostringstream pg(""), outloc(""); 01946 outloc << "d, d, d, d, d, d, d, d, " 01947 << "d, d, d, d, d, d, d, d, " 01948 << "d, d, d, d, d, d, d, d;" << endl; 01949 pg << "O " << outloc.str(); 01950 pg << "L " << outloc.str(); 01951 pg << "C " 01952 << "vc,8, vc,8, vc,8, vc,8, vc,8, vc,8, vc,8, vc,8, " 01953 << "c,1, c,1, c,3, c,2, c,4, c,5, c,5, c,7, " 01954 << "c,16, c,16, c,16, c,16, c,16, c,16, c,16, c,16;" << endl; 01955 pg << "V "; 01956 for (int i = 0; i < 2; i++) { 01957 pg << "," 01958 << "0x" << stringToHex("0") << "," 01959 << "0x" << stringToHex("0.0") << "," 01960 << "0x" << stringToHex(".0") << "," 01961 << "0x" << stringToHex("1.98") << "," 01962 << "0x" << stringToHex("-1.98") << "," 01963 << "0x" << stringToHex("0.001") << "," 01964 << "0x" << stringToHex("0.00100") << ","; 01965 } 01966 // same values padded to char(16) 01967 pg << "," 01968 << "0x" << stringToHex("0 ") << "," 01969 << "0x" << stringToHex("0.0 ") << "," 01970 << "0x" << stringToHex(".0 ") << "," 01971 << "0x" << stringToHex("1.98 ") << "," 01972 << "0x" << stringToHex("-1.98 ") << "," 01973 << "0x" << stringToHex("0.001 ") << "," 01974 << "0x" << stringToHex("0.00100 ") << ";" << endl; 01975 pg << "T;" << endl; 01976 for (int i = 0; i < 8; i++) { 01977 pg << "CALL 'castA(L" << i << ", C" << i << ");" << endl; 01978 } 01979 for (int i = 0; i < 8; i++) { 01980 pg << "CALL 'castA(L" << (i + 8) << ", C" << i << ");" << endl; 01981 } 01982 for (int i = 0; i < 8; i++) { 01983 pg << "CALL 'castA(L" << (i + 16) << ", C" << i << ");" << endl; 01984 } 01985 refLocalOutput(pg, 24); // make output available 01986 01987 Calculator calc(0); 01988 try { 01989 calc.assemble(pg.str().c_str()); 01990 } catch (FennelExcn& ex) { 01991 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 01992 BOOST_MESSAGE(pg.str()); 01993 BOOST_REQUIRE(0); 01994 } 01995 01996 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 01997 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 01998 calc.bind(&inTuple, &outTuple); 01999 calc.exec(); 02000 printOutput(outTuple, calc); 02001 02002 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 02003 // check 3 identical sets of 8 values 02004 for (int pass = 0, i = 0; pass < 3; pass++) { 02005 BOOST_CHECK(cmpTupNull(outTuple[i++])); 02006 BOOST_CHECK_EQUAL(0, cmpTupDouble(outTuple[i++], 0)); 02007 BOOST_CHECK_EQUAL(0, cmpTupDouble(outTuple[i++], 0)); 02008 BOOST_CHECK_EQUAL(0, cmpTupDouble(outTuple[i++], 0)); 02009 BOOST_CHECK_EQUAL(0, cmpTupDouble(outTuple[i++], 1.98)); 02010 BOOST_CHECK_EQUAL(0, cmpTupDouble(outTuple[i++], -1.98)); 02011 BOOST_CHECK_EQUAL(0, cmpTupDouble(outTuple[i++], 0.001)); 02012 BOOST_CHECK_EQUAL(0, cmpTupDouble(outTuple[i++], 0.001)); 02013 } 02014 BOOST_CHECK(iter == calc.mWarnings.end()); 02015 }
void CalcExtCastTest::testCalcExtCastApproxToString | ( | ) | [private] |
Definition at line 2017 of file CalcExtCastTest.cpp.
References Calculator::assemble(), Calculator::bind(), cmpTupNull(), cmpTupStr(), Calculator::exec(), Calculator::getInputRegisterDescriptor(), FennelExcn::getMessage(), Calculator::getOutputRegisterDescriptor(), Calculator::mWarnings, printOutput(), and refLocalOutput().
Referenced by CalcExtCastTest().
02018 { 02019 // double test values: null, 0, +1.98, -1.98, +0.001, -0.001 02020 02021 ostringstream pg(""), outloc(""); 02022 outloc << "vc,16, vc,16, vc,16, vc,16, vc,16, vc,16, " 02023 << "c,16, c,16, c,16, c,16, c,16, c,16;" << endl; 02024 pg << "O " << outloc.str(); 02025 pg << "L " << outloc.str(); 02026 pg << "C d,d,d,d,d,d;" << endl; 02027 pg << "V , 0.0, 1.98, -1.98, 0.001, -0.001;" << endl; 02028 pg << "T;" << endl; 02029 for (int i = 0; i < 6; i++) { 02030 pg << "CALL 'castA(L" << i << ", C" << i << ");" << endl; 02031 } 02032 for (int i = 0; i < 6; i++) { 02033 pg << "CALL 'castA(L" << (i + 6) << ", C" << i << ");" << endl; 02034 } 02035 refLocalOutput(pg, 12); // make output available 02036 // cerr << "testCalcExtCastApproxToString Program:\n" << pg.str() << endl; 02037 02038 Calculator calc(0); 02039 try { 02040 calc.assemble(pg.str().c_str()); 02041 } catch (FennelExcn& ex) { 02042 BOOST_MESSAGE("Assemble exception " << ex.getMessage()); 02043 BOOST_MESSAGE(pg.str()); 02044 BOOST_REQUIRE(0); 02045 } 02046 02047 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor()); 02048 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor()); 02049 calc.bind(&inTuple, &outTuple); 02050 calc.exec(); 02051 printOutput(outTuple, calc); 02052 02053 deque<CalcMessage>::iterator iter = calc.mWarnings.begin(); 02054 02055 int i = 0; 02056 // first the varchars 02057 // TODO: fix these strings when calc/SqlString produces terser results. 02058 BOOST_CHECK(cmpTupNull(outTuple[i++])); 02059 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "0E0")); 02060 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "1.98E0")); 02061 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "-1.98E0")); 02062 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "1E-3")); 02063 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "-1E-3")); 02064 // then the char(16)s 02065 BOOST_CHECK(cmpTupNull(outTuple[i++])); 02066 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "0E0 ")); 02067 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "1.98E0 ")); 02068 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "-1.98E0 ")); 02069 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "1E-3 ")); 02070 BOOST_CHECK_EQUAL(0, cmpTupStr(outTuple[i++], "-1E-3 ")); 02071 BOOST_CHECK(iter == calc.mWarnings.end()); 02072 }
int CalcExtCastTest::cmpTupStr | ( | TupleDatum const & | tup, | |
char const *const | str | |||
) | [private] |
Definition at line 209 of file CalcExtCastTest.cpp.
References TupleDatum::cbData, cmpTupNull(), and TupleDatum::pData.
Referenced by cmpTupStr(), testCalcExtCastApproxToString(), testCalcExtCastBigExactToString(), testCalcExtCastBooleanToChar(), testCalcExtCastBooleanToVarChar(), testCalcExtCastDecimalToChar(), testCalcExtCastDecimalToStringTruncates(), testCalcExtCastDecimalToVarChar(), testCalcExtCastExactToChar(), testCalcExtCastExactToStringTruncates(), testCalcExtCastExactToVarChar(), testCalcExtCastStringToChar(), and testCalcExtCastStringToVarChar().
00212 { 00213 if (cmpTupNull(tup)) { 00214 return 1; 00215 } 00216 int len = strlen(str); 00217 BOOST_CHECK_EQUAL(len, tup.cbData); 00218 return strncmp( 00219 reinterpret_cast<char *>(const_cast<PBuffer>(tup.pData)), 00220 str, 00221 len); 00222 }
int CalcExtCastTest::cmpTupStr | ( | TupleDatum const & | tup, | |
const string & | str | |||
) | [private] |
Definition at line 201 of file CalcExtCastTest.cpp.
References cmpTupStr().
00204 { 00205 return cmpTupStr(tup, s.c_str()); 00206 }
int CalcExtCastTest::cmpTupBool | ( | TupleDatum const & | tup, | |
bool | val | |||
) | [private] |
Definition at line 225 of file CalcExtCastTest.cpp.
References cmpTupNull(), and TupleDatum::pData.
Referenced by testCalcExtCastCharToBoolean(), and testCalcExtCastVarCharToBoolean().
00226 { 00227 if (cmpTupNull(tup)) { 00228 return 0; 00229 } 00230 return *(reinterpret_cast<bool*> 00231 (const_cast<PBuffer>(tup.pData))) == val; 00232 }
int CalcExtCastTest::cmpTupInt | ( | TupleDatum const & | tup, | |
int | val | |||
) | [private] |
Definition at line 165 of file CalcExtCastTest.cpp.
References cmpTupNull(), and TupleDatum::pData.
Referenced by testCalcExtCastCharToDecimal(), testCalcExtCastCharToExact(), testCalcExtCastStringToDecimalRange(), testCalcExtCastVarCharToDecimal(), and testCalcExtCastVarCharToExact().
00166 { 00167 if (cmpTupNull(tup)) { 00168 return 1; 00169 } 00170 return *(reinterpret_cast<int*> 00171 (const_cast<PBuffer>(tup.pData))) - val; 00172 }
int CalcExtCastTest::cmpTupInt64 | ( | TupleDatum const & | tup, | |
int64_t | val | |||
) | [private] |
Definition at line 189 of file CalcExtCastTest.cpp.
References cmpTupNull(), and TupleDatum::pData.
Referenced by testCalcExtCastCharToExact(), testCalcExtCastStringToDecimalMinMax(), and testCalcExtCastVarCharToExact().
00192 { 00193 if (cmpTupNull(tup)) { 00194 return 1; 00195 } 00196 return *(reinterpret_cast<int64_t*> 00197 (const_cast<PBuffer>(tup.pData))) - val; 00198 }
int CalcExtCastTest::cmpTupNull | ( | TupleDatum const & | tup | ) | [private] |
Definition at line 235 of file CalcExtCastTest.cpp.
References TupleDatum::pData.
Referenced by cmpTupBool(), cmpTupDouble(), cmpTupInt(), cmpTupInt64(), cmpTupStr(), testCalcExtCastApproxToString(), testCalcExtCastBooleanToChar(), testCalcExtCastBooleanToVarChar(), testCalcExtCastCharToBoolean(), testCalcExtCastCharToDecimal(), testCalcExtCastCharToExact(), testCalcExtCastDecimalToChar(), testCalcExtCastDecimalToVarChar(), testCalcExtCastExactToChar(), testCalcExtCastExactToVarChar(), testCalcExtCastStringToApprox(), testCalcExtCastStringToChar(), testCalcExtCastStringToVarChar(), testCalcExtCastVarCharToBoolean(), testCalcExtCastVarCharToDecimal(), and testCalcExtCastVarCharToExact().
int CalcExtCastTest::cmpTupDouble | ( | TupleDatum const & | tup, | |
double | val | |||
) | [private] |
Definition at line 175 of file CalcExtCastTest.cpp.
References cmpTupNull(), and TupleDatum::pData.
Referenced by testCalcExtCastStringToApprox().
00176 { 00177 if (cmpTupNull(tup)) { 00178 return 1; 00179 } 00180 double tval = * reinterpret_cast<double*> 00181 (const_cast<PBuffer>(tup.pData)); 00182 if (fabs(tval - val) < 0.00001) { 00183 return 0; 00184 } 00185 return (tval > val) ? 1 : -1; 00186 }
void CalcExtCastTest::printOutput | ( | TupleData const & | tup, | |
Calculator const & | calc | |||
) | [private] |
Definition at line 242 of file CalcExtCastTest.cpp.
References Calculator::getOutputRegisterDescriptor(), TuplePrinter::print(), and verbose.
Referenced by testCalcExtCastApproxToString(), testCalcExtCastBigExactToString(), testCalcExtCastBooleanToChar(), testCalcExtCastBooleanToVarChar(), testCalcExtCastCharToBoolean(), testCalcExtCastCharToDecimal(), testCalcExtCastCharToExact(), testCalcExtCastDecimalToChar(), testCalcExtCastDecimalToStringTruncates(), testCalcExtCastDecimalToVarChar(), testCalcExtCastExactToChar(), testCalcExtCastExactToStringTruncates(), testCalcExtCastExactToVarChar(), testCalcExtCastStringToApprox(), testCalcExtCastStringToChar(), testCalcExtCastStringToDecimalFails(), testCalcExtCastStringToDecimalMinMax(), testCalcExtCastStringToDecimalRange(), testCalcExtCastStringToExactFails(), testCalcExtCastStringToVarChar(), testCalcExtCastVarCharToBoolean(), testCalcExtCastVarCharToDecimal(), and testCalcExtCastVarCharToExact().
00245 { 00246 if (verbose) { 00247 TuplePrinter tuplePrinter; 00248 tuplePrinter.print(cout, calc.getOutputRegisterDescriptor(), tup); 00249 cout << endl; 00250 } 00251 }
void CalcExtCastTest::refLocalOutput | ( | ostringstream & | pg, | |
int | count | |||
) | [private] |
Definition at line 256 of file CalcExtCastTest.cpp.
Referenced by testCalcExtCastApproxToString(), testCalcExtCastBigExactToString(), testCalcExtCastBooleanToChar(), testCalcExtCastBooleanToVarChar(), testCalcExtCastCharToBoolean(), testCalcExtCastCharToDecimal(), testCalcExtCastCharToExact(), testCalcExtCastDecimalToChar(), testCalcExtCastDecimalToStringTruncates(), testCalcExtCastDecimalToVarChar(), testCalcExtCastExactToChar(), testCalcExtCastExactToStringTruncates(), testCalcExtCastExactToVarChar(), testCalcExtCastStringToApprox(), testCalcExtCastStringToChar(), testCalcExtCastStringToDecimalFails(), testCalcExtCastStringToDecimalMinMax(), testCalcExtCastStringToDecimalRange(), testCalcExtCastStringToExactFails(), testCalcExtCastStringToVarChar(), testCalcExtCastVarCharToBoolean(), testCalcExtCastVarCharToDecimal(), and testCalcExtCastVarCharToExact().
00259 { 00260 int i; 00261 00262 for (i = 0; i < count; i++) { 00263 pg << "REF O" << i << ", L" << i << ";" << endl; 00264 } 00265 }
string CalcExtCastTest::minInt64String | ( | ) | [private] |
Definition at line 138 of file CalcExtCastTest.cpp.
References min().
Referenced by testCalcExtCastBigExactToString(), testCalcExtCastCharToExact(), testCalcExtCastStringToDecimalMinMax(), and testCalcExtCastVarCharToExact().
00139 { 00140 ostringstream os(""); 00141 os << dec << numeric_limits<int64_t>::min(); 00142 return os.str(); 00143 }
string CalcExtCastTest::maxInt64String | ( | ) | [private] |
Definition at line 146 of file CalcExtCastTest.cpp.
References max().
Referenced by testCalcExtCastBigExactToString(), testCalcExtCastCharToExact(), testCalcExtCastStringToDecimalMinMax(), and testCalcExtCastVarCharToExact().
00147 { 00148 ostringstream os(""); 00149 os << dec << numeric_limits<int64_t>::max(); 00150 return os.str(); 00151 }
string CalcExtCastTest::rpad | ( | string | s, | |
int | size, | |||
char | pad = ' ' | |||
) | [private] |
Definition at line 155 of file CalcExtCastTest.cpp.
Referenced by testCalcExtCastBigExactToString(), testCalcExtCastCharToExact(), and testCalcExtCastVarCharToExact().
00156 { 00157 int n = size - s.size(); 00158 if (n > 0) { 00159 s.append(n, pad); 00160 } 00161 return s; 00162 }
void TestBase::snooze | ( | uint | nSeconds | ) | [protected, inherited] |
Definition at line 263 of file TestBase.cpp.
Referenced by DatabaseTest::executeForceTxn(), ThreadedTestBase::runThreadedTestCase(), PagingTestBase::testCacheResize(), BTreeTxnTest::testCheckpoint(), PagingTestBase::testCheckpointGuarded(), PagingTestBase::testPrefetch(), and PagingTestBase::testPrefetchBatch().
00264 { 00265 #ifdef __MSVC__ 00266 ::_sleep(nSeconds*1000); 00267 #else 00268 ::sleep(nSeconds); 00269 #endif 00270 }
void TestBase::readParams | ( | int | argc, | |
char ** | argv | |||
) | [static, inherited] |
Parses the command line.
format: [-v] [-t TEST | -all] {param=val}* [CONFIGFILE | -] Normally, the test program runs the default test cases. With the option "-all", runs the extra test cases as well. With the option "-t TEST", runs only the single test case named TEST. CONFIGFILE is read to load configuration parameters. Configuration parameters can also be set ad hoc, from the command line, as pairs name=val. These take precedence.
Definition at line 108 of file TestBase.cpp.
References TestBase::configMap, ConfigMap::dumpParams(), ConfigMap::isParamSet(), ConfigMap::mergeFrom(), TestBase::paramDictionaryFileName, ConfigMap::readParams(), TestBase::runAll, TestBase::runSingle, ConfigMap::setStringParam(), and verbose.
00109 { 00110 bool verbose = false; 00111 ConfigMap adhocMap; 00112 00113 for (int i = 1; i < argc; ++i) { 00114 std::string arg = argv[i]; 00115 if (argv[i][0] == '-') { 00116 if (arg == "-v") { 00117 verbose = true; 00118 } else if (arg == "-") { 00119 configMap.readParams(std::cin); 00120 } else if (arg == "-all") { 00121 runAll = true; 00122 } else if (arg == "-t") { // -t TEST 00123 permAssert(i + 1 < argc); 00124 runSingle = argv[++i]; 00125 } else if (arg[1] == 't') { // allow -tTEST 00126 runSingle = arg.substr(2); 00127 } 00128 } else { 00129 int i = arg.find("="); 00130 if ((0 < i) && (i < arg.size())) { 00131 // an ad hoc parameter 00132 std::string key = arg.substr(0,i); 00133 std::string val = arg.substr(i + 1); 00134 adhocMap.setStringParam(key,val); 00135 } else { 00136 // a config file name 00137 std::ifstream configFile(arg.c_str()); 00138 assert(configFile.good()); 00139 configMap.readParams(configFile); 00140 } 00141 } 00142 } 00143 configMap.mergeFrom(adhocMap); 00144 00145 // set a default dictionary file location for use by tests that need a 00146 // small non-random sorted data set 00147 if (!configMap.isParamSet(paramDictionaryFileName)) { 00148 std::string dictFileName = "dictWords"; 00149 configMap.setStringParam(paramDictionaryFileName,dictFileName); 00150 } 00151 00152 if (verbose) { 00153 configMap.dumpParams(std::cout); 00154 } 00155 }
TestSuite * TestBase::releaseTestSuite | ( | ) | [inherited] |
Definition at line 157 of file TestBase.cpp.
References TestBase::TestCaseGroup::addAllToTestSuite(), TestBase::defaultTests, TestBase::extraTests, TestBase::TestCaseGroup::findTest(), TestBase::pTestObj, TestBase::pTestSuite, TestBase::runAll, TestBase::runSingle, and TestBase::testName.
00158 { 00159 assert(pTestObj); 00160 assert(pTestObj.use_count() > 1); 00161 00162 // release self-reference now that all test cases have been registered 00163 pTestObj.reset(); 00164 00165 TestSuite* pTestSuite = BOOST_TEST_SUITE(testName.c_str()); 00166 00167 if (runSingle.size()) { 00168 test_unit *p = defaultTests.findTest(runSingle); 00169 if (!p) { 00170 p = extraTests.findTest(runSingle); 00171 } 00172 if (!p) { 00173 std::cerr << "test " << runSingle << " not found\n"; 00174 exit(2); 00175 } 00176 pTestSuite->add(p); 00177 } else { 00178 defaultTests.addAllToTestSuite(pTestSuite); 00179 if (runAll) { 00180 extraTests.addAllToTestSuite(pTestSuite); 00181 } 00182 } 00183 return pTestSuite; 00184 }
void TestBase::beforeTestCase | ( | std::string | testCaseName | ) | [inherited] |
Definition at line 214 of file TestBase.cpp.
References TestBase::configMap, TraceSource::initTraceSource(), AutoBacktrace::install(), TestBase::notifyTrace(), AutoBacktrace::setOutputStream(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.
00215 { 00216 notifyTrace(testName,TRACE_INFO,"ENTER: " + testCaseName); 00217 00218 // Install the AutoBacktrace signal handler now, after 00219 // boost::execution_monitor::catch_signals() has installed its own, so that 00220 // on SIGABRT AutoBacktrace goes first, prints the backtrace, then chains 00221 // to boost, which handles the error. 00222 AutoBacktrace::setOutputStream(); 00223 AutoBacktrace::setTraceTarget(shared_from_this()); 00224 AutoBacktrace::install(); 00225 configMap.initTraceSource(shared_from_this(), "testConfig"); 00226 }
void TestBase::afterTestCase | ( | std::string | testCaseName | ) | [inherited] |
Definition at line 228 of file TestBase.cpp.
References TestBase::configMap, TraceSource::disableTracing(), TestBase::notifyTrace(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.
00229 { 00230 AutoBacktrace::setTraceTarget(); 00231 configMap.disableTracing(); 00232 notifyTrace(testName,TRACE_INFO,"LEAVE: " + testCaseName); 00233 }
void TestBase::testCaseSetUp | ( | ) | [virtual, inherited] |
Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.
Default is no-op.
Reimplemented in LbmEntryTest, LbmExecStreamTestBase, LbmLoadBitmapTest, LbmSearchTest, LbmSplicerExecStreamTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, ExecStreamGovernorTest, ExecStreamTestBase, ExecStreamUnitTestBase, ExternalSortExecStreamTest, LhxHashTableTest, LogicalTxnTest, and SnapshotSegmentTestBase.
Definition at line 235 of file TestBase.cpp.
Referenced by ExecStreamTestBase::testCaseSetUp().
void TestBase::testCaseTearDown | ( | ) | [virtual, inherited] |
Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.
Default is no-op.
Reimplemented in LbmEntryTest, LbmLoadBitmapTest, LbmSearchTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, CacheTestBase, DatabaseTest, ExecStreamTestBase, LhxHashTableTest, RandomAccessFileDeviceTest, and SparseBitmapTest.
Definition at line 239 of file TestBase.cpp.
Referenced by SparseBitmapTest::testCaseTearDown().
void TestBase::notifyTrace | ( | std::string | source, | |
TraceLevel | level, | |||
std::string | message | |||
) | [virtual, inherited] |
Receives notification when a trace event occurs.
source | the facility from which the message originated | |
level | the trace event severity level | |
message | the text of the message |
Implements TraceTarget.
Definition at line 243 of file TestBase.cpp.
References TestBase::traceFile, TestBase::traceMutex, TestBase::traceStdout, and TestBase::traceStream.
Referenced by TestBase::afterTestCase(), and TestBase::beforeTestCase().
00244 { 00245 if (traceFile || traceStdout) { 00246 StrictMutexGuard traceMutexGuard(traceMutex); 00247 if (traceFile) { 00248 traceStream << "[" << source << "] " << message << std::endl; 00249 traceStream.flush(); 00250 } 00251 if (traceStdout) { 00252 std::cout << "[" << source << "] " << message << std::endl; 00253 std::cout.flush(); 00254 } 00255 } 00256 }
TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, inherited] |
Gets the level at which a particular source should be traced.
source | name of source to be traced |
Implements TraceTarget.
Definition at line 258 of file TestBase.cpp.
References TestBase::traceLevel.
Referenced by LbmExecStreamTestBase::generateBitmaps().
00259 { 00260 return traceLevel; 00261 }
void TraceSource::initTraceSource | ( | SharedTraceTarget | pTraceTarget, | |
std::string | name | |||
) | [virtual, inherited] |
For use when initialization has to be deferred until after construction.
pTraceTarget | the TraceTarget to which messages will be sent | |
name | the name of this source |
Definition at line 46 of file TraceSource.cpp.
References TraceSource::isTracing(), TraceSource::minimumLevel, TraceSource::name, TraceSource::pTraceTarget, and TRACE_OFF.
Referenced by TestBase::beforeTestCase(), TestBase::TestBase(), and TraceSource::TraceSource().
00049 { 00050 assert(!pTraceTarget.get()); 00051 00052 pTraceTarget = pTraceTargetInit; 00053 name = nameInit; 00054 if (isTracing()) { 00055 minimumLevel = pTraceTarget->getSourceTraceLevel(name); 00056 } else { 00057 minimumLevel = TRACE_OFF; 00058 } 00059 }
void TraceSource::trace | ( | TraceLevel | level, | |
std::string | message | |||
) | const [inherited] |
Records a trace message.
Normally only called via FENNEL_TRACE.
level | severity level of event being trace | |
message | the text of the message |
Definition at line 61 of file TraceSource.cpp.
References TraceSource::getTraceTarget(), TraceSource::isTracing(), TraceSource::name, and TraceTarget::notifyTrace().
Referenced by Calculator::exec(), and ExecStreamScheduler::traceStreamBufferContents().
00062 { 00063 if (isTracing()) { 00064 getTraceTarget().notifyTrace(name,level,message); 00065 } 00066 }
bool TraceSource::isTracing | ( | ) | const [inline, inherited] |
Definition at line 88 of file TraceSource.h.
Referenced by TraceSource::initTraceSource(), CalcExecStream::prepare(), and TraceSource::trace().
00089 { 00090 return pTraceTarget.get() ? true : false; 00091 }
bool TraceSource::isTracingLevel | ( | TraceLevel | level | ) | const [inline, inherited] |
Determines whether a particular level is being traced.
level | trace level to test |
Definition at line 100 of file TraceSource.h.
Referenced by ExecStreamScheduler::addGraph(), SimpleExecStreamGovernor::assignCachePages(), SimpleExecStreamGovernor::distributeCachePages(), Calculator::exec(), ExecStreamScheduler::ExecStreamScheduler(), LcsClusterNodeWriter::getLastClusterPageForWrite(), LcsClusterNodeWriter::moveFromTempToIndex(), JavaSinkExecStream::stuffByteBuffer(), and ExecStreamScheduler::traceStreamBuffers().
00101 { 00102 return level >= minimumLevel; 00103 }
TraceTarget& TraceSource::getTraceTarget | ( | ) | const [inline, inherited] |
Definition at line 108 of file TraceSource.h.
Referenced by TraceSource::trace().
00109 { 00110 assert(isTracing()); 00111 return *(pTraceTarget.get()); 00112 }
SharedTraceTarget TraceSource::getSharedTraceTarget | ( | ) | const [inline, inherited] |
Definition at line 117 of file TraceSource.h.
Referenced by Database::init(), LcsClusterAppendExecStream::initLoad(), and CalcExecStream::prepare().
00118 { 00119 return pTraceTarget; 00120 }
std::string TraceSource::getTraceSourceName | ( | ) | const [inline, inherited] |
Gets the name of this source.
Useful to construct nested names for subcomponents that are also TraceSources.
Definition at line 127 of file TraceSource.h.
Referenced by LcsClusterAppendExecStream::initLoad().
00128 { 00129 return name; 00130 }
void TraceSource::setTraceSourceName | ( | std::string const & | n | ) | [inline, inherited] |
Sets the name of this source.
Useful to construct dynamic names for fine-grained filtering.
Definition at line 136 of file TraceSource.h.
00137 { 00138 name = n; 00139 }
TraceLevel TraceSource::getMinimumTraceLevel | ( | ) | const [inline, inherited] |
void TraceSource::disableTracing | ( | ) | [inherited] |
Definition at line 68 of file TraceSource.cpp.
References TraceSource::minimumLevel, TraceSource::pTraceTarget, and TRACE_OFF.
Referenced by TestBase::afterTestCase().
00069 { 00070 pTraceTarget.reset(); 00071 minimumLevel = TRACE_OFF; 00072 }
const bool CalcExtCastTest::verbose = true [static, private] |
const char * CalcExtCastTest::truncErr [static, private] |
Definition at line 87 of file CalcExtCastTest.cpp.
Referenced by testCalcExtCastDecimalToStringTruncates(), and testCalcExtCastExactToStringTruncates().
const char * CalcExtCastTest::invalidCharErr [static, private] |
Definition at line 88 of file CalcExtCastTest.cpp.
Referenced by testCalcExtCastBooleanToChar(), testCalcExtCastBooleanToVarChar(), testCalcExtCastCharToBoolean(), testCalcExtCastStringToDecimalFails(), testCalcExtCastStringToExactFails(), and testCalcExtCastVarCharToBoolean().
const char * CalcExtCastTest::outOfRangeErr [static, private] |
Definition at line 89 of file CalcExtCastTest.cpp.
Referenced by testCalcExtCastStringToDecimalMinMax(), and testCalcExtCastStringToDecimalRange().
TestSuite* TestBase::pTestSuite [protected, inherited] |
Boost test suite.
Definition at line 59 of file TestBase.h.
Referenced by TestBase::releaseTestSuite().
boost::shared_ptr<TestBase> TestBase::pTestObj [protected, inherited] |
Definition at line 61 of file TestBase.h.
Referenced by TestBase::releaseTestSuite(), and TestBase::TestBase().
std::ofstream TestBase::traceStream [protected, inherited] |
Output file stream for tracing.
Definition at line 66 of file TestBase.h.
Referenced by TestBase::notifyTrace(), TestBase::TestBase(), and TestBase::~TestBase().
StrictMutex TestBase::traceMutex [protected, inherited] |
Protects traceStream.
Definition at line 71 of file TestBase.h.
Referenced by TestBase::notifyTrace().
std::string TestBase::testName [protected, inherited] |
Name of test.
Definition at line 76 of file TestBase.h.
Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), TestBase::releaseTestSuite(), TestBase::TestBase(), LhxHashTableTest::testInsert1Ka(), and LhxHashTableTest::testInsert1Kb().
TraceLevel TestBase::traceLevel [protected, inherited] |
Level at which to trace test execution.
Definition at line 81 of file TestBase.h.
Referenced by TestBase::getSourceTraceLevel(), and TestBase::TestBase().
FileStatsTarget TestBase::statsTarget [protected, inherited] |
StatsTimer TestBase::statsTimer [protected, inherited] |
Timer for stats collection.
Definition at line 91 of file TestBase.h.
Referenced by CacheTestBase::closeStorage(), CacheTestBase::openStorage(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCaseTearDown(), and BTreeTxnTest::testTxns().
bool TestBase::traceStdout [protected, inherited] |
Copy trace output to stdout.
Definition at line 99 of file TestBase.h.
Referenced by TestBase::notifyTrace(), and TestBase::TestBase().
bool TestBase::traceFile [protected, inherited] |
Copy trace output to file.
Definition at line 104 of file TestBase.h.
Referenced by TestBase::notifyTrace(), and TestBase::TestBase().
bool TestBase::runAll [static, protected, inherited] |
Run all test cases, including the extra tests.
(static, since set by readParams())
Definition at line 110 of file TestBase.h.
Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().
std::string TestBase::runSingle [static, protected, inherited] |
Run only the test case of this name.
(static, since set by readParams())
Definition at line 116 of file TestBase.h.
Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().
TestCaseGroup TestBase::defaultTests [protected, inherited] |
TestCaseGroup TestBase::extraTests [protected, inherited] |
ParamName TestBase::paramTestSuiteName [static, inherited] |
ParamName TestBase::paramTraceFileName [static, inherited] |
ParamName TestBase::paramDictionaryFileName [static, inherited] |
Definition at line 145 of file TestBase.h.
Referenced by TestBase::readParams(), SegStreamTest::testRead(), and SegStreamTest::testWrite().
ParamName TestBase::paramTraceLevel [static, inherited] |
ParamName TestBase::paramStatsFileName [static, inherited] |
Definition at line 147 of file TestBase.h.
ParamName TestBase::paramTraceStdout [static, inherited] |
ParamName TestBase::paramDegreeOfParallelism [static, inherited] |
Definition at line 149 of file TestBase.h.
Referenced by ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest().
ConfigMap TestBase::configMap [static, inherited] |
Configuration parameters.
The reason this is static is so that no constructor parameters (which burden virtual bases) are needed.
Definition at line 155 of file TestBase.h.
Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), BTreeTxnTest::BTreeTxnTest(), CacheTestBase::CacheTestBase(), BackupRestoreTest::createSnapshotData(), DatabaseTest::DatabaseTest(), TestOptionsTest::extra(), DatabaseTest::loadDatabase(), SparseBitmapTest::openStorage(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), RandomAccessFileDeviceTest::RandomAccessFileDeviceTest(), TestBase::readParams(), SegStorageTestBase::SegStorageTestBase(), TestOptionsTest::test1(), TestOptionsTest::test2(), BackupRestoreTest::testBackupCleanup(), TestBase::TestBase(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCheckpoint(), DatabaseTest::testCreateEmpty(), DatabaseTest::testForceTxns(), BackupRestoreTest::testHeaderBackupRestore(), SegPageEntryIterTest::testIter(), SegStreamTest::testRead(), BTreeTxnTest::testTxns(), SegStreamTest::testWrite(), ThreadedTestBase::ThreadedTestBase(), and TestBase::~TestBase().