diff options
Diffstat (limited to 'tools/qa/cppunit/test_stream.cxx')
-rw-r--r-- | tools/qa/cppunit/test_stream.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx index dc80c7d5c02a..77c2b9ed75ae 100644 --- a/tools/qa/cppunit/test_stream.cxx +++ b/tools/qa/cppunit/test_stream.cxx @@ -46,10 +46,12 @@ namespace public: void test_stdstream(); void test_fastostring(); + void test_read_cstring(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(test_stdstream); CPPUNIT_TEST(test_fastostring); + CPPUNIT_TEST(test_read_cstring); CPPUNIT_TEST_SUITE_END(); }; @@ -146,6 +148,25 @@ namespace CPPUNIT_ASSERT(aFour.equalsL(RTL_CONSTASCII_STRINGPARAM(foo))); } + void Test::test_read_cstring() + { + char foo[] = "foobar"; + SvMemoryStream aMemStream(RTL_CONSTASCII_STRINGPARAM(foo), STREAM_READ); + + rtl::OString aOne = read_zeroTerminated_uInt8s_AsOString(aMemStream); + CPPUNIT_ASSERT(aOne.equalsL(RTL_CONSTASCII_STRINGPARAM("foobar"))); + CPPUNIT_ASSERT(!aMemStream.good()); + CPPUNIT_ASSERT(!aMemStream.bad()); + CPPUNIT_ASSERT(aMemStream.eof()); + + aMemStream.Seek(0); + foo[3] = 0; + rtl::OString aTwo = read_zeroTerminated_uInt8s_AsOString(aMemStream); + CPPUNIT_ASSERT(aTwo.equalsL(RTL_CONSTASCII_STRINGPARAM("foo"))); + CPPUNIT_ASSERT(aMemStream.good()); + } + + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |