summaryrefslogtreecommitdiff
path: root/tools/qa/cppunit
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-09-01 23:55:18 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-09-02 09:54:18 +0100
commit0ee8ec18c4218da4f82c4ff2bf601edca42100be (patch)
tree7bde351118562e0060dcb50e51ed4f9ada3e1c95 /tools/qa/cppunit
parent088e175776fe0fa37c859b68278f5d4304d7ddd6 (diff)
add a way to better construct an OString of len X from a SvStream
Diffstat (limited to 'tools/qa/cppunit')
-rw-r--r--tools/qa/cppunit/test_stream.cxx (renamed from tools/qa/cppunit/test_streamstate.cxx)22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/qa/cppunit/test_streamstate.cxx b/tools/qa/cppunit/test_stream.cxx
index 182ad6c45561..ae098e5b836d 100644
--- a/tools/qa/cppunit/test_streamstate.cxx
+++ b/tools/qa/cppunit/test_stream.cxx
@@ -41,9 +41,11 @@ namespace
{
public:
void test_stdstream();
+ void test_fastostring();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(test_stdstream);
+ CPPUNIT_TEST(test_fastostring);
CPPUNIT_TEST_SUITE_END();
};
@@ -120,6 +122,26 @@ namespace
//failbit is rather subtle wrt e.g seeks
}
+ void Test::test_fastostring()
+ {
+ char foo[] = "foobar";
+ SvMemoryStream aMemStream(RTL_CONSTASCII_STRINGPARAM(foo), STREAM_READ);
+
+ rtl::OString aOne = readBytesAsOString(aMemStream, 3);
+ CPPUNIT_ASSERT(aOne.equalsL(RTL_CONSTASCII_STRINGPARAM("foo")));
+
+ rtl::OString aTwo = readBytesAsOString(aMemStream, 3);
+ CPPUNIT_ASSERT(aTwo.equalsL(RTL_CONSTASCII_STRINGPARAM("bar")));
+
+ rtl::OString aThree = readBytesAsOString(aMemStream, 3);
+ CPPUNIT_ASSERT(!aThree.getLength());
+
+ aMemStream.Seek(0);
+
+ rtl::OString aFour = readBytesAsOString(aMemStream, 100);
+ CPPUNIT_ASSERT(aFour.equalsL(RTL_CONSTASCII_STRINGPARAM(foo)));
+ }
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}