From 33c3c4256c71462350f05d6cdc816d09f550daaf Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 18 Aug 2015 03:27:09 +0200 Subject: add another test from the VBA spec for the compression code Change-Id: I5368e30bbb383621153c31ae8705cff6df7dad90 --- oox/qa/unit/data/vba/reference/spec322.bin | Bin 0 -> 51 bytes oox/qa/unit/data/vba/spec322.bin | 1 + oox/qa/unit/vba_compression.cxx | 25 +++++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 oox/qa/unit/data/vba/reference/spec322.bin create mode 100644 oox/qa/unit/data/vba/spec322.bin (limited to 'oox/qa') diff --git a/oox/qa/unit/data/vba/reference/spec322.bin b/oox/qa/unit/data/vba/reference/spec322.bin new file mode 100644 index 000000000000..7724b62a4452 Binary files /dev/null and b/oox/qa/unit/data/vba/reference/spec322.bin differ diff --git a/oox/qa/unit/data/vba/spec322.bin b/oox/qa/unit/data/vba/spec322.bin new file mode 100644 index 000000000000..781c426c0ae3 --- /dev/null +++ b/oox/qa/unit/data/vba/spec322.bin @@ -0,0 +1 @@ +#aaabcdefaaaaghijaaaaaklaaamnopqaaaaaaaaaaaarstuvwxyzaaa \ No newline at end of file diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx index 79d394ba0f5f..abf2b29ecadd 100644 --- a/oox/qa/unit/vba_compression.cxx +++ b/oox/qa/unit/vba_compression.cxx @@ -33,6 +33,8 @@ public: // tests taken from the VBA specification // section 3.2 + // section 3.2.2 + void testSpec322(); // section 3.2.3 void testSpec323(); @@ -45,6 +47,7 @@ public: CPPUNIT_TEST(testSimple2); CPPUNIT_TEST(testSimple3); CPPUNIT_TEST(testComplex1); + CPPUNIT_TEST(testSpec322); CPPUNIT_TEST(testSpec323); CPPUNIT_TEST_SUITE_END(); @@ -163,6 +166,28 @@ void TestVbaCompression::testComplex1() } } +void TestVbaCompression::testSpec322() +{ + OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec322.bin"); + OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/spec322.bin"); + + SvMemoryStream aOutputMemoryStream(4096, 4096); + SvMemoryStream aReferenceMemoryStream(4096, 4096); + ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_spec322.bin"); + + CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); + + 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::testSpec323() { OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec323.bin"); -- cgit