Bump version to 5.0-14
[LibreOffice.git] / filter / qa / cppunit / utils-test.cxx
blob5e306ef99335b56163c3ebfb85a2f4fb213505a5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <cppunit/TestAssert.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
13 #include <cppunit/plugin/TestPlugIn.h>
15 #include <sal/types.h>
16 #include <rtl/ustrbuf.hxx>
17 #include <filter/msfilter/util.hxx>
19 #include <unotest/bootstrapfixturebase.hxx>
21 namespace {
23 class UtilsTest
24 : public test::BootstrapFixtureBase
26 public:
27 void testTransColToIco();
29 CPPUNIT_TEST_SUITE(UtilsTest);
30 CPPUNIT_TEST(testTransColToIco);
31 CPPUNIT_TEST_SUITE_END();
34 void UtilsTest::testTransColToIco()
36 const sal_uInt32 aStdCol[] = {
37 0xeeeeee, 0xffff99, 0xff6600, 0xff3333, 0xff00cc, 0xff33ff, 0x9900ff, 0x6666ff, 0x00ccff, 0x66ffff, 0x33ff99, 0x99ff66, 0xccff00,
38 0xdddddd, 0xffff66, 0xffcc00, 0xff9999, 0xff66cc, 0xff99ff, 0xcc66ff, 0x9999ff, 0x9999ff, 0x99ffff, 0x66ff99, 0x99ff99, 0xccff66,
39 0xcccccc, 0xffff00, 0xff9900, 0xff6666, 0xff3399, 0xff66ff, 0x9933ff, 0x3333ff, 0x3399ff, 0x00ffff, 0x00ff66, 0x66ff66, 0x99ff33,
40 0xb2b2b2, 0xcc9900, 0xff3300, 0xff0000, 0xff0066, 0xff00ff, 0x6600ff, 0x0000ff, 0x0066ff, 0x00cccc, 0x00cc33, 0x00cc00, 0x66ff00,
41 0x999999, 0x996600, 0xcc3300, 0xcc0000, 0xcc0066, 0xcc00cc, 0x6600cc, 0x0000cc, 0x0066cc, 0x009999, 0x009933, 0x009900, 0x66cc00,
42 0x808080, 0x663300, 0x801900, 0x990000, 0x990066, 0x990099, 0x330099, 0x000099, 0x006699, 0x006666, 0x007826, 0x006600, 0x669900,
43 0x666666, 0x333300, 0x461900, 0x330000, 0x330033, 0x660066, 0x000033, 0x000066, 0x000080, 0x003333, 0x00331a, 0x003300, 0x193300,
44 0x333333, 0x666633, 0x661900, 0x663333, 0x660033, 0x663366, 0x330066, 0x333366, 0x003366, 0x336666, 0x006633, 0x336633, 0x336600 };
46 const sal_uInt16 aExpected[] = {
47 8, 7, 6, 6, 5, 5, 5, 2, 3, 3, 10, 4, 7,
48 16, 7, 7, 6, 5, 5, 5, 2, 2, 3, 4, 4, 7,
49 16, 7, 7, 6, 12, 5, 12, 2, 10, 3, 4, 4, 14,
50 16, 14, 6, 6, 6, 5, 2, 2, 2, 3, 4, 4, 4,
51 15, 14, 6, 6, 12, 5, 12, 2, 10, 10, 11, 11, 14,
52 15, 1, 13, 13, 12, 12, 9, 9, 10, 10, 11, 11, 14,
53 15, 14, 13, 13, 12, 12, 9, 9, 9, 10, 10, 11, 11,
54 1, 14, 13, 13, 1, 12, 1, 9, 1, 10, 1, 11, 1 };
56 for( size_t i = 0; i < SAL_N_ELEMENTS(aStdCol); ++i)
58 const OString sMessage = "Index of unmatched color: " + OString::number(i);
59 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), aExpected[i],
60 static_cast<sal_uInt16>(msfilter::util::TransColToIco( Color(aStdCol[i]) )));
63 // tdf#92471
64 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), static_cast<sal_uInt16>(msfilter::util::TransColToIco( Color( 0x6666ff ))));
65 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), static_cast<sal_uInt16>(msfilter::util::TransColToIco( Color( 0x6566ff ))));
66 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), static_cast<sal_uInt16>(msfilter::util::TransColToIco( Color( 0x6665ff ))));
67 CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), static_cast<sal_uInt16>(msfilter::util::TransColToIco( Color( 0x6666fe ))));
71 CPPUNIT_TEST_SUITE_REGISTRATION(UtilsTest);
75 CPPUNIT_PLUGIN_IMPLEMENT();
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */