00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "fennel/common/CommonPreamble.h"
00024 #include "fennel/test/TestBase.h"
00025 #include "fennel/common/TraceSource.h"
00026
00027 #include "fennel/tuple/TupleDataWithBuffer.h"
00028 #include "fennel/tuple/TuplePrinter.h"
00029 #include "fennel/calculator/CalcCommon.h"
00030 #include "fennel/calculator/StringToHex.h"
00031 #include "fennel/common/FennelExcn.h"
00032
00033 #include <boost/test/test_tools.hpp>
00034 #include <boost/scoped_array.hpp>
00035 #include <string>
00036 #include <limits>
00037
00038
00039 using namespace fennel;
00040 using namespace std;
00041
00042
00043 class CalcExtRegExpTest : virtual public TestBase, public TraceSource
00044 {
00045 void testCalcExtRegExpLikeAVarChar();
00046 void testCalcExtRegExpLikeAChar();
00047 void testCalcExtRegExpSimilarAVarChar();
00048 void testCalcExtRegExpSimilarAChar();
00049
00050 void likeHelper(
00051 TupleDataWithBuffer const & outTuple,
00052 bool const * exp,
00053 int validoutputs,
00054 int nulloutputs,
00055 deque<CalcMessage> dq);
00056
00057 void similarHelper(
00058 TupleDataWithBuffer const & outTuple,
00059 bool const * exp,
00060 int validoutputs,
00061 int nulloutputs,
00062 deque<CalcMessage> dq);
00063
00064 int cmpTupStr(
00065 TupleDatum const & tup,
00066 char const * const str);
00067
00068 int cmpTupInt(
00069 TupleDatum const & tup,
00070 int val);
00071
00072 int cmpTupBool(
00073 TupleDatum const & tup,
00074 bool val);
00075
00076 int cmpTupNull(TupleDatum const & tup);
00077
00078 void printOutput(
00079 TupleData const & tup,
00080 Calculator const & calc);
00081
00082 void refLocalOutput(
00083 ostringstream& pg,
00084 int count);
00085
00086 static const char* truncErr;
00087 static const char* substrErr;
00088
00089 public:
00090 explicit CalcExtRegExpTest()
00091 : TraceSource(shared_from_this(), "CalcExtRegExpTest")
00092 {
00093 srand(time(NULL));
00094 CalcInit::instance();
00095 FENNEL_UNIT_TEST_CASE(CalcExtRegExpTest, testCalcExtRegExpLikeAVarChar);
00096 FENNEL_UNIT_TEST_CASE(CalcExtRegExpTest, testCalcExtRegExpLikeAChar);
00097 FENNEL_UNIT_TEST_CASE(
00098 CalcExtRegExpTest, testCalcExtRegExpSimilarAVarChar);
00099 FENNEL_UNIT_TEST_CASE(CalcExtRegExpTest, testCalcExtRegExpSimilarAChar);
00100 }
00101
00102 virtual ~CalcExtRegExpTest()
00103 {
00104 }
00105 };
00106
00107 const char *
00108 CalcExtRegExpTest::truncErr = "22001";
00109
00110 const char *
00111 CalcExtRegExpTest::substrErr = "22011";
00112
00113 int
00114 CalcExtRegExpTest::cmpTupStr(
00115 TupleDatum const & tup,
00116 char const * const str)
00117 {
00118 int len = strlen(str);
00119 BOOST_CHECK_EQUAL(len, tup.cbData);
00120 return strncmp(
00121 reinterpret_cast<char *>(const_cast<PBuffer>(tup.pData)),
00122 str,
00123 len);
00124 }
00125
00126 int
00127 CalcExtRegExpTest::cmpTupInt(
00128 TupleDatum const & tup,
00129 int val)
00130 {
00131 return *(reinterpret_cast<int*>
00132 (const_cast<PBuffer>(tup.pData))) - val;
00133 }
00134
00135 int
00136 CalcExtRegExpTest::cmpTupBool(
00137 TupleDatum const & tup,
00138 bool val)
00139 {
00140 return *(reinterpret_cast<bool*>
00141 (const_cast<PBuffer>(tup.pData))) != val;
00142 }
00143
00144 int
00145 CalcExtRegExpTest::cmpTupNull(TupleDatum const & tup)
00146 {
00147 if ((const_cast<PBuffer>(tup.pData)) == NULL) {
00148 return 1;
00149 }
00150 return 0;
00151 }
00152
00153
00154 void
00155 CalcExtRegExpTest::printOutput(
00156 TupleData const & tup,
00157 Calculator const & calc)
00158 {
00159 #if 0
00160 TuplePrinter tuplePrinter;
00161 tuplePrinter.print(cout, calc.getOutputRegisterDescriptor(), tup);
00162 cout << endl;
00163 #endif
00164 }
00165
00166
00167 void
00168 CalcExtRegExpTest::refLocalOutput(
00169 ostringstream& pg,
00170 int count)
00171 {
00172 int i;
00173
00174 for (i = 0; i < count; i++) {
00175 pg << "REF O" << i << ", L" << i << ";" << endl;
00176 }
00177 }
00178
00179 void
00180 CalcExtRegExpTest::likeHelper(
00181 TupleDataWithBuffer const & outTuple,
00182 bool const * exp,
00183 int validoutputs,
00184 int nulloutputs,
00185 deque<CalcMessage> dq)
00186 {
00187 int i;
00188 deque<CalcMessage>::iterator iter = dq.begin();
00189 deque<CalcMessage>::iterator end = dq.end();
00190
00191 for (i = 0; i < validoutputs; i++) {
00192 if (cmpTupBool(outTuple[i], exp[i])) {
00193 BOOST_MESSAGE("error on valid output [" << i << "]");
00194 }
00195 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], exp[i]));
00196 }
00197
00198 for (i = validoutputs; i < nulloutputs; i++) {
00199 if (!cmpTupNull(outTuple[i])) {
00200 BOOST_MESSAGE("error on null output [" << i << "]");
00201 }
00202 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[i]));
00203 }
00204 BOOST_CHECK(iter != end);
00205 BOOST_CHECK_EQUAL(iter->pc, nulloutputs);
00206 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "22019"));
00207 iter++;
00208 BOOST_CHECK(iter != end);
00209
00210 BOOST_CHECK(iter != end);
00211 BOOST_CHECK_EQUAL(iter->pc, nulloutputs + 1);
00212 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "22019"));
00213 iter++;
00214 BOOST_CHECK(iter != end);
00215
00216 BOOST_CHECK_EQUAL(iter->pc, nulloutputs + 2);
00217 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "22025"));
00218 iter++;
00219 BOOST_CHECK(iter == end);
00220
00221 }
00222
00223
00224
00225 void
00226 CalcExtRegExpTest::testCalcExtRegExpLikeAVarChar()
00227 {
00228 ostringstream pg(""), outloc(""), constants("");
00229 int i;
00230 int outputs = 23;
00231
00232 bool exp[40];
00233 BOOST_REQUIRE((sizeof(exp) / sizeof(bool)) >= outputs);
00234
00235 for (i = 0; i < outputs - 1; i++) {
00236 outloc << "bo, ";
00237 }
00238 outloc << "bo;" << endl;
00239
00240
00241 for (i = 0; i <= 9; i++) {
00242 constants << "vc,5, ";
00243 }
00244 constants << "vc,5;" << endl;
00245
00246 pg << "O " << outloc.str();
00247 pg << "L " << outloc.str();
00248 pg << "C " << constants.str();
00249 pg << "V 0x" << stringToHex("_");
00250 pg << ", 0x" << stringToHex("%");
00251 pg << ", 0x" << stringToHex("=");
00252 pg << ", 0x" << stringToHex("=_");
00253 pg << ", 0x" << stringToHex("=%");
00254 pg << ", 0x" << stringToHex("ab");
00255 pg << ", 0x" << stringToHex("ba");
00256 pg << ", 0x" << stringToHex("a%");
00257 pg << ", 0x" << stringToHex("a_");
00258 pg << ", 0x" << stringToHex("");
00259 pg << ",;" << endl;
00260 pg << "T;" << endl;
00261
00262
00263
00264
00265
00266
00267 pg << "CALL 'strLikeA3(L0, C5, C1);" << endl; exp[0] = true;
00268 pg << "CALL 'strLikeA3(L1, C5, C0);" << endl; exp[1] = false;
00269 pg << "CALL 'strLikeA3(L2, C5, C7);" << endl; exp[2] = true;
00270 pg << "CALL 'strLikeA3(L3, C6, C7);" << endl; exp[3] = false;
00271 pg << "CALL 'strLikeA3(L4, C5, C8);" << endl; exp[4] = true;
00272 pg << "CALL 'strLikeA3(L5, C6, C8);" << endl; exp[5] = false;
00273 pg << "CALL 'strLikeA3(L6, C0, C0);" << endl; exp[6] = true;
00274 pg << "CALL 'strLikeA3(L7, C0, C1);" << endl; exp[7] = true;
00275
00276
00277 pg << "CALL 'strLikeA4(L8, C5, C0, C2);" << endl; exp[8] = false;
00278 pg << "CALL 'strLikeA4(L9, C5, C1, C2);" << endl; exp[9] = true;
00279 pg << "CALL 'strLikeA4(L10, C5, C3, C2);" << endl; exp[10] = false;
00280 pg << "CALL 'strLikeA4(L11, C0, C3, C2);" << endl; exp[11] = true;
00281 pg << "CALL 'strLikeA4(L12, C5, C4, C2);" << endl; exp[12] = false;
00282 pg << "CALL 'strLikeA4(L13, C0, C4, C2);" << endl; exp[13] = false;
00283 pg << "CALL 'strLikeA4(L14, C1, C4, C2);" << endl; exp[14] = true;
00284 int validoutputs = 15;
00285
00286
00287 pg << "CALL 'strLikeA3(L15, C10, C1);" << endl;
00288 pg << "CALL 'strLikeA3(L16, C5, C10);" << endl;
00289
00290
00291 pg << "CALL 'strLikeA4(L17, C10, C1, C2);" << endl;
00292 pg << "CALL 'strLikeA4(L18, C5, C10, C2);" << endl;
00293 pg << "CALL 'strLikeA4(L19, C5, C1, C10);" << endl;
00294 int nulloutputs = 20;
00295
00296
00297
00298 pg << "CALL 'strLikeA4(L20, C5, C1, C4);" << endl;
00299
00300 pg << "CALL 'strLikeA4(L21, C5, C1, C9);" << endl;
00301
00302 pg << "CALL 'strLikeA4(L22, C5, C2, C2);" << endl;
00303
00304
00305 refLocalOutput(pg, outputs);
00306
00307 Calculator calc(0);
00308
00309 try {
00310 calc.assemble(pg.str().c_str());
00311 } catch (FennelExcn& ex) {
00312 BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00313 BOOST_MESSAGE(pg.str());
00314 BOOST_FAIL("assembler error");
00315 }
00316
00317 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00318 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00319
00320 calc.bind(&inTuple, &outTuple);
00321 calc.exec();
00322 printOutput(outTuple, calc);
00323
00324 likeHelper(
00325 outTuple, exp, validoutputs, nulloutputs,
00326 calc.mWarnings);
00327
00328
00329
00330
00331 calc.exec();
00332 likeHelper(
00333 outTuple, exp, validoutputs, nulloutputs,
00334 calc.mWarnings);
00335 }
00336
00337 void
00338 CalcExtRegExpTest::testCalcExtRegExpLikeAChar()
00339 {
00340 ostringstream pg("");
00341
00342 pg << "O bo, bo, bo, bo, bo, bo, bo, bo;" << endl;
00343 pg << "L bo, bo, bo, bo, bo, bo, bo, bo;" << endl;
00344 pg << "C c,1, c,2, c,1, vc,1, vc,2, vc,1;" << endl;
00345 pg << "V 0x" << stringToHex("%");
00346 pg << ", 0x" << stringToHex("ab");
00347 pg << ", 0x" << stringToHex("=");
00348 pg << ", 0x" << stringToHex("%");
00349 pg << ", 0x" << stringToHex("ab");
00350 pg << ", 0x" << stringToHex("=");
00351 pg << ";" << endl;
00352 pg << "T;" << endl;
00353
00354
00355 pg << "CALL 'strLikeA4(L0, C1, C0, C2);" << endl;
00356 pg << "CALL 'strLikeA4(L1, C0, C1, C2);" << endl;
00357
00358
00359 pg << "CALL 'strLikeA3(L2, C1, C0);" << endl;
00360 pg << "CALL 'strLikeA3(L3, C0, C1);" << endl;
00361
00362
00363 pg << "CALL 'strLikeA4(L4, C1, C3, C2);" << endl;
00364 pg << "CALL 'strLikeA4(L5, C4, C0, C2);" << endl;
00365
00366
00367 pg << "CALL 'strLikeA3(L6, C1, C3);" << endl;
00368 pg << "CALL 'strLikeA3(L7, C4, C0);" << endl;
00369
00370 refLocalOutput(pg, 8);
00371
00372 Calculator calc(0);
00373
00374 try {
00375 calc.assemble(pg.str().c_str());
00376 } catch (FennelExcn& ex) {
00377 BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00378 BOOST_MESSAGE(pg.str());
00379 BOOST_FAIL("assembler error");
00380 }
00381
00382 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00383 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00384
00385 calc.bind(&inTuple, &outTuple);
00386 calc.exec();
00387 printOutput(outTuple, calc);
00388
00389 int i;
00390 BOOST_CHECK(calc.mWarnings.begin() == calc.mWarnings.end());
00391 for (i = 0; i < 8; i++) {
00392 if (i == 1 || i == 3) {
00393 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], false));
00394 } else {
00395 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], true));
00396 }
00397 }
00398
00399
00400
00401 calc.exec();
00402 BOOST_CHECK(calc.mWarnings.begin() == calc.mWarnings.end());
00403 for (i = 0; i < 8; i++) {
00404 if (i == 1 || i == 3) {
00405 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], false));
00406 } else {
00407 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], true));
00408 }
00409 }
00410 }
00411
00412 void
00413 CalcExtRegExpTest::similarHelper(
00414 TupleDataWithBuffer const & outTuple,
00415 bool const * exp,
00416 int validoutputs,
00417 int nulloutputs,
00418 deque<CalcMessage> dq)
00419 {
00420 int i;
00421 deque<CalcMessage>::iterator iter = dq.begin();
00422 deque<CalcMessage>::iterator end = dq.end();
00423
00424 for (i = 0; i < validoutputs; i++) {
00425 if (cmpTupBool(outTuple[i], exp[i])) {
00426 BOOST_MESSAGE("error on valid output [" << i << "]");
00427 }
00428 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], exp[i]));
00429 }
00430
00431 for (i = validoutputs; i < nulloutputs; i++) {
00432 if (!cmpTupNull(outTuple[i])) {
00433 BOOST_MESSAGE("error on null output [" << i << "]");
00434 }
00435 BOOST_CHECK_EQUAL(1, cmpTupNull(outTuple[i]));
00436 }
00437 int exceptionPc = nulloutputs;
00438
00439 BOOST_CHECK(iter != end);
00440 BOOST_CHECK_EQUAL(iter->pc, exceptionPc++);
00441 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "2200B"));
00442 iter++;
00443 BOOST_CHECK(iter != end);
00444
00445 BOOST_CHECK_EQUAL(iter->pc, exceptionPc++);
00446 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "22019"));
00447 iter++;
00448 BOOST_CHECK(iter != end);
00449
00450 BOOST_CHECK_EQUAL(iter->pc, exceptionPc++);
00451 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "22019"));
00452 iter++;
00453 BOOST_CHECK(iter != end);
00454
00455 BOOST_CHECK_EQUAL(iter->pc, exceptionPc++);
00456 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "2201B"));
00457 iter++;
00458 BOOST_CHECK(iter != end);
00459
00460 BOOST_CHECK_EQUAL(iter->pc, exceptionPc++);
00461 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "2200C"));
00462 iter++;
00463
00464 BOOST_CHECK_EQUAL(iter->pc, exceptionPc++);
00465 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "2201B"));
00466 iter++;
00467 BOOST_CHECK(iter == end);
00468 }
00469
00470
00471 void
00472 CalcExtRegExpTest::testCalcExtRegExpSimilarAVarChar()
00473 {
00474 ostringstream pg(""), outloc(""), constants("");
00475 int i;
00476 int outputs = 26;
00477
00478 bool exp[40];
00479 BOOST_REQUIRE((sizeof(exp) / sizeof(bool)) >= outputs);
00480
00481 for (i = 0; i < outputs - 1; i++) {
00482 outloc << "bo, ";
00483 }
00484 outloc << "bo;" << endl;
00485
00486
00487 for (i = 0; i <= 14; i++) {
00488 constants << "vc,20, ";
00489 }
00490 constants << "vc,20;" << endl;
00491
00492 pg << "O " << outloc.str();
00493 pg << "L " << outloc.str();
00494 pg << "C " << constants.str();
00495 pg << "V 0x" << stringToHex("_");
00496 pg << ", 0x" << stringToHex("%");
00497 pg << ", 0x" << stringToHex("=");
00498 pg << ", 0x" << stringToHex("=_");
00499 pg << ", 0x" << stringToHex("=%");
00500 pg << ", 0x" << stringToHex("ab");
00501 pg << ", 0x" << stringToHex("ba");
00502 pg << ", 0x" << stringToHex("a%");
00503 pg << ", 0x" << stringToHex("a_");
00504 pg << ", 0x" << stringToHex("");
00505 pg << ", 0x" << stringToHex(":");
00506 pg << ", 0x" << stringToHex("[[:ALPHA:]]");
00507 pg << ", 0x" << stringToHex("=a");
00508 pg << ", 0x" << stringToHex("%a");
00509 pg << ", 0x" << stringToHex("{}");
00510 pg << ",;" << endl;
00511 pg << "T;" << endl;
00512
00513
00514
00515
00516
00517
00518 pg << "CALL 'strSimilarA3(L0, C5, C1);" << endl; exp[0] = true;
00519 pg << "CALL 'strSimilarA3(L1, C5, C0);" << endl; exp[1] = false;
00520 pg << "CALL 'strSimilarA3(L2, C5, C7);" << endl; exp[2] = true;
00521 pg << "CALL 'strSimilarA3(L3, C6, C7);" << endl; exp[3] = false;
00522 pg << "CALL 'strSimilarA3(L4, C5, C8);" << endl; exp[4] = true;
00523 pg << "CALL 'strSimilarA3(L5, C6, C8);" << endl; exp[5] = false;
00524 pg << "CALL 'strSimilarA3(L6, C0, C0);" << endl; exp[6] = true;
00525 pg << "CALL 'strSimilarA3(L7, C0, C1);" << endl; exp[7] = true;
00526
00527
00528 pg << "CALL 'strSimilarA4(L8, C5, C0, C2);" << endl; exp[8] = false;
00529 pg << "CALL 'strSimilarA4(L9, C5, C1, C2);" << endl; exp[9] = true;
00530 pg << "CALL 'strSimilarA4(L10, C5, C3, C2);" << endl; exp[10] = false;
00531 pg << "CALL 'strSimilarA4(L11, C0, C3, C2);" << endl; exp[11] = true;
00532 pg << "CALL 'strSimilarA4(L12, C5, C4, C2);" << endl; exp[12] = false;
00533 pg << "CALL 'strSimilarA4(L13, C0, C4, C2);" << endl; exp[13] = false;
00534 pg << "CALL 'strSimilarA4(L14, C1, C4, C2);" << endl; exp[14] = true;
00535 int validoutputs = 15;
00536
00537
00538 pg << "CALL 'strSimilarA3(L15, C15, C1);" << endl;
00539 pg << "CALL 'strSimilarA3(L16, C5, C15);" << endl;
00540
00541 pg << "CALL 'strSimilarA4(L17, C15, C1, C9);" << endl;
00542 pg << "CALL 'strSimilarA4(L18, C5, C15, C9);" << endl;
00543 pg << "CALL 'strSimilarA4(L19, C5, C1, C15);" << endl;
00544 int nulloutputs = 20;
00545
00546
00547
00548 pg << "CALL 'strSimilarA4(L20, C5, C11, C10);" << endl;
00549
00550 pg << "CALL 'strSimilarA4(L21, C5, C1, C4);" << endl;
00551
00552 pg << "CALL 'strSimilarA4(L22, C5, C1, C9);" << endl;
00553
00554 pg << "CALL 'strSimilarA4(L23, C5, C2, C2);" << endl;
00555
00556 pg << "CALL 'strSimilarA4(L24, C5, C13, C1);" << endl;
00557
00558 pg << "CALL 'strSimilarA4(L25, C5, C14, C1);" << endl;
00559
00560
00561 refLocalOutput(pg, outputs);
00562
00563 Calculator calc(0);
00564
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_FAIL("assembler error");
00571 }
00572
00573 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00574 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00575
00576 calc.bind(&inTuple, &outTuple);
00577 calc.exec();
00578 printOutput(outTuple, calc);
00579
00580 similarHelper(
00581 outTuple, exp, validoutputs, nulloutputs,
00582 calc.mWarnings);
00583
00584
00585
00586
00587 calc.exec();
00588 similarHelper(
00589 outTuple, exp, validoutputs, nulloutputs,
00590 calc.mWarnings);
00591 }
00592
00593 void
00594 CalcExtRegExpTest::testCalcExtRegExpSimilarAChar()
00595 {
00596 ostringstream pg("");
00597
00598 pg << "O bo, bo, bo, bo, bo, bo, bo, bo;" << endl;
00599 pg << "L bo, bo, bo, bo, bo, bo, bo, bo;" << endl;
00600 pg << "C c,1, c,2, c,1, vc,1, vc,2, vc,1 ;" << endl;
00601 pg << "V 0x" << stringToHex("%");
00602 pg << ", 0x" << stringToHex("ab");
00603 pg << ", 0x" << stringToHex("=");
00604 pg << ", 0x" << stringToHex("%");
00605 pg << ", 0x" << stringToHex("ab");
00606 pg << ", 0x" << stringToHex("=");
00607 pg << ";" << endl;
00608 pg << "T;" << endl;
00609
00610
00611 pg << "CALL 'strSimilarA4(L0, C1, C0, C2);" << endl;
00612 pg << "CALL 'strSimilarA4(L1, C0, C1, C2);" << endl;
00613
00614
00615 pg << "CALL 'strSimilarA3(L2, C1, C0);" << endl;
00616 pg << "CALL 'strSimilarA3(L3, C0, C1);" << endl;
00617
00618
00619 pg << "CALL 'strSimilarA4(L4, C1, C3, C2);" << endl;
00620 pg << "CALL 'strSimilarA4(L5, C4, C0, C2);" << endl;
00621
00622
00623 pg << "CALL 'strSimilarA3(L6, C1, C3);" << endl;
00624 pg << "CALL 'strSimilarA3(L7, C4, C0);" << endl;
00625
00626 refLocalOutput(pg, 8);
00627
00628 Calculator calc(0);
00629
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_FAIL("assembler error");
00636 }
00637
00638 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00639 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00640
00641 calc.bind(&inTuple, &outTuple);
00642 calc.exec();
00643 printOutput(outTuple, calc);
00644
00645 int i;
00646 BOOST_CHECK(calc.mWarnings.begin() == calc.mWarnings.end());
00647 for (i = 0; i < 8; i++) {
00648 if (i == 1 || i == 3) {
00649 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], false));
00650 } else {
00651 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], true));
00652 }
00653 }
00654
00655
00656
00657 calc.exec();
00658 BOOST_CHECK(calc.mWarnings.begin() == calc.mWarnings.end());
00659 for (i = 0; i < 8; i++) {
00660 if (i == 1 || i == 3) {
00661 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], false));
00662 } else {
00663 BOOST_CHECK_EQUAL(0, cmpTupBool(outTuple[i], true));
00664 }
00665 }
00666 }
00667
00668
00669 FENNEL_UNIT_TEST_SUITE(CalcExtRegExpTest);
00670
00671