summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorArtur Dorda <artur.dorda+libo@gmail.com>2012-08-10 16:55:19 +0200
committerArtur Dorda <artur.dorda+libo@gmail.com>2012-08-15 13:42:19 +0200
commit57cac07a4dc2f447e1ed907dda077b37f015acec (patch)
tree9be6afba2f36f3b6d14d5f49b5ace13538e150dd /sax
parent9f2a303b9975a7d257990ecefb36cf9e80c02747 (diff)
encodeBase64 test is working
Change-Id: I598ea47ff02b15fdb1d7ff3992d2c660f5a41c95
Diffstat (limited to 'sax')
-rw-r--r--sax/CppunitTest_sax.mk2
-rw-r--r--sax/qa/cppunit/test_converter.cxx32
2 files changed, 34 insertions, 0 deletions
diff --git a/sax/CppunitTest_sax.mk b/sax/CppunitTest_sax.mk
index 493cb7679645..fd8fb5e9fd45 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 c799f452f6a6..428027ba7c24 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);
}