LbmReaderTest.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/lucidera/test/LbmReaderTest.cpp#4 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 LucidEra, Inc.
00005 // Copyright (C) 2005-2009 The Eigenbase Project
00006 //
00007 // This program is free software; you can redistribute it and/or modify it
00008 // under the terms of the GNU General Public License as published by the Free
00009 // Software Foundation; either version 2 of the License, or (at your option)
00010 // any later version approved by The Eigenbase Project.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 */
00021 
00022 #include "fennel/common/CommonPreamble.h"
00023 #include "fennel/lucidera/bitmap/LbmRidReader.h"
00024 #include "fennel/lucidera/bitmap/LbmTupleReader.h"
00025 #include "fennel/lucidera/test/LbmExecStreamTestBase.h"
00026 
00027 #include <boost/test/test_tools.hpp>
00028 
00029 using namespace fennel;
00030 
00034 class LbmReaderTest : public LbmExecStreamTestBase
00035 {
00036 public:
00037     explicit LbmReaderTest()
00038     {
00039         FENNEL_UNIT_TEST_CASE(LbmReaderTest, testSingleTupleReader);
00040     }
00041 
00042     void testSingleTupleReader();
00043 };
00044 
00045 void LbmReaderTest::testSingleTupleReader()
00046 {
00047     LcsRid rid = LcsRid(123);
00048     bitmapTupleData[0].pData = (PConstBuffer) &rid;
00049 
00050     LbmSingleTupleReader tupleReader;
00051     tupleReader.init(bitmapTupleData);
00052 
00053     uint nRows = 0;
00054     while (true) {
00055         TupleData *pTuple;
00056         ExecStreamResult rc = tupleReader.read(pTuple);
00057         if (rc == EXECRC_EOS) {
00058             break;
00059         }
00060         BOOST_CHECK_EQUAL(rc, EXECRC_YIELD);
00061         int cmp = bitmapTupleDesc.compareTuples(bitmapTupleData, *pTuple);
00062         BOOST_CHECK_EQUAL(cmp, 0);
00063         nRows++;
00064     }
00065     BOOST_CHECK_EQUAL(nRows, 1);
00066 
00067     LbmTupleRidReader ridReader;
00068     ridReader.init(bitmapTupleData);
00069     BOOST_CHECK_EQUAL(ridReader.hasNext(), true);
00070     BOOST_CHECK_EQUAL(ridReader.peek(), LcsRid(123));
00071     ridReader.advance();
00072     BOOST_CHECK_EQUAL(ridReader.hasNext(), false);
00073 
00074     ridReader.init(bitmapTupleData);
00075     BOOST_CHECK_EQUAL(ridReader.hasNext(), true);
00076     BOOST_CHECK_EQUAL(ridReader.getNext(), LcsRid(123));
00077     BOOST_CHECK_EQUAL(ridReader.hasNext(), false);
00078 }
00079 
00080 FENNEL_UNIT_TEST_SUITE(LbmReaderTest);
00081 
00082 // End LbmReaderTest.cpp

Generated on Mon Jun 22 04:00:20 2009 for Fennel by  doxygen 1.5.1