From 1edec50b9daa18c1a4088ce94051c4b415cf8a1a Mon Sep 17 00:00:00 2001 From: Artur Dorda Date: Fri, 10 Aug 2012 14:57:44 +0200 Subject: 'color to string' test covered Change-Id: Ia65d1bef19ec02efbb5d7dd784d4cc48c3dd51f2 --- sax/qa/cppunit/test_converter.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sax') diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index 1efbc94dec7e..1bf1dd004709 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); } -- cgit