sax/CppunitTest_sax.mk | 2 + sax/qa/cppunit/test_converter.cxx | 70 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+)
New commits: commit 00d88714e3b85b71c2b29e836244482acc68f8bd Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 16:55:19 2012 +0200 encodeBase64 test is working Change-Id: I598ea47ff02b15fdb1d7ff3992d2c660f5a41c95 diff --git a/sax/CppunitTest_sax.mk b/sax/CppunitTest_sax.mk index 493cb76..fd8fb5e 100644 --- a/sax/CppunitTest_sax.mk +++ b/sax/CppunitTest_sax.mk @@ -17,6 +17,8 @@ $(eval $(call gb_CppunitTest_use_api,sax_cpputest,\ $(eval $(call gb_CppunitTest_use_libraries,sax_cpputest, \ sax \ sal \ + comphelper \ + cppu \ $(gb_STDLIBS) \ )) diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index c799f45..428027b 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/util/MeasureUnit.hpp> #include "sax/tools/converter.hxx" +#include "comphelper/sequenceasvector.hxx" using namespace ::com::sun::star; @@ -55,6 +56,7 @@ public: void testPercent(); void testColor(); void testNumber(); + void testBase64(); CPPUNIT_TEST_SUITE(ConverterTest); CPPUNIT_TEST(testDuration); @@ -65,6 +67,7 @@ public: CPPUNIT_TEST(testPercent); CPPUNIT_TEST(testColor); CPPUNIT_TEST(testNumber); + CPPUNIT_TEST(testBase64); CPPUNIT_TEST_SUITE_END(); private: @@ -506,6 +509,35 @@ void ConverterTest::testNumber() doTestNumberToString("-1", -0001); doTestNumberToString("0", -0); } + +void doTestEncodeBase64(char const*const pis, const uno::Sequence<sal_Int8> aPass) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + ::rtl::OUStringBuffer buf; + Converter::encodeBase64(buf, aPass); + OSL_TRACE("%s", ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8).getStr()); + CPPUNIT_ASSERT_EQUAL(is, buf.makeStringAndClear()); +} +void ConverterTest::testBase64() +{ + comphelper::SequenceAsVector< sal_Int8 > tempSeq(4); + for(sal_Int8 i = 0; i<4; ++i) + tempSeq.push_back(i); + uno::Sequence< sal_Int8 > tempSequence = tempSeq.getAsConstList(); + doTestEncodeBase64("AAAAAAABAgM=", tempSequence); + tempSeq[0] = sal_Int8(5); + tempSeq[1] = sal_Int8(2); + tempSeq[2] = sal_Int8(3); + tempSequence = tempSeq.getAsConstList(); + doTestEncodeBase64("BQIDAAABAgM=", tempSequence); + tempSeq[0] = sal_Int8(200); + tempSeq[1] = sal_Int8(31); + tempSeq[2] = sal_Int8(77); + tempSeq[3] = sal_Int8(111); + tempSequence = tempSeq.getAsConstList(); + doTestEncodeBase64("yB9NbwABAgM=", tempSequence); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); } commit 4109661388f8919cb3b39a9a8c63e5ca82583cbe Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 15:42:51 2012 +0200 added some extreme values in string-to-measure test Change-Id: I8fd9029f42159444e7bb56f89eeb83fdb3745732 diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index c4fe50e..c799f45 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -363,6 +363,9 @@ void ConverterTest::testMeasure() doTestStringToMeasure(777, "777", MeasureUnit::APPFONT, 10, 4321); doTestStringToMeasure(80000, "80000", MeasureUnit::SYSFONT, 10, 432100); //strange values (negative, too large etc.) + doTestStringToMeasure(555, "666", MeasureUnit::MM, -1000, 555); + doTestStringToMeasure(-1000, "-1001", MeasureUnit::MM, -1000, 555); + doTestStringToMeasure(0, "-0", MeasureUnit::MM, -1, 0); doTestStringToMeasure(-539222987, "1234567890mm", MeasureUnit::MM_10TH, 12, 12345678901); doTestStringToMeasure(-300, "-300", MeasureUnit::MM, -1000, 555); doTestStringToMeasure(1305424328, "-999999999999999px", MeasureUnit::PIXEL, -88888888888, 555); //really crazy numbers... commit 1b32ec1503a77a28ffdcbc4768a0a113bb6d1c21 Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 15:40:05 2012 +0200 'string to number' test covered Change-Id: Ib8a81edce168be5babd1bcd62746199de77c2ade diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index f0df6ad..c4fe50e 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -471,6 +471,16 @@ void ConverterTest::testColor() doTestColorToString("#000000", 0); } +void doTestStringToNumber(sal_Int32 nValue, char const*const pis, sal_Int32 nMin, sal_Int32 nMax) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + sal_Int32 nTemp; + bool bSuccess(Converter::convertNumber(nTemp, is, nMin, nMax)); + OSL_TRACE("%i", nTemp); + CPPUNIT_ASSERT(bSuccess); + CPPUNIT_ASSERT_EQUAL(nValue, nTemp); +} + void doTestNumberToString(char const*const pis, sal_Int32 nValue) { ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); @@ -482,6 +492,11 @@ void doTestNumberToString(char const*const pis, sal_Int32 nValue) void ConverterTest::testNumber() { + doTestStringToNumber(30, "30", 1, 40); + doTestStringToNumber(1, "-5", 1, 300); + doTestStringToNumber(-30, "7", -100, -30); + doTestStringToNumber(0, "-0", 0, 1); + doTestStringToNumber(0, "666", -0, 0); doTestNumberToString("333", 333); doTestNumberToString("-1", -1); doTestNumberToString("0", 0000); commit 297d4613dfae872c3589ea3a84129a9f58d2071e Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 15:12:38 2012 +0200 'number to string' test covered Change-Id: Ic6bdc9448509e6f8251709c22576cc10cf9b8eb2 diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index c3cab68..f0df6ad 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -54,6 +54,7 @@ public: void testBool(); void testPercent(); void testColor(); + void testNumber(); CPPUNIT_TEST_SUITE(ConverterTest); CPPUNIT_TEST(testDuration); @@ -63,6 +64,7 @@ public: CPPUNIT_TEST(testBool); CPPUNIT_TEST(testPercent); CPPUNIT_TEST(testColor); + CPPUNIT_TEST(testNumber); CPPUNIT_TEST_SUITE_END(); private: @@ -468,6 +470,24 @@ void ConverterTest::testColor() doTestColorToString("#fffac7", -1337); doTestColorToString("#000000", 0); } + +void doTestNumberToString(char const*const pis, sal_Int32 nValue) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + ::rtl::OUStringBuffer buf; + Converter::convertNumber(buf, nValue); + OSL_TRACE("%s", ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8).getStr()); + CPPUNIT_ASSERT_EQUAL(is, buf.makeStringAndClear()); +} + +void ConverterTest::testNumber() +{ + doTestNumberToString("333", 333); + doTestNumberToString("-1", -1); + doTestNumberToString("0", 0000); + doTestNumberToString("-1", -0001); + doTestNumberToString("0", -0); +} CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits