From dcf947534778520bad32167f181b42ef6a451531 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 30 Dec 2014 17:38:12 +0000 Subject: fdo#84229 - add sot storage unit test. Change-Id: Ic11c397984602bf8a2e292bc901cd7bf71ad555d --- sot/qa/cppunit/data/pass/fdo84229-1.compound | Bin 0 -> 14848 bytes sot/qa/cppunit/test_sot.cxx | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 sot/qa/cppunit/data/pass/fdo84229-1.compound (limited to 'sot/qa') diff --git a/sot/qa/cppunit/data/pass/fdo84229-1.compound b/sot/qa/cppunit/data/pass/fdo84229-1.compound new file mode 100644 index 000000000000..46eb4da8fddb Binary files /dev/null and b/sot/qa/cppunit/data/pass/fdo84229-1.compound differ diff --git a/sot/qa/cppunit/test_sot.cxx b/sot/qa/cppunit/test_sot.cxx index c97a86e0b812..92ade70a11a4 100644 --- a/sot/qa/cppunit/test_sot.cxx +++ b/sot/qa/cppunit/test_sot.cxx @@ -36,9 +36,11 @@ namespace unsigned int, unsigned int, unsigned int) SAL_OVERRIDE; void test(); + void testSize(); CPPUNIT_TEST_SUITE(SotTest); CPPUNIT_TEST(test); + CPPUNIT_TEST(testSize); CPPUNIT_TEST_SUITE_END(); }; @@ -120,6 +122,30 @@ namespace OUString()); } + void SotTest::testSize() + { + OUString aURL(getURLFromSrc("/sot/qa/cppunit/data/pass/fdo84229-1.compound")); + SvFileStream aStream(aURL, STREAM_READ); + SotStorageRef xObjStor = new SotStorage(aStream); + CPPUNIT_ASSERT_MESSAGE("sot storage failed to open", + xObjStor.Is() && !xObjStor->GetError()); + SotStorageStreamRef xStream = xObjStor->OpenSotStream("Book"); + CPPUNIT_ASSERT_MESSAGE("stream failed to open", + xStream.Is() && !xObjStor->GetError()); + CPPUNIT_ASSERT_MESSAGE("error in opened stream", !xStream->GetError()); + sal_uLong nPos = xStream->GetSize(); + CPPUNIT_ASSERT_MESSAGE("odd stream length", nPos == 13312); + + xStream->Seek(STREAM_SEEK_TO_END); + CPPUNIT_ASSERT_MESSAGE("error seeking to end", !xStream->GetError()); + // cf. comment in Pos2Page, not extremely intuitive ... + CPPUNIT_ASSERT_MESSAGE("stream not at beginning", xStream->Tell() == xStream->GetSize()); + xStream->Seek(STREAM_SEEK_TO_BEGIN); + + CPPUNIT_ASSERT_MESSAGE("error seeking to beginning", !xStream->GetError()); + CPPUNIT_ASSERT_MESSAGE("stream not at beginning", xStream->Tell() == 0); + } + CPPUNIT_TEST_SUITE_REGISTRATION(SotTest); } -- cgit