summaryrefslogtreecommitdiff
path: root/oox/qa
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-08-15 02:24:34 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-10 02:12:38 +0200
commit6917cd98ca6b6fd2d495d0257c7fe50611982d34 (patch)
treebadcf3349ba09ff64841591f83dd53c9a4da4a2c /oox/qa
parentc465695b7e18b38ab99f202fab169fa1bdf930f8 (diff)
add one more test for vba compression
Change-Id: Iba6b4e7b5d26ac7943f72e2a5b3d5d2dc4fc95fd
Diffstat (limited to 'oox/qa')
-rw-r--r--oox/qa/unit/data/vba/reference/simple2.binbin0 -> 32 bytes
-rw-r--r--oox/qa/unit/data/vba/simple2.bin1
-rw-r--r--oox/qa/unit/vba_compression.cxx63
3 files changed, 52 insertions, 12 deletions
diff --git a/oox/qa/unit/data/vba/reference/simple2.bin b/oox/qa/unit/data/vba/reference/simple2.bin
new file mode 100644
index 000000000000..89f448a9acaa
--- /dev/null
+++ b/oox/qa/unit/data/vba/reference/simple2.bin
Binary files differ
diff --git a/oox/qa/unit/data/vba/simple2.bin b/oox/qa/unit/data/vba/simple2.bin
new file mode 100644
index 000000000000..9843ad2c731f
--- /dev/null
+++ b/oox/qa/unit/data/vba/simple2.bin
@@ -0,0 +1 @@
+0000000: 0001 0203 0000 0000 0405 .
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
index b526a3c1e073..6a7133187d7e 100644
--- a/oox/qa/unit/vba_compression.cxx
+++ b/oox/qa/unit/vba_compression.cxx
@@ -19,40 +19,79 @@ class TestVbaCompression : public test::BootstrapFixtureBase
{
public:
+ // just a sequence of bytes that should not be compressed at all
void testSimple1();
+ // a sequence containing one subsequence that can be compressed
+ void testSimple2();
+
// avoid the BootstrapFixtureBase::setUp and tearDown
virtual void setUp() SAL_OVERRIDE;
virtual void tearDown() SAL_OVERRIDE;
CPPUNIT_TEST_SUITE(TestVbaCompression);
CPPUNIT_TEST(testSimple1);
+ CPPUNIT_TEST(testSimple2);
CPPUNIT_TEST_SUITE_END();
private:
};
-void TestVbaCompression::testSimple1()
-{
- OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple1.bin");
- OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple1.bin");
+namespace {
- SvFileStream aInputStream(aTestFile, StreamMode::READ);
+void ReadFiles(const OUString& rTestFile, const OUString& rReference,
+ SvMemoryStream& rOutputMemoryStream, SvMemoryStream& rReferenceMemoryStream,
+ const OUString& rDebugPath)
+{
+ SvFileStream aInputStream(rTestFile, StreamMode::READ);
SvMemoryStream aInputMemoryStream(4096, 4096);
aInputMemoryStream.WriteStream(aInputStream);
- SvMemoryStream aOutputMemoryStream(4096, 4096);
- VBACompression aCompression(aOutputMemoryStream, aInputMemoryStream);
+ VBACompression aCompression(rOutputMemoryStream, aInputMemoryStream);
aCompression.write();
- SvFileStream aReferenceStream(aReference, StreamMode::READ);
+ SvFileStream aReferenceStream(rReference, StreamMode::READ);
+ rReferenceMemoryStream.WriteStream(aReferenceStream);
+
+ rOutputMemoryStream.Seek(0);
+ SvFileStream aDebugStream(rDebugPath, StreamMode::WRITE);
+ aDebugStream.WriteStream(rOutputMemoryStream);
+}
+
+}
+
+void TestVbaCompression::testSimple1()
+{
+ OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple1.bin");
+ OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple1.bin");
+
+ SvMemoryStream aOutputMemoryStream(4096, 4096);
SvMemoryStream aReferenceMemoryStream(4096, 4096);
- aReferenceMemoryStream.WriteStream(aReferenceStream);
+ ReadFiles(aTestFile, aReference, aOutputMemoryStream,
+ aReferenceMemoryStream, "/tmp/vba_debug.bin");
+
+ // CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
- aOutputMemoryStream.Seek(0);
- SvFileStream aDebugStream("/tmp/vba_debug.bin", StreamMode::WRITE);
- aDebugStream.WriteStream(aOutputMemoryStream);
+ const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+ const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
+ size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+ aOutputMemoryStream.GetSize());
+ for (size_t i = 0; i < nSize; ++i)
+ {
+ CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+ }
+}
+
+void TestVbaCompression::testSimple2()
+{
+ OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple2.bin");
+ OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple2.bin");
+
+ SvMemoryStream aOutputMemoryStream(4096, 4096);
+ SvMemoryStream aReferenceMemoryStream(4096, 4096);
+ ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug2.bin");
+ //
// CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();