oox/qa/unit/data/vba/reference/spec322.bin |binary oox/qa/unit/data/vba/reference/spec323.bin |binary oox/qa/unit/data/vba/spec322.bin | 1 oox/qa/unit/data/vba/spec323.bin | 1 oox/qa/unit/vba_compression.cxx | 54 +++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+)
New commits: commit c3258eda42cef329f6f067e6d6c4b774687482a3 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Aug 18 03:27:09 2015 +0200 add another test from the VBA spec for the compression code Change-Id: I5368e30bbb383621153c31ae8705cff6df7dad90 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 0000000..7724b62 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 0000000..781c426 --- /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 79d394b..abf2b29 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"); commit e29a9163f4b37b6286d2e03460d9a80024d2c60e Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Aug 18 00:32:00 2015 +0200 add test from the VBA spec for the compression algorithm Change-Id: I41d5aca8940e34b41e2cc70a72b6e076707bfac6 diff --git a/oox/qa/unit/data/vba/reference/spec323.bin b/oox/qa/unit/data/vba/reference/spec323.bin new file mode 100644 index 0000000..51104ee Binary files /dev/null and b/oox/qa/unit/data/vba/reference/spec323.bin differ diff --git a/oox/qa/unit/data/vba/spec323.bin b/oox/qa/unit/data/vba/spec323.bin new file mode 100644 index 0000000..9ca58b9 --- /dev/null +++ b/oox/qa/unit/data/vba/spec323.bin @@ -0,0 +1 @@ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ No newline at end of file diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx index 4519700..79d394b 100644 --- a/oox/qa/unit/vba_compression.cxx +++ b/oox/qa/unit/vba_compression.cxx @@ -30,6 +30,12 @@ public: // real stream from a document void testComplex1(); + // tests taken from the VBA specification + // section 3.2 + + // section 3.2.3 + void testSpec323(); + // avoid the BootstrapFixtureBase::setUp and tearDown virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; @@ -39,6 +45,7 @@ public: CPPUNIT_TEST(testSimple2); CPPUNIT_TEST(testSimple3); CPPUNIT_TEST(testComplex1); + CPPUNIT_TEST(testSpec323); CPPUNIT_TEST_SUITE_END(); private: @@ -156,6 +163,28 @@ void TestVbaCompression::testComplex1() } } +void TestVbaCompression::testSpec323() +{ + OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec323.bin"); + OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/spec323.bin"); + + SvMemoryStream aOutputMemoryStream(4096, 4096); + SvMemoryStream aReferenceMemoryStream(4096, 4096); + ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_spec321.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::setUp() { } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits