sax/qa/cppunit/test_converter.cxx | 97 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
New commits: commit 7e639f9332d2e7af8502176ae2915983c2cfb389 Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 15:06:14 2012 +0200 'string to color' test covered Change-Id: I024296d1f71bd06837547cd8af3adc2cf2830b95 diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index 1bf1dd0..c3cab68 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -438,6 +438,16 @@ void ConverterTest::testPercent() doTestPercentToString("1%", 00001); } +void doTestStringToColor(sal_Int32 nValue, char const*const pis) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + sal_Int32 nTemp; + bool bSuccess(Converter::convertColor(nTemp, is)); + OSL_TRACE("%i", nTemp); + CPPUNIT_ASSERT(bSuccess); + CPPUNIT_ASSERT_EQUAL(nValue, nTemp); +} + void doTestColorToString(char const*const pis, sal_Int32 nValue) { ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); @@ -449,6 +459,10 @@ void doTestColorToString(char const*const pis, sal_Int32 nValue) void ConverterTest::testColor() { + doTestStringToColor(11259375, "#abcdef"); + doTestStringToColor(160, "#0000a0"); + doTestStringToColor(40960, "#00a000"); + doTestStringToColor(0, "#000000"); doTestColorToString("#000615", 1557); doTestColorToString("#5bcd15", 123456789); doTestColorToString("#fffac7", -1337); commit 768e16f91851f7c9696c26f2ea0e297ef2fe1f5c Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 14:57:44 2012 +0200 'color to string' test covered Change-Id: Ia65d1bef19ec02efbb5d7dd784d4cc48c3dd51f2 diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index 1efbc94..1bf1dd0 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -53,6 +53,7 @@ public: void testMeasure(); void testBool(); void testPercent(); + void testColor(); CPPUNIT_TEST_SUITE(ConverterTest); CPPUNIT_TEST(testDuration); @@ -61,6 +62,7 @@ public: CPPUNIT_TEST(testMeasure); CPPUNIT_TEST(testBool); CPPUNIT_TEST(testPercent); + CPPUNIT_TEST(testColor); CPPUNIT_TEST_SUITE_END(); private: @@ -435,6 +437,23 @@ void ConverterTest::testPercent() doTestPercentToString("0%", 0); doTestPercentToString("1%", 00001); } + +void doTestColorToString(char const*const pis, sal_Int32 nValue) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + ::rtl::OUStringBuffer buf; + Converter::convertColor(buf, nValue); + OSL_TRACE("%s", ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8).getStr()); + CPPUNIT_ASSERT_EQUAL(is, buf.makeStringAndClear()); +} + +void ConverterTest::testColor() +{ + doTestColorToString("#000615", 1557); + doTestColorToString("#5bcd15", 123456789); + doTestColorToString("#fffac7", -1337); + doTestColorToString("#000000", 0); +} CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); } commit ee3617d926a8d416fec937b206e818c679f0df3d Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 14:48:53 2012 +0200 'percent to string' test covered Change-Id: I6966191a3adde0af318021ce8eec910763c42585 diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index 62e6d5d..1efbc94 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -414,6 +414,15 @@ void doTestStringToPercent(sal_Int32 nValue, char const*const pis) CPPUNIT_ASSERT_EQUAL(nValue, nTemp); } +void doTestPercentToString(char const*const pis, sal_Int32 nValue) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + ::rtl::OUStringBuffer buf; + Converter::convertPercent(buf, nValue); + OSL_TRACE("%s", ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8).getStr()); + CPPUNIT_ASSERT_EQUAL(is, buf.makeStringAndClear()); +} + void ConverterTest::testPercent() { doTestStringToPercent(40, "40%"); @@ -421,6 +430,10 @@ void ConverterTest::testPercent() doTestStringToPercent(120, "120%"); doTestStringToPercent(-40, "-40%"); doTestStringToPercent(0, "0%"); + doTestPercentToString("12%", 12); + doTestPercentToString("-123%", -123); + doTestPercentToString("0%", 0); + doTestPercentToString("1%", 00001); } CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); commit e48d7c56f745ea9aab1869d3ad7da02eea321f74 Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 14:44:48 2012 +0200 'string to percent' test covered Change-Id: Ib18e28cba03c7032e8a446449b2839e7b7534133 diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index b95a65c..62e6d5d 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -52,6 +52,7 @@ public: void testDouble(); void testMeasure(); void testBool(); + void testPercent(); CPPUNIT_TEST_SUITE(ConverterTest); CPPUNIT_TEST(testDuration); @@ -59,6 +60,7 @@ public: CPPUNIT_TEST(testDouble); CPPUNIT_TEST(testMeasure); CPPUNIT_TEST(testBool); + CPPUNIT_TEST(testPercent); CPPUNIT_TEST_SUITE_END(); private: @@ -402,6 +404,24 @@ void ConverterTest::testBool() doTestBoolToString("false", false); } +void doTestStringToPercent(sal_Int32 nValue, char const*const pis) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + sal_Int32 nTemp; + bool bSuccess(Converter::convertPercent(nTemp, is)); + OSL_TRACE("%i", nTemp); + CPPUNIT_ASSERT(bSuccess); + CPPUNIT_ASSERT_EQUAL(nValue, nTemp); +} + +void ConverterTest::testPercent() +{ + doTestStringToPercent(40, "40%"); + doTestStringToPercent(30, "30"); + doTestStringToPercent(120, "120%"); + doTestStringToPercent(-40, "-40%"); + doTestStringToPercent(0, "0%"); +} CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); } commit c81046d88c432bd143face5b73c8b0fc1b83bb4c Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 14:36:24 2012 +0200 'bool to string' test covered Change-Id: I8ee1142b2a68799a650f501e2fe491a5ed8d7a5e diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index d58858a..b95a65c 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -384,11 +384,24 @@ void doTestStringToBool(bool bBool, char const*const pis) CPPUNIT_ASSERT_EQUAL(bBool, bTemp); } + +void doTestBoolToString(char const*const pis, bool bValue ) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + ::rtl::OUStringBuffer buf; + Converter::convertBool(buf, bValue); + OSL_TRACE("%s", ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8).getStr()); + CPPUNIT_ASSERT_EQUAL(is, buf.makeStringAndClear()); +} + void ConverterTest::testBool() { doTestStringToBool(true, "true"); doTestStringToBool(false, "false"); + doTestBoolToString("true", true); + doTestBoolToString("false", false); } + CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); } commit 3026c792c285a689d5c0604bfa40c651922893e3 Author: Artur Dorda <artur.dorda+l...@gmail.com> Date: Fri Aug 10 14:30:07 2012 +0200 'string to bool' test covered Change-Id: I6613167703974d802d17d7fd8cdf0f552721c33c diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index ad146e2..d58858a 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -51,12 +51,14 @@ public: void testDateTime(); void testDouble(); void testMeasure(); + void testBool(); CPPUNIT_TEST_SUITE(ConverterTest); CPPUNIT_TEST(testDuration); CPPUNIT_TEST(testDateTime); CPPUNIT_TEST(testDouble); CPPUNIT_TEST(testMeasure); + CPPUNIT_TEST(testBool); CPPUNIT_TEST_SUITE_END(); private: @@ -371,6 +373,22 @@ void ConverterTest::testMeasure() doTestMeasureToString("111.1pt", 2222, MeasureUnit::TWIP, MeasureUnit::POINT); doTestMeasureToString("385.7986in", 555550, MeasureUnit::TWIP, MeasureUnit::INCH); } + +void doTestStringToBool(bool bBool, char const*const pis) +{ + ::rtl::OUString const is(::rtl::OUString::createFromAscii(pis)); + bool bTemp; + bool bSuccess(Converter::convertBool(bTemp, is)); + OSL_TRACE("%s", bTemp); + CPPUNIT_ASSERT(bSuccess); + CPPUNIT_ASSERT_EQUAL(bBool, bTemp); + +} +void ConverterTest::testBool() +{ + doTestStringToBool(true, "true"); + doTestStringToBool(false, "false"); +} CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits