diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-02-23 07:56:09 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-02-23 10:31:23 +0000 |
commit | 55b71dcc18ff1c736c6ec4a3facc46dfb97d744f (patch) | |
tree | c05eeed5059c423fe56bb85271a3f2def16194da /tools | |
parent | 416010c7d302874821a0a8db1a5e77f3d3cb51c5 (diff) |
convert workben inetmimetest to cppunit test
Diffstat (limited to 'tools')
-rw-r--r-- | tools/CppunitTest_tools_test.mk | 1 | ||||
-rw-r--r-- | tools/qa/cppunit/inetmimetest.cxx (renamed from tools/workben/inetmimetest.cxx) | 55 |
2 files changed, 31 insertions, 25 deletions
diff --git a/tools/CppunitTest_tools_test.mk b/tools/CppunitTest_tools_test.mk index 00c490264205..608c2a4e51ee 100644 --- a/tools/CppunitTest_tools_test.mk +++ b/tools/CppunitTest_tools_test.mk @@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,tools_test)) $(eval $(call gb_CppunitTest_add_exception_objects,tools_test, \ + tools/qa/cppunit/inetmimetest \ tools/qa/cppunit/test_reversemap \ tools/qa/cppunit/test_pathutils \ tools/qa/cppunit/test_stream \ diff --git a/tools/workben/inetmimetest.cxx b/tools/qa/cppunit/inetmimetest.cxx index 333cc83ebafd..4fd6e2b0c84e 100644 --- a/tools/workben/inetmimetest.cxx +++ b/tools/qa/cppunit/inetmimetest.cxx @@ -26,39 +26,44 @@ * ************************************************************************/ +#include "sal/config.h" +#include "sal/precppunit.hxx" + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" #include <tools/inetmime.hxx> -#include "rtl/textenc.h" -#include "rtl/ustring.hxx" +namespace +{ -#include <cstdlib> -#include <iostream> + class Test: public CppUnit::TestFixture + { + bool testDecode(char const * input, char const * expected); + public: + void test_decodeHeaderFieldBody(); -namespace { + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(test_decodeHeaderFieldBody); + CPPUNIT_TEST_SUITE_END(); + }; -bool testDecode(char const * input, char const * expected) { - rtl::OUString result = INetMIME::decodeHeaderFieldBody( - INetMIME::HEADER_FIELD_TEXT, input); - bool success = result.equalsAscii(expected); - if (!success) { - std::cout - << "FAILED: decodeHeaderFieldBody(\"" << input << "\"): \"" - << rtl::OUStringToOString( - result, RTL_TEXTENCODING_ASCII_US).getStr() - << "\" != \"" << expected << "\"\n"; + bool Test::testDecode(char const * input, char const * expected) + { + rtl::OUString result = INetMIME::decodeHeaderFieldBody( + INetMIME::HEADER_FIELD_TEXT, input); + return result.equalsAscii(expected); } - return success; -} -} + void Test::test_decodeHeaderFieldBody() + { + CPPUNIT_ASSERT(testDecode("=?iso-8859-1?B?QQ==?=", "A")); + CPPUNIT_ASSERT(testDecode("=?iso-8859-1?B?QUI=?=", "AB")); + CPPUNIT_ASSERT(testDecode("=?iso-8859-1?B?QUJD?=", "ABC")); + } -int SAL_CALL main() { - bool success = true; - success &= testDecode("=?iso-8859-1?B?QQ==?=", "A"); - success &= testDecode("=?iso-8859-1?B?QUI=?=", "AB"); - success &= testDecode("=?iso-8859-1?B?QUJD?=", "ABC"); - return success ? EXIT_SUCCESS : EXIT_FAILURE; + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |