void BlockFileInputStreamTestCase::testSeekAndRead()
{
    OutputStreamPtr pOutput = m_pBlockFileSystem->createFile("testfile1");

    size_t dataSize = 10000;
    stringstream content;
    for (size_t i = 0; i < dataSize; ++i)
    {
        content << (i % 10);
    }
    pOutput->write((const void*)content.str().c_str(), content.str().size());
    pOutput.reset();

    InputStreamPtr pInput = m_pBlockFileSystem->openFile("testfile1");
    CPPUNIT_ASSERT(pInput != NULL);   

    CPPUNIT_ASSERT_EQUAL(dataSize, (size_t)pInput->getSize());   

    for (size_t i = 0; i < dataSize - 1; ++i)
    {
        string readCont;
        readCont.resize(dataSize - i);
        if (i % 147 == 0)
        {
            pInput->seek(i % 789);
        }
        pInput->seekAndRead(i, (void*)readCont.c_str(), dataSize - i);

        string expStr = content.str().substr(i);
//        assert(expStr == readCont);
        CPPUNIT_ASSERT_EQUAL(expStr, readCont);
    }
    pInput.reset();
}
void BlockFileInputStreamTestCase::testSeekInBuffer()
{
    OutputStreamPtr pOutput = m_pBlockFileSystem->createFile("testfile1");

    size_t dataSize = 10000;
    stringstream content;
    for (size_t i = 0; i < dataSize; ++i)
    {
        content << (i % 10);
    }
    pOutput->write((const void*)content.str().c_str(), content.str().size());
    pOutput.reset();

    InputStreamPtr pInput = m_pBlockFileSystem->openFile("testfile1");
    CPPUNIT_ASSERT(pInput != NULL);   

    CPPUNIT_ASSERT_EQUAL(dataSize, (size_t)pInput->getSize());   
    off_t off = 100;
    string readCont;
    readCont.resize((size_t)off);
    pInput->read((void*)readCont.c_str(), (size_t)off);
    pInput->seek(off);

    size_t readSize = 1000;
    readCont.resize(readSize);
    pInput->read((void*)readCont.c_str(), readSize);
    
    string expStr = content.str().substr((size_t)off, readSize);
    CPPUNIT_ASSERT_EQUAL(expStr, readCont);

    pInput.reset();
}