Added test for tellp/tellg issue.

This commit is contained in:
martin-osborne 2014-11-30 10:25:51 +00:00
parent bf6234d7b5
commit 627eee72cb
2 changed files with 28 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include "MemoryStreamTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/Buffer.h"
#include "Poco/MemoryStream.h"
@ -87,6 +88,31 @@ void MemoryStreamTest::testOutput()
}
void MemoryStreamTest::testTell()
{
Poco::Buffer<char> buffer(1024);
Poco::MemoryOutputStream ostr(buffer.begin(), buffer.size());
ostr << 'H' << 'e' << 'l' << 'l' << 'o' << '\0';
std::streamoff np = ostr.tellp();
assert (np == 6);
Poco::MemoryInputStream istr(buffer.begin(), buffer.size());
char c;
istr >> c;
assert (c == 'H');
istr >> c;
assert (c == 'e');
istr >> c;
assert (c == 'l');
std::streamoff ng = istr.tellg();
assert (ng == 3);
}
void MemoryStreamTest::setUp()
{
}
@ -103,6 +129,7 @@ CppUnit::Test* MemoryStreamTest::suite()
CppUnit_addTest(pSuite, MemoryStreamTest, testInput);
CppUnit_addTest(pSuite, MemoryStreamTest, testOutput);
CppUnit_addTest(pSuite, MemoryStreamTest, testTell);
return pSuite;
}

View File

@ -28,6 +28,7 @@ public:
void testInput();
void testOutput();
void testTell();
void setUp();
void tearDown();