LCOV - code coverage report
Current view: top level - basegfx/test - basegfx2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 684 684 100.0 %
Date: 2015-06-13 12:38:46 Functions: 151 152 99.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <cppunit/TestAssert.h>
      21             : #include <cppunit/TestFixture.h>
      22             : #include <cppunit/extensions/HelperMacros.h>
      23             : #include <cppunit/plugin/TestPlugIn.h>
      24             : 
      25             : #include <basegfx/matrix/b2dhommatrix.hxx>
      26             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      27             : #include <basegfx/polygon/b2dpolygon.hxx>
      28             : #include <basegfx/polygon/b2dpolygontools.hxx>
      29             : #include <basegfx/curve/b2dcubicbezier.hxx>
      30             : #include <basegfx/curve/b2dbeziertools.hxx>
      31             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      32             : #include <basegfx/polygon/b2dpolygonclipper.hxx>
      33             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      34             : #include <basegfx/polygon/b2dtrapezoid.hxx>
      35             : #include <basegfx/range/b2irange.hxx>
      36             : #include <basegfx/range/b2ibox.hxx>
      37             : #include <basegfx/range/b1drange.hxx>
      38             : #include <basegfx/range/b2drange.hxx>
      39             : #include <basegfx/range/b2dpolyrange.hxx>
      40             : #include <basegfx/numeric/ftools.hxx>
      41             : #include <basegfx/color/bcolor.hxx>
      42             : #include <basegfx/color/bcolortools.hxx>
      43             : 
      44             : #include <basegfx/tools/rectcliptools.hxx>
      45             : 
      46             : #include <iostream>
      47             : #include <fstream>
      48             : 
      49             : #include <boxclipper.hxx>
      50             : 
      51             : using namespace ::basegfx;
      52             : 
      53             : namespace basegfx2d
      54             : {
      55           3 : class b2dsvgdimpex : public CppUnit::TestFixture
      56             : {
      57             : private:
      58             :     OUString aPath0;
      59             :     OUString aPath1;
      60             :     OUString aPath2;
      61             :     OUString aPath3;
      62             : 
      63             : public:
      64             :     // initialise your test code values here.
      65           1 :     void setUp() SAL_OVERRIDE
      66             :     {
      67             :         // simple rectangle
      68           1 :         aPath0 = "M 10 10-10 10-10-10 10-10Z";
      69             : 
      70             :         // simple bezier polygon
      71           1 :         aPath1 = "m11430 0c-8890 3810 5715 6985 5715 6985 "
      72             :             "0 0-17145-1905-17145-1905 0 0 22860-10160 "
      73           1 :             "16510 6350-6350 16510-3810-11430-3810-11430z";
      74             : 
      75             :         // '@' as a bezier polygon
      76           1 :         aPath2 = "m1917 1114c-89-189-233-284-430-284-167 "
      77             :             "0-306 91-419 273-113 182-170 370-170 564 "
      78             :             "0 145 33 259 98 342 65 84 150 126 257 126 "
      79             :             "77 0 154-19 231-57 77-38 147-97 210-176 63"
      80             :             "-79 99-143 109-190 38-199 76-398 114-598z"
      81             :             "m840 1646c-133 73-312 139-537 197-225 57"
      82             :             "-440 86-644 87-483-1-866-132-1150-392-284"
      83             :             "-261-426-619-426-1076 0-292 67-560 200-803 "
      84             :             "133-243 321-433 562-569 241-136 514-204 821"
      85             :             "-204 405 0 739 125 1003 374 264 250 396 550 "
      86             :             "396 899 0 313-88 576-265 787-177 212-386 318"
      87             :             "-627 318-191 0-308-94-352-281-133 187-315 281"
      88             :             "-546 281-172 0-315-67-428-200-113-133-170-301"
      89             :             "-170-505 0-277 90-527 271-751 181-223 394"
      90             :             "-335 640-335 196 0 353 83 470 250 13-68 26"
      91             :             "-136 41-204 96 0 192 0 288 0-74 376-148 752"
      92             :             "-224 1128-21 101-31 183-31 245 0 39 9 70 26 "
      93             :             "93 17 24 39 36 67 36 145 0 279-80 400-240 121"
      94             :             "-160 182-365 182-615 0-288-107-533-322-734"
      95             :             "-215-201-487-301-816-301-395 0-715 124-960 "
      96             :             "373-245 249-368 569-368 958 0 385 119 685 "
      97             :             "357 900 237 216 557 324 958 325 189-1 389-27 "
      98           1 :             "600-77 211-52 378-110 503-174 27 70 54 140 81 210z";
      99             : 
     100             :         // first part of 'Hello World' as a line polygon
     101           1 :         aPath3 = "m1598 125h306v2334h-306v-1105h-1293v1105h-305v"
     102             :             "-2334h305v973h1293zm2159 1015 78-44 85 235-91 "
     103             :             "47-91 40-90 34-90 29-89 21-88 16-88 10-88 3-102"
     104             :             "-4-97-12-91-19-85-26-40-16-39-18-38-20-36-22-34"
     105             :             "-24-33-26-32-27-30-30-29-31-27-33-25-33-23-36-21"
     106             :             "-36-19-38-18-40-16-40-26-86-18-91-11-97-4-103 3"
     107             :             "-98 11-94 17-89 24-84 31-79 37-75 22-35 23-34 24"
     108             :             "-33 27-32 28-30 29-28 31-27 31-24 33-22 34-21 35"
     109             :             "-18 37-17 38-14 38-13 41-11 41-8 86-12 91-4 82 4 "
     110             :             "78 10 37 9 37 9 36 12 35 14 33 15 33 17 32 19 31 "
     111             :             "21 30 22 30 25 55 54 26 29 24 31 22 32 21 33 19 "
     112             :             "34 18 36 30 74 23 80 17 84 10 89 3 94v78h-1277l6 "
     113             :             "75 10 70 14 66 19 62 23 57 13 26 14 26 15 25 17 "
     114             :             "23 17 22 19 21 19 20 21 18 21 18 23 16 23 14 24 "
     115             :             "14 26 12 26 11 27 10 28 8 59 13 63 7 67 3 80-3 81"
     116             :             "-9 79-14 80-21 78-26 79-32zm-1049-808-12 53h963l"
     117             :             "-7-51-11-49-14-46-17-43-21-40-24-38-27-36-31-32"
     118             :             "-33-29-35-25-37-22-38-17-40-14-41-9-42-6-44-2-48 "
     119             :             "2-46 6-44 9-42 13-40 17-38 21-36 24-34 28-32 32"
     120             :             "-29 34-26 38-23 41-20 44-17 47zm1648-1293h288v"
     121             :             "2459h-288zm752-2459h288v2459h-288zm1286-1750 86-11 "
     122             :             "91-4 91 4 85 12 42 8 39 11 39 13 38 14 36 17 35 18 "
     123             :             "34 20 33 23 31 24 30 26 29 28 28 30 26 32 25 33 23 "
     124             :             "34 21 35 37 75 31 80 24 84 16 90 11 94 3 100-3 100"
     125             :             "-11 95-16 89-24 85-31 80-37 74-21 35-23 35-25 32-26 "
     126             :             "32-28 30-29 28-30 26-31 24-33 22-34 21-35 18-36 17"
     127             :             "-38 14-39 13-39 10-42 9-85 12-91 4-91-4-86-12-41-9"
     128             :             "-40-10-39-13-37-14-36-17-35-18-34-21-33-22-31-24-30"
     129             :             "-26-29-28-28-30-26-32-25-32-23-35-21-35-38-74-30-80"
     130             :             "-24-85-17-89-11-95-3-100 3-101 11-95 17-90 24-85 30"
     131             :             "-79 38-75 21-35 23-35 25-32 26-32 28-30 29-28 30-26 "
     132           1 :             "31-24 33-22 34-20 35-18 36-16 37-15 39-12 40-11z";
     133           1 :     }
     134             : 
     135           1 :     void tearDown() SAL_OVERRIDE
     136             :     {
     137           1 :     }
     138             : 
     139           1 :     void impex()
     140             :     {
     141           1 :         B2DPolyPolygon  aPoly;
     142           2 :         OUString aExport;
     143             : 
     144           2 :         CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D",
     145           1 :                                tools::importFromSvgD( aPoly, aPath0, false, 0 ));
     146           1 :         aExport = tools::exportToSvgD( aPoly, true, true, false );
     147           1 :         const char* sExportString = "m10 10h-20v-20h20z";
     148           2 :         CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D",
     149           1 :                                aExport.equalsAscii(sExportString) );
     150           2 :         CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D (round-trip",
     151           1 :                                tools::importFromSvgD( aPoly, aExport, false, 0 ));
     152           1 :         aExport = tools::exportToSvgD( aPoly, true, true, false );
     153           2 :         CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D (round-trip)",
     154           1 :                                aExport.equalsAscii(sExportString));
     155             : 
     156           2 :         CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D",
     157           1 :                                tools::importFromSvgD( aPoly, aPath1, false, 0 ));
     158           1 :         aExport = tools::exportToSvgD( aPoly, true, true, false );
     159             : 
     160             :         // Adaptions for B2DPolygon bezier change (see #i77162#):
     161             : 
     162             :         // The import/export of aPath1 does not reproduce aExport again. This is
     163             :         // correct since aPath1 contains a segment with non-used control points
     164             :         // which gets exported now correctly as 'l' and also a point (#4, index 3)
     165             :         // with C2 continuity which produces a 's' staement now.
     166             : 
     167             :         // The old SVGexport identified nun-used ControlVectors erraneously as bezier segments
     168             :         // because the 2nd vector at the start point was used, even when added
     169             :         // with start point was identical to end point. Exactly for that reason
     170             :         // i reworked the B2DPolygon to use prev, next control points.
     171             : 
     172             :         // so for correct unit test i add the new exported string here as sExportStringSimpleBezier
     173             :         // and compare to it.
     174             :         const char* sExportStringSimpleBezier =
     175             :             "m11430 0c-8890 3810 5715 6985 5715 6985"
     176             :             "l-17145-1905c0 0 22860-10160 16510 6350"
     177           1 :             "s-3810-11430-3810-11430z";
     178           1 :         CPPUNIT_ASSERT_MESSAGE("exporting bezier polygon to SVG-D", aExport.equalsAscii(sExportStringSimpleBezier));
     179             : 
     180             :         // Adaptions for B2DPolygon bezier change (see #i77162#):
     181             : 
     182             :         // a 2nd good test is that re-importing of aExport has to create the same
     183             :         // B2DPolPolygon again:
     184           2 :         B2DPolyPolygon aReImport;
     185           1 :         CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D", tools::importFromSvgD( aReImport, aExport, false, 0));
     186           1 :         CPPUNIT_ASSERT_MESSAGE("re-imported polygon needs to be identical", aReImport == aPoly);
     187             : 
     188           1 :         CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D", tools::importFromSvgD( aPoly, aPath2, false, NULL));
     189           1 :         aExport = tools::exportToSvgD( aPoly, true, true, false );
     190             : 
     191             :         // Adaptions for B2DPolygon bezier change (see #i77162#):
     192             : 
     193             :         // same here, the corrected export with the corrected B2DPolygon is simply more efficient,
     194             :         // so i needed to change the compare string. Also adding the re-import comparison below.
     195             :         const char* sExportString1 =
     196             :             "m1917 1114c-89-189-233-284-430-284-167 0-306 91-419 273s-170 370-17"
     197             :             "0 564c0 145 33 259 98 342 65 84 150 126 257 126q115.5 0 231-57s147-97 210-176 99-143 109-190c38-199 76-398 114"
     198             :             "-598zm840 1646c-133 73-312 139-537 197-225 57-440 86-644 87-483-1-866-132-1150-392-284-261-426-619-426-1076 0-"
     199             :             "292 67-560 200-803s321-433 562-569 514-204 821-204c405 0 739 125 1003 374 264 250 396 550 396 899 0 313-88 576"
     200             :             "-265 787q-265.5 318-627 318c-191 0-308-94-352-281-133 187-315 281-546 281-172 0-315-67-428-200s-170-301-170-50"
     201             :             "5c0-277 90-527 271-751 181-223 394-335 640-335 196 0 353 83 470 250 13-68 26-136 41-204q144 0 288 0c-74 376-14"
     202             :             "8 752-224 1128-21 101-31 183-31 245 0 39 9 70 26 93 17 24 39 36 67 36 145 0 279-80 400-240s182-365 182-615c0-2"
     203             :             "88-107-533-322-734s-487-301-816-301c-395 0-715 124-960 373s-368 569-368 958q0 577.5 357 900c237 216 557 324 95"
     204           1 :             "8 325 189-1 389-27 600-77 211-52 378-110 503-174q40.5 105 81 210z";
     205           1 :         CPPUNIT_ASSERT_MESSAGE("re-importing '@' from SVG-D", tools::importFromSvgD( aReImport, aExport, false, 0));
     206           1 :         CPPUNIT_ASSERT_MESSAGE("re-imported '@' needs to be identical", aReImport == aPoly);
     207             : 
     208           1 :         CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D", aExport.equalsAscii(sExportString1));
     209           2 :         CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D (round-trip",
     210           1 :                                tools::importFromSvgD( aPoly, aExport, false, 0 ));
     211           1 :         aExport = tools::exportToSvgD( aPoly, true, true, false );
     212           2 :         CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D (round-trip)",
     213           1 :                                aExport.equalsAscii(sExportString1));
     214             : 
     215           2 :         CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D",
     216           1 :                                tools::importFromSvgD( aPoly, aPath3, false, 0 ));
     217           1 :         aExport = tools::exportToSvgD( aPoly, true, true, false );
     218             :         const char* sExportString2 =
     219             :             "m1598 125h306v2334h-306v-1105h-1293v1105h-305v-2334h305v973h1293"
     220             :             "zm2159 1015 78-44 85 235-91 47-91 40-90 34-90 29-89 21-88 16-88 10-88 3-102-4-97"
     221             :             "-12-91-19-85-26-40-16-39-18-38-20-36-22-34-24-33-26-32-27-30-30-29-31-27-33-25-3"
     222             :             "3-23-36-21-36-19-38-18-40-16-40-26-86-18-91-11-97-4-103 3-98 11-94 17-89 24-84 3"
     223             :             "1-79 37-75 22-35 23-34 24-33 27-32 28-30 29-28 31-27 31-24 33-22 34-21 35-18 37-"
     224             :             "17 38-14 38-13 41-11 41-8 86-12 91-4 82 4 78 10 37 9 37 9 36 12 35 14 33 15 33 1"
     225             :             "7 32 19 31 21 30 22 30 25 55 54 26 29 24 31 22 32 21 33 19 34 18 36 30 74 23 80 "
     226             :             "17 84 10 89 3 94v78h-1277l6 75 10 70 14 66 19 62 23 57 13 26 14 26 15 25 17 23 1"
     227             :             "7 22 19 21 19 20 21 18 21 18 23 16 23 14 24 14 26 12 26 11 27 10 28 8 59 13 63 7"
     228             :             " 67 3 80-3 81-9 79-14 80-21 78-26 79-32zm-1049-808-12 53h963l-7-51-11-49-14-46-1"
     229             :             "7-43-21-40-24-38-27-36-31-32-33-29-35-25-37-22-38-17-40-14-41-9-42-6-44-2-48 2-4"
     230             :             "6 6-44 9-42 13-40 17-38 21-36 24-34 28-32 32-29 34-26 38-23 41-20 44-17 47zm1648"
     231             :             "-1293h288v2459h-288zm752-2459h288v2459h-288zm1286-1750 86-11 91-4 91 4 85 12 42 "
     232             :             "8 39 11 39 13 38 14 36 17 35 18 34 20 33 23 31 24 30 26 29 28 28 30 26 32 25 33 "
     233             :             "23 34 21 35 37 75 31 80 24 84 16 90 11 94 3 100-3 100-11 95-16 89-24 85-31 80-37"
     234             :             " 74-21 35-23 35-25 32-26 32-28 30-29 28-30 26-31 24-33 22-34 21-35 18-36 17-38 1"
     235             :             "4-39 13-39 10-42 9-85 12-91 4-91-4-86-12-41-9-40-10-39-13-37-14-36-17-35-18-34-2"
     236             :             "1-33-22-31-24-30-26-29-28-28-30-26-32-25-32-23-35-21-35-38-74-30-80-24-85-17-89-"
     237             :             "11-95-3-100 3-101 11-95 17-90 24-85 30-79 38-75 21-35 23-35 25-32 26-32 28-30 29"
     238           1 :             "-28 30-26 31-24 33-22 34-20 35-18 36-16 37-15 39-12 40-11z";
     239           2 :         CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D",
     240           1 :                                aExport.equalsAscii(sExportString2));
     241           2 :         CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D (round-trip",
     242           1 :                                tools::importFromSvgD( aPoly, aExport, false, 0 ));
     243           1 :         aExport = tools::exportToSvgD( aPoly, true, true, false );
     244           2 :         CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D (round-trip)",
     245           1 :                                aExport.equalsAscii(sExportString2));
     246             : 
     247             :         const B2DPolygon aRect(
     248           2 :             tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) ));
     249           1 :         aExport = tools::exportToSvgD( B2DPolyPolygon(aRect), false, false, false );
     250             : 
     251           1 :         const char* sExportStringRect = "M0 0H4000V4000H0Z";
     252           2 :         CPPUNIT_ASSERT_MESSAGE("exporting to rectangle svg-d string",
     253           2 :                                aExport.equalsAscii(sExportStringRect));
     254           1 :     }
     255             : 
     256             :     // Change the following lines only, if you add, remove or rename
     257             :     // member functions of the current class,
     258             :     // because these macros are need by auto register mechanism.
     259             : 
     260           2 :     CPPUNIT_TEST_SUITE(b2dsvgdimpex);
     261           1 :     CPPUNIT_TEST(impex);
     262           5 :     CPPUNIT_TEST_SUITE_END();
     263             : }; // class b2dsvgdimpex
     264             : 
     265           3 : class b2drange : public CppUnit::TestFixture
     266             : {
     267             : private:
     268             : public:
     269           1 :     void check()
     270             :     {
     271           2 :         CPPUNIT_ASSERT_MESSAGE("simple range rounding from double to integer",
     272           1 :                                fround(B2DRange(1.2, 2.3, 3.5, 4.8)) == B2IRange(1, 2, 4, 5));
     273           1 :     }
     274             : 
     275             :     // Change the following lines only, if you add, remove or rename
     276             :     // member functions of the current class,
     277             :     // because these macros are need by auto register mechanism.
     278             : 
     279           2 :     CPPUNIT_TEST_SUITE(b2drange);
     280           1 :     CPPUNIT_TEST(check);
     281           5 :     CPPUNIT_TEST_SUITE_END();
     282             : };
     283             : 
     284           3 : class b2dpolyrange : public CppUnit::TestFixture
     285             : {
     286             : private:
     287             : public:
     288           1 :     void check()
     289             :     {
     290           1 :         B2DPolyRange aRange;
     291           1 :         aRange.appendElement(B2DRange(0,0,1,1),B2VectorOrientation::Positive);
     292           1 :         aRange.appendElement(B2DRange(2,2,3,3),B2VectorOrientation::Positive);
     293             : 
     294           2 :         CPPUNIT_ASSERT_MESSAGE("simple poly range - count",
     295           1 :                                aRange.count() == 2);
     296           2 :         CPPUNIT_ASSERT_MESSAGE("simple poly range - first element",
     297           1 :                                std::get<0>(aRange.getElement(0)) == B2DRange(0,0,1,1));
     298           2 :         CPPUNIT_ASSERT_MESSAGE("simple poly range - second element",
     299           1 :                                std::get<0>(aRange.getElement(1)) == B2DRange(2,2,3,3));
     300             : 
     301             :         // B2DPolyRange relies on correctly orientated rects
     302           1 :         const B2DRange aRect(0,0,1,1);
     303           2 :         CPPUNIT_ASSERT_MESSAGE("createPolygonFromRect - correct orientation",
     304             :                                tools::getOrientation(
     305           2 :                                    tools::createPolygonFromRect(aRect)) == B2VectorOrientation::Positive );
     306           1 :     }
     307             : 
     308             :     // Change the following lines only, if you add, remove or rename
     309             :     // member functions of the current class,
     310             :     // because these macros are need by auto register mechanism.
     311             : 
     312           2 :     CPPUNIT_TEST_SUITE(b2dpolyrange);
     313           1 :     CPPUNIT_TEST(check);
     314           5 :     CPPUNIT_TEST_SUITE_END();
     315             : };
     316             : 
     317          24 : class b2dhommatrix : public CppUnit::TestFixture
     318             : {
     319             : private:
     320             :     B2DHomMatrix    maIdentity;
     321             :     B2DHomMatrix    maScale;
     322             :     B2DHomMatrix    maTranslate;
     323             :     B2DHomMatrix    maShear;
     324             :     B2DHomMatrix    maAffine;
     325             :     B2DHomMatrix    maPerspective;
     326             : 
     327             : public:
     328             :     // initialise your test code values here.
     329           8 :     void setUp() SAL_OVERRIDE
     330             :     {
     331             :         // setup some test matrices
     332           8 :         maIdentity.identity(); // force compact layout
     333           8 :         maIdentity.set(0,0, 1.0);
     334           8 :         maIdentity.set(0,1, 0.0);
     335           8 :         maIdentity.set(0,2, 0.0);
     336           8 :         maIdentity.set(1,0, 0.0);
     337           8 :         maIdentity.set(1,1, 1.0);
     338           8 :         maIdentity.set(1,2, 0.0);
     339             : 
     340           8 :         maScale.identity(); // force compact layout
     341           8 :         maScale.set(0,0, 2.0);
     342           8 :         maScale.set(1,1, 20.0);
     343             : 
     344           8 :         maTranslate.identity(); // force compact layout
     345           8 :         maTranslate.set(0,2, 20.0);
     346           8 :         maTranslate.set(1,2, 2.0);
     347             : 
     348           8 :         maShear.identity(); // force compact layout
     349           8 :         maShear.set(0,1, 3.0);
     350           8 :         maShear.set(1,0, 7.0);
     351           8 :         maShear.set(1,1, 22.0);
     352             : 
     353           8 :         maAffine.identity(); // force compact layout
     354           8 :         maAffine.set(0,0, 1.0);
     355           8 :         maAffine.set(0,1, 2.0);
     356           8 :         maAffine.set(0,2, 3.0);
     357           8 :         maAffine.set(1,0, 4.0);
     358           8 :         maAffine.set(1,1, 5.0);
     359           8 :         maAffine.set(1,2, 6.0);
     360             : 
     361           8 :         maPerspective.set(0,0, 1.0);
     362           8 :         maPerspective.set(0,1, 2.0);
     363           8 :         maPerspective.set(0,2, 3.0);
     364           8 :         maPerspective.set(1,0, 4.0);
     365           8 :         maPerspective.set(1,1, 5.0);
     366           8 :         maPerspective.set(1,2, 6.0);
     367           8 :         maPerspective.set(2,0, 7.0);
     368           8 :         maPerspective.set(2,1, 8.0);
     369           8 :         maPerspective.set(2,2, 9.0);
     370           8 :     }
     371             : 
     372           8 :     void tearDown() SAL_OVERRIDE
     373             :     {
     374           8 :     }
     375             : 
     376           1 :     void equal()
     377             :     {
     378           1 :         B2DHomMatrix    aIdentity;
     379           2 :         B2DHomMatrix    aScale;
     380           2 :         B2DHomMatrix    aTranslate;
     381           2 :         B2DHomMatrix    aShear;
     382           2 :         B2DHomMatrix    aAffine;
     383           2 :         B2DHomMatrix    aPerspective;
     384             : 
     385             :         // setup some test matrices
     386           1 :         aIdentity.identity(); // force compact layout
     387           1 :         aIdentity.set(0,0, 1.0);
     388           1 :         aIdentity.set(0,1, 0.0);
     389           1 :         aIdentity.set(0,2, 0.0);
     390           1 :         aIdentity.set(1,0, 0.0);
     391           1 :         aIdentity.set(1,1, 1.0);
     392           1 :         aIdentity.set(1,2, 0.0);
     393             : 
     394           1 :         aScale.identity(); // force compact layout
     395           1 :         aScale.set(0,0, 2.0);
     396           1 :         aScale.set(1,1, 20.0);
     397             : 
     398           1 :         aTranslate.identity(); // force compact layout
     399           1 :         aTranslate.set(0,2, 20.0);
     400           1 :         aTranslate.set(1,2, 2.0);
     401             : 
     402           1 :         aShear.identity(); // force compact layout
     403           1 :         aShear.set(0,1, 3.0);
     404           1 :         aShear.set(1,0, 7.0);
     405           1 :         aShear.set(1,1, 22.0);
     406             : 
     407           1 :         aAffine.identity(); // force compact layout
     408           1 :         aAffine.set(0,0, 1.0);
     409           1 :         aAffine.set(0,1, 2.0);
     410           1 :         aAffine.set(0,2, 3.0);
     411           1 :         aAffine.set(1,0, 4.0);
     412           1 :         aAffine.set(1,1, 5.0);
     413           1 :         aAffine.set(1,2, 6.0);
     414             : 
     415           1 :         aPerspective.set(0,0, 1.0);
     416           1 :         aPerspective.set(0,1, 2.0);
     417           1 :         aPerspective.set(0,2, 3.0);
     418           1 :         aPerspective.set(1,0, 4.0);
     419           1 :         aPerspective.set(1,1, 5.0);
     420           1 :         aPerspective.set(1,2, 6.0);
     421           1 :         aPerspective.set(2,0, 7.0);
     422           1 :         aPerspective.set(2,1, 8.0);
     423           1 :         aPerspective.set(2,2, 9.0);
     424             : 
     425           1 :         CPPUNIT_ASSERT_MESSAGE("operator==: identity matrix", aIdentity == maIdentity);
     426           1 :         CPPUNIT_ASSERT_MESSAGE("operator==: scale matrix", aScale == maScale);
     427           1 :         CPPUNIT_ASSERT_MESSAGE("operator==: translate matrix", aTranslate == maTranslate);
     428           1 :         CPPUNIT_ASSERT_MESSAGE("operator==: shear matrix", aShear == maShear);
     429           1 :         CPPUNIT_ASSERT_MESSAGE("operator==: affine matrix", aAffine == maAffine);
     430           2 :         CPPUNIT_ASSERT_MESSAGE("operator==: perspective matrix", aPerspective == maPerspective);
     431           1 :     }
     432             : 
     433           1 :     void identity()
     434             :     {
     435           1 :         B2DHomMatrix ident;
     436             : 
     437           1 :         CPPUNIT_ASSERT_MESSAGE("identity", maIdentity == ident);
     438           1 :     }
     439             : 
     440           1 :     void scale()
     441             :     {
     442           1 :         B2DHomMatrix mat;
     443           1 :         mat.scale(2.0,20.0);
     444           1 :         CPPUNIT_ASSERT_MESSAGE("scale", maScale == mat);
     445           1 :     }
     446             : 
     447           1 :     void rotate()
     448             :     {
     449           1 :         B2DHomMatrix mat;
     450           1 :         mat.rotate(90*F_PI180);
     451           2 :         CPPUNIT_ASSERT_MESSAGE("rotate pi/2 yields exact matrix",
     452             :                                mat.get(0,0) == 0.0 &&
     453             :                                mat.get(0,1) == -1.0 &&
     454             :                                mat.get(0,2) == 0.0 &&
     455             :                                mat.get(1,0) == 1.0 &&
     456             :                                mat.get(1,1) == 0.0 &&
     457           1 :                                mat.get(1,2) == 0.0);
     458           1 :         mat.rotate(90*F_PI180);
     459           2 :         CPPUNIT_ASSERT_MESSAGE("rotate pi yields exact matrix",
     460             :                                mat.get(0,0) == -1.0 &&
     461             :                                mat.get(0,1) == 0.0 &&
     462             :                                mat.get(0,2) == 0.0 &&
     463             :                                mat.get(1,0) == 0.0 &&
     464             :                                mat.get(1,1) == -1.0 &&
     465           1 :                                mat.get(1,2) == 0.0);
     466           1 :         mat.rotate(90*F_PI180);
     467           2 :         CPPUNIT_ASSERT_MESSAGE("rotate 3/2 pi yields exact matrix",
     468             :                                mat.get(0,0) == 0.0 &&
     469             :                                mat.get(0,1) == 1.0 &&
     470             :                                mat.get(0,2) == 0.0 &&
     471             :                                mat.get(1,0) == -1.0 &&
     472             :                                mat.get(1,1) == 0.0 &&
     473           1 :                                mat.get(1,2) == 0.0);
     474           1 :         mat.rotate(90*F_PI180);
     475           2 :         CPPUNIT_ASSERT_MESSAGE("rotate 2 pi yields exact matrix",
     476             :                                mat.get(0,0) == 1.0 &&
     477             :                                mat.get(0,1) == 0.0 &&
     478             :                                mat.get(0,2) == 0.0 &&
     479             :                                mat.get(1,0) == 0.0 &&
     480             :                                mat.get(1,1) == 1.0 &&
     481           2 :                                mat.get(1,2) == 0.0);
     482           1 :     }
     483             : 
     484           1 :     void translate()
     485             :     {
     486           1 :         B2DHomMatrix mat;
     487           1 :         mat.translate(20.0,2.0);
     488           1 :         CPPUNIT_ASSERT_MESSAGE("translate", maTranslate == mat);
     489           1 :     }
     490             : 
     491           1 :     void shear()
     492             :     {
     493           1 :         B2DHomMatrix mat;
     494           1 :         mat.shearX(3.0);
     495           1 :         mat.shearY(7.0);
     496           1 :         CPPUNIT_ASSERT_MESSAGE("translate", maShear == mat);
     497           1 :     }
     498             : 
     499           1 :     void multiply()
     500             :     {
     501           1 :         B2DHomMatrix affineAffineProd;
     502             : 
     503           1 :         affineAffineProd.set(0,0, 9);
     504           1 :         affineAffineProd.set(0,1, 12);
     505           1 :         affineAffineProd.set(0,2, 18);
     506           1 :         affineAffineProd.set(1,0, 24);
     507           1 :         affineAffineProd.set(1,1, 33);
     508           1 :         affineAffineProd.set(1,2, 48);
     509             : 
     510           2 :         B2DHomMatrix affinePerspectiveProd;
     511             : 
     512           1 :         affinePerspectiveProd.set(0,0, 30);
     513           1 :         affinePerspectiveProd.set(0,1, 36);
     514           1 :         affinePerspectiveProd.set(0,2, 42);
     515           1 :         affinePerspectiveProd.set(1,0, 66);
     516           1 :         affinePerspectiveProd.set(1,1, 81);
     517           1 :         affinePerspectiveProd.set(1,2, 96);
     518           1 :         affinePerspectiveProd.set(2,0, 7);
     519           1 :         affinePerspectiveProd.set(2,1, 8);
     520           1 :         affinePerspectiveProd.set(2,2, 9);
     521             : 
     522           2 :         B2DHomMatrix perspectiveAffineProd;
     523             : 
     524           1 :         perspectiveAffineProd.set(0,0, 9);
     525           1 :         perspectiveAffineProd.set(0,1, 12);
     526           1 :         perspectiveAffineProd.set(0,2, 18);
     527           1 :         perspectiveAffineProd.set(1,0, 24);
     528           1 :         perspectiveAffineProd.set(1,1, 33);
     529           1 :         perspectiveAffineProd.set(1,2, 48);
     530           1 :         perspectiveAffineProd.set(2,0, 39);
     531           1 :         perspectiveAffineProd.set(2,1, 54);
     532           1 :         perspectiveAffineProd.set(2,2, 78);
     533             : 
     534           2 :         B2DHomMatrix perspectivePerspectiveProd;
     535             : 
     536           1 :         perspectivePerspectiveProd.set(0,0, 30);
     537           1 :         perspectivePerspectiveProd.set(0,1, 36);
     538           1 :         perspectivePerspectiveProd.set(0,2, 42);
     539           1 :         perspectivePerspectiveProd.set(1,0, 66);
     540           1 :         perspectivePerspectiveProd.set(1,1, 81);
     541           1 :         perspectivePerspectiveProd.set(1,2, 96);
     542           1 :         perspectivePerspectiveProd.set(2,0, 102);
     543           1 :         perspectivePerspectiveProd.set(2,1, 126);
     544           1 :         perspectivePerspectiveProd.set(2,2, 150);
     545             : 
     546           2 :         B2DHomMatrix temp;
     547             : 
     548           1 :         temp = maAffine;
     549           1 :         temp*=maAffine;
     550           1 :         CPPUNIT_ASSERT_MESSAGE("multiply: both compact", temp == affineAffineProd);
     551             : 
     552           1 :         temp = maPerspective;
     553           1 :         temp*=maAffine;
     554           1 :         CPPUNIT_ASSERT_MESSAGE("multiply: first compact", temp == affinePerspectiveProd);
     555             : 
     556           1 :         temp = maAffine;
     557           1 :         temp*=maPerspective;
     558           1 :         CPPUNIT_ASSERT_MESSAGE("multiply: second compact", temp == perspectiveAffineProd);
     559             : 
     560           1 :         temp = maPerspective;
     561           1 :         temp*=maPerspective;
     562           2 :         CPPUNIT_ASSERT_MESSAGE("multiply: none compact", temp == perspectivePerspectiveProd);
     563           1 :     }
     564             : 
     565          72 :     void impFillMatrix(B2DHomMatrix& rSource, double fScaleX, double fScaleY, double fShearX, double fRotate)
     566             :     {
     567             :         // fill rSource with a linear combination of scale, shear and rotate
     568          72 :         rSource.identity();
     569          72 :         rSource.scale(fScaleX, fScaleY);
     570          72 :         rSource.shearX(fShearX);
     571          72 :         rSource.rotate(fRotate);
     572          72 :     }
     573             : 
     574          36 :     bool impDecomposeComposeTest(double fScaleX, double fScaleY, double fShearX, double fRotate)
     575             :     {
     576             :         // linear combine matrix with given values
     577          36 :         B2DHomMatrix aSource;
     578          36 :         impFillMatrix(aSource, fScaleX, fScaleY, fShearX, fRotate);
     579             : 
     580             :         // decompose that matrix
     581          72 :         B2DTuple aDScale;
     582          72 :         B2DTuple aDTrans;
     583             :         double fDRot;
     584             :         double fDShX;
     585          36 :         bool bWorked = aSource.decompose(aDScale, aDTrans, fDRot, fDShX);
     586             : 
     587             :         // linear combine another matrix with decomposition results
     588          72 :         B2DHomMatrix aRecombined;
     589          36 :         impFillMatrix(aRecombined, aDScale.getX(), aDScale.getY(), fDShX, fDRot);
     590             : 
     591             :         // if decomposition worked, matrices need to be the same
     592          72 :         return bWorked && aSource == aRecombined;
     593             :     }
     594             : 
     595           1 :     void decompose()
     596             :     {
     597             :         // test matrix decompositions. Each matrix decomposed and rebuilt
     598             :         // using the decompose result should be the same as before. Test
     599             :         // with all ranges of values. Translations are not tested since these
     600             :         // are just the two rightmost values and uncritical
     601             :         static double fSX(10.0);
     602             :         static double fSY(12.0);
     603             :         static double fR(45.0 * F_PI180);
     604             :         static double fS(15.0 * F_PI180);
     605             : 
     606             :         // check all possible scaling combinations
     607           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test A1", impDecomposeComposeTest(fSX, fSY, 0.0, 0.0));
     608           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test A2", impDecomposeComposeTest(-fSX, fSY, 0.0, 0.0));
     609           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test A3", impDecomposeComposeTest(fSX, -fSY, 0.0, 0.0));
     610           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test A4", impDecomposeComposeTest(-fSX, -fSY, 0.0, 0.0));
     611             : 
     612             :         // check all possible scaling combinations with positive rotation
     613           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test B1", impDecomposeComposeTest(fSX, fSY, 0.0, fR));
     614           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test B2", impDecomposeComposeTest(-fSX, fSY, 0.0, fR));
     615           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test B3", impDecomposeComposeTest(fSX, -fSY, 0.0, fR));
     616           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test B4", impDecomposeComposeTest(-fSX, -fSY, 0.0, fR));
     617             : 
     618             :         // check all possible scaling combinations with negative rotation
     619           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test C1", impDecomposeComposeTest(fSX, fSY, 0.0, -fR));
     620           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test C2", impDecomposeComposeTest(-fSX, fSY, 0.0, -fR));
     621           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test C3", impDecomposeComposeTest(fSX, -fSY, 0.0, -fR));
     622           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test C4", impDecomposeComposeTest(-fSX, -fSY, 0.0, -fR));
     623             : 
     624             :         // check all possible scaling combinations with positive shear
     625           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test D1", impDecomposeComposeTest(fSX, fSY, tan(fS), 0.0));
     626           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test D2", impDecomposeComposeTest(-fSX, fSY, tan(fS), 0.0));
     627           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test D3", impDecomposeComposeTest(fSX, -fSY, tan(fS), 0.0));
     628           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test D4", impDecomposeComposeTest(-fSX, -fSY, tan(fS), 0.0));
     629             : 
     630             :         // check all possible scaling combinations with negative shear
     631           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test E1", impDecomposeComposeTest(fSX, fSY, tan(-fS), 0.0));
     632           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test E2", impDecomposeComposeTest(-fSX, fSY, tan(-fS), 0.0));
     633           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test E3", impDecomposeComposeTest(fSX, -fSY, tan(-fS), 0.0));
     634           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test E4", impDecomposeComposeTest(-fSX, -fSY, tan(-fS), 0.0));
     635             : 
     636             :         // check all possible scaling combinations with positive rotate and positive shear
     637           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test F1", impDecomposeComposeTest(fSX, fSY, tan(fS), fR));
     638           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test F2", impDecomposeComposeTest(-fSX, fSY, tan(fS), fR));
     639           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test F3", impDecomposeComposeTest(fSX, -fSY, tan(fS), fR));
     640           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test F4", impDecomposeComposeTest(-fSX, -fSY, tan(fS), fR));
     641             : 
     642             :         // check all possible scaling combinations with negative rotate and positive shear
     643           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test G1", impDecomposeComposeTest(fSX, fSY, tan(fS), -fR));
     644           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test G2", impDecomposeComposeTest(-fSX, fSY, tan(fS), -fR));
     645           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test G3", impDecomposeComposeTest(fSX, -fSY, tan(fS), -fR));
     646           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test G4", impDecomposeComposeTest(-fSX, -fSY, tan(fS), -fR));
     647             : 
     648             :         // check all possible scaling combinations with positive rotate and negative shear
     649           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test H1", impDecomposeComposeTest(fSX, fSY, tan(-fS), fR));
     650           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test H2", impDecomposeComposeTest(-fSX, fSY, tan(-fS), fR));
     651           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test H3", impDecomposeComposeTest(fSX, -fSY, tan(-fS), fR));
     652           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test H4", impDecomposeComposeTest(-fSX, -fSY, tan(-fS), fR));
     653             : 
     654             :         // check all possible scaling combinations with negative rotate and negative shear
     655           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test I1", impDecomposeComposeTest(fSX, fSY, tan(-fS), -fR));
     656           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test I2", impDecomposeComposeTest(-fSX, fSY, tan(-fS), -fR));
     657           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test I3", impDecomposeComposeTest(fSX, -fSY, tan(-fS), -fR));
     658           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test I4", impDecomposeComposeTest(-fSX, -fSY, tan(-fS), -fR));
     659             : 
     660             :         // cover special case of 180 degree rotation
     661             :         B2DHomMatrix aTest=tools::createScaleShearXRotateTranslateB2DHomMatrix(
     662             :             6425,3938,
     663             :             0,
     664             :             180*F_PI180,
     665           1 :             10482,4921);
     666             :         // decompose that matrix
     667           2 :         B2DTuple aDScale;
     668           2 :         B2DTuple aDTrans;
     669             :         double fDRot;
     670             :         double fDShX;
     671           1 :         aTest.decompose(aDScale, aDTrans, fDRot, fDShX);
     672           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", aDScale.getX() == 6425 && aDScale.getY() == 3938);
     673           1 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", aDTrans.getX() == 10482 && aDTrans.getY() == 4921);
     674           2 :         CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", fDRot == 180*F_PI180);
     675           1 :     }
     676             : 
     677             :     // Change the following lines only, if you add, remove or rename
     678             :     // member functions of the current class,
     679             :     // because these macros are need by auto register mechanism.
     680             : 
     681           2 :     CPPUNIT_TEST_SUITE(b2dhommatrix);
     682           1 :     CPPUNIT_TEST(equal);
     683           1 :     CPPUNIT_TEST(identity);
     684           1 :     CPPUNIT_TEST(scale);
     685           1 :     CPPUNIT_TEST(translate);
     686           1 :     CPPUNIT_TEST(rotate);
     687           1 :     CPPUNIT_TEST(shear);
     688           1 :     CPPUNIT_TEST(multiply);
     689           1 :     CPPUNIT_TEST(decompose);
     690           5 :     CPPUNIT_TEST_SUITE_END();
     691             : 
     692             : }; // class b2dhommatrix
     693             : 
     694           3 : class b2dpoint : public CppUnit::TestFixture
     695             : {
     696             : public:
     697             :     // insert your test code here.
     698             :     // this is only demonstration code
     699           1 :     void EmptyMethod()
     700             :     {
     701             :           // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
     702           1 :     }
     703             : 
     704             :     // Change the following lines only, if you add, remove or rename
     705             :     // member functions of the current class,
     706             :     // because these macros are need by auto register mechanism.
     707             : 
     708           2 :     CPPUNIT_TEST_SUITE(b2dpoint);
     709           1 :     CPPUNIT_TEST(EmptyMethod);
     710           5 :     CPPUNIT_TEST_SUITE_END();
     711             : }; // class b2dpoint
     712             : 
     713           3 : class b2dpolygon : public CppUnit::TestFixture
     714             : {
     715             : public:
     716             :     // insert your test code here.
     717           1 :     void testBasics()
     718             :     {
     719           1 :         B2DPolygon aPoly;
     720             : 
     721           1 :         aPoly.appendBezierSegment(B2DPoint(1,1),B2DPoint(2,2),B2DPoint(3,3));
     722             : 
     723           2 :         CPPUNIT_ASSERT_MESSAGE("#1 first polygon point wrong",
     724           1 :                                aPoly.getB2DPoint(0) == B2DPoint(3,3));
     725           2 :         CPPUNIT_ASSERT_MESSAGE("#1 first control point wrong",
     726           1 :                                aPoly.getPrevControlPoint(0) == B2DPoint(2,2));
     727           2 :         CPPUNIT_ASSERT_MESSAGE("#1 second control point wrong",
     728           1 :                                aPoly.getNextControlPoint(0) == B2DPoint(3,3));
     729           2 :         CPPUNIT_ASSERT_MESSAGE("next control point not used",
     730           1 :                                !aPoly.isNextControlPointUsed(0));
     731             : 
     732           1 :         aPoly.setNextControlPoint(0,B2DPoint(4,4));
     733           2 :         CPPUNIT_ASSERT_MESSAGE("#1.1 second control point wrong",
     734           1 :                                aPoly.getNextControlPoint(0) == B2DPoint(4,4));
     735           2 :         CPPUNIT_ASSERT_MESSAGE("next control point used",
     736           1 :                                aPoly.isNextControlPointUsed(0));
     737           2 :         CPPUNIT_ASSERT_MESSAGE("areControlPointsUsed() wrong",
     738           1 :                                aPoly.areControlPointsUsed());
     739           2 :         CPPUNIT_ASSERT_MESSAGE("getContinuityInPoint() wrong",
     740           1 :                                aPoly.getContinuityInPoint(0) == B2VectorContinuity::C2);
     741             : 
     742           1 :         aPoly.resetControlPoints();
     743           2 :         CPPUNIT_ASSERT_MESSAGE("resetControlPoints() did not clear",
     744           1 :                                aPoly.getB2DPoint(0) == B2DPoint(3,3));
     745           2 :         CPPUNIT_ASSERT_MESSAGE("resetControlPoints() did not clear",
     746           1 :                                aPoly.getPrevControlPoint(0) == B2DPoint(3,3));
     747           2 :         CPPUNIT_ASSERT_MESSAGE("resetControlPoints() did not clear",
     748           1 :                                aPoly.getNextControlPoint(0) == B2DPoint(3,3));
     749           2 :         CPPUNIT_ASSERT_MESSAGE("areControlPointsUsed() wrong #2",
     750           1 :                                !aPoly.areControlPointsUsed());
     751             : 
     752           1 :         aPoly.clear();
     753           1 :         aPoly.append(B2DPoint(0,0));
     754           1 :         aPoly.appendBezierSegment(B2DPoint(1,1),B2DPoint(2,2),B2DPoint(3,3));
     755             : 
     756           2 :         CPPUNIT_ASSERT_MESSAGE("#2 first polygon point wrong",
     757           1 :                                aPoly.getB2DPoint(0) == B2DPoint(0,0));
     758           2 :         CPPUNIT_ASSERT_MESSAGE("#2 first control point wrong",
     759           1 :                                aPoly.getPrevControlPoint(0) == B2DPoint(0,0));
     760           2 :         CPPUNIT_ASSERT_MESSAGE("#2 second control point wrong",
     761           1 :                                aPoly.getNextControlPoint(0) == B2DPoint(1,1));
     762           2 :         CPPUNIT_ASSERT_MESSAGE("#2 third control point wrong",
     763           1 :                                aPoly.getPrevControlPoint(1) == B2DPoint(2,2));
     764           2 :         CPPUNIT_ASSERT_MESSAGE("#2 fourth control point wrong",
     765           1 :                                aPoly.getNextControlPoint(1) == B2DPoint(3,3));
     766           2 :         CPPUNIT_ASSERT_MESSAGE("#2 second polygon point wrong",
     767           2 :                                aPoly.getB2DPoint(1) == B2DPoint(3,3));
     768           1 :     }
     769             :     // Change the following lines only, if you add, remove or rename
     770             :     // member functions of the current class,
     771             :     // because these macros are need by auto register mechanism.
     772             : 
     773           2 :     CPPUNIT_TEST_SUITE(b2dpolygon);
     774           1 :     CPPUNIT_TEST(testBasics);
     775           5 :     CPPUNIT_TEST_SUITE_END();
     776             : }; // class b2dpolygon
     777             : 
     778           3 : class b2dpolygontools : public CppUnit::TestFixture
     779             : {
     780             : public:
     781             :     // insert your test code here.
     782             :     // this is only demonstration code
     783           1 :     void testIsRectangle()
     784             :     {
     785             :         B2DPolygon aRect1(
     786             :             tools::createPolygonFromRect(
     787           1 :                 B2DRange(0,0,1,1) ) );
     788             : 
     789           2 :         B2DPolygon aRect2;
     790           1 :         aRect2.append( B2DPoint(0,0) );
     791           1 :         aRect2.append( B2DPoint(1,0) );
     792           1 :         aRect2.append( B2DPoint(1,.5));
     793           1 :         aRect2.append( B2DPoint(1,1) );
     794           1 :         aRect2.append( B2DPoint(0,1) );
     795           1 :         aRect2.setClosed(true);
     796             : 
     797           2 :         B2DPolygon aNonRect1;
     798           1 :         aNonRect1.append( B2DPoint(0,0) );
     799           1 :         aNonRect1.append( B2DPoint(1,0) );
     800           1 :         aNonRect1.append( B2DPoint(1,1) );
     801           1 :         aNonRect1.append( B2DPoint(0.5,1) );
     802           1 :         aNonRect1.append( B2DPoint(0.5,0) );
     803           1 :         aNonRect1.setClosed(true);
     804             : 
     805           2 :         B2DPolygon aNonRect2;
     806           1 :         aNonRect2.append( B2DPoint(0,0) );
     807           1 :         aNonRect2.append( B2DPoint(1,1) );
     808           1 :         aNonRect2.append( B2DPoint(1,0) );
     809           1 :         aNonRect2.append( B2DPoint(0,1) );
     810           1 :         aNonRect2.setClosed(true);
     811             : 
     812           2 :         B2DPolygon aNonRect3;
     813           1 :         aNonRect3.append( B2DPoint(0,0) );
     814           1 :         aNonRect3.append( B2DPoint(1,0) );
     815           1 :         aNonRect3.append( B2DPoint(1,1) );
     816           1 :         aNonRect3.setClosed(true);
     817             : 
     818           2 :         B2DPolygon aNonRect4;
     819           1 :         aNonRect4.append( B2DPoint(0,0) );
     820           1 :         aNonRect4.append( B2DPoint(1,0) );
     821           1 :         aNonRect4.append( B2DPoint(1,1) );
     822           1 :         aNonRect4.append( B2DPoint(0,1) );
     823             : 
     824           2 :         B2DPolygon aNonRect5;
     825           1 :         aNonRect5.append( B2DPoint(0,0) );
     826           1 :         aNonRect5.append( B2DPoint(1,0) );
     827           1 :         aNonRect5.append( B2DPoint(1,1) );
     828           1 :         aNonRect5.append( B2DPoint(0,1) );
     829           1 :         aNonRect5.setControlPoints(1,B2DPoint(1,0),B2DPoint(-11,0));
     830           1 :         aNonRect5.setClosed(true);
     831             : 
     832           2 :         CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 1",
     833           1 :                                tools::isRectangle( aRect1 ));
     834           2 :         CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 2",
     835           1 :                                tools::isRectangle( aRect2 ));
     836           2 :         CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 1",
     837           1 :                                !tools::isRectangle( aNonRect1 ));
     838           2 :         CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 2",
     839           1 :                                !tools::isRectangle( aNonRect2 ));
     840           2 :         CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 3",
     841           1 :                                !tools::isRectangle( aNonRect3 ));
     842           2 :         CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 4",
     843           1 :                                !tools::isRectangle( aNonRect4 ));
     844           2 :         CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 5",
     845           2 :                                !tools::isRectangle( aNonRect5 ));
     846           1 :     }
     847             : 
     848             :     // Change the following lines only, if you add, remove or rename
     849             :     // member functions of the current class,
     850             :     // because these macros are need by auto register mechanism.
     851             : 
     852           2 :     CPPUNIT_TEST_SUITE(b2dpolygontools);
     853           1 :     CPPUNIT_TEST(testIsRectangle);
     854           5 :     CPPUNIT_TEST_SUITE_END();
     855             : }; // class b2dpolygontools
     856             : 
     857           3 : class b2dpolypolygon : public CppUnit::TestFixture
     858             : {
     859             : public:
     860             :     // insert your test code here.
     861           1 :     void testTrapezoidHelper()
     862             :     {
     863           1 :         B2DPolygon aPolygon;
     864             :         // provoke the PointBlockAllocator to exercise the freeIfLast path
     865         161 :         for(int i = 0; i < 16 * 10; i++)
     866             :         {
     867         160 :             B2DPoint aPoint(getRandomOrdinal(1000), getRandomOrdinal(1000));
     868         160 :             aPolygon.append(aPoint);
     869         160 :         }
     870             :         // scatter some duplicate points in to stress things more.
     871         161 :         for(int i = 0; i < 16 * 10; i++)
     872             :         {
     873         160 :             aPolygon.insert(getRandomOrdinal(aPolygon.count() - 1),
     874         320 :                             aPolygon.getB2DPoint(getRandomOrdinal(aPolygon.count() - 1)));
     875             :         }
     876           2 :         B2DPolygon aPolygonOffset;
     877             :         // duplicate the polygon and offset it slightly.
     878         321 :         for(size_t i = 0; i < aPolygon.count(); i++)
     879             :         {
     880         320 :             B2DPoint aPoint(aPolygon.getB2DPoint(i));
     881         320 :             aPoint += B2DPoint(0.5-getRandomOrdinal(1),0.5-getRandomOrdinal(1));
     882         320 :         }
     883           2 :         B2DPolyPolygon aPolyPolygon;
     884           1 :         aPolyPolygon.append(aPolygon);
     885           1 :         aPolyPolygon.append(aPolygonOffset);
     886           2 :         B2DTrapezoidVector aVector;
     887           1 :         basegfx::tools::trapezoidSubdivide(aVector, aPolyPolygon);
     888           2 :         CPPUNIT_ASSERT_MESSAGE("more than zero sub-divided trapezoids",
     889           2 :                                aVector.size() > 0);
     890           1 :     }
     891             : 
     892             :     // Change the following lines only, if you add, remove or rename
     893             :     // member functions of the current class,
     894             :     // because these macros are need by auto register mechanism.
     895             : 
     896           2 :     CPPUNIT_TEST_SUITE(b2dpolypolygon);
     897           1 :     CPPUNIT_TEST(testTrapezoidHelper);
     898           5 :     CPPUNIT_TEST_SUITE_END();
     899             : }; // class b2dpolypolygon
     900             : 
     901           3 : class b1Xrange : public CppUnit::TestFixture
     902             : {
     903             : public:
     904           1 :     template<class Type> void implCheck()
     905             :     {
     906             :         // test interval axioms
     907             :         // (http://en.wikipedia.org/wiki/Interval_%28mathematics%29)
     908           1 :         Type aRange;
     909           1 :         CPPUNIT_ASSERT_MESSAGE("default ctor - empty range", aRange.isEmpty());
     910           1 :         CPPUNIT_ASSERT_MESSAGE("center - get cop-out value since range is empty", aRange.getCenter()==0);
     911             : 
     912             :         // degenerate interval
     913           1 :         aRange.expand(1);
     914           1 :         CPPUNIT_ASSERT_MESSAGE("degenerate range - still, not empty!", !aRange.isEmpty());
     915           1 :         CPPUNIT_ASSERT_MESSAGE("degenerate range - size of 0", aRange.getRange() == 0);
     916           1 :         CPPUNIT_ASSERT_MESSAGE("same value as degenerate range - is inside range", aRange.isInside(1));
     917           1 :         CPPUNIT_ASSERT_MESSAGE("center - must be the single range value", aRange.getCenter()==1);
     918             : 
     919             :         // proper interval
     920           1 :         aRange.expand(2);
     921           1 :         CPPUNIT_ASSERT_MESSAGE("proper range - size of 1", aRange.getRange() == 1);
     922           1 :         CPPUNIT_ASSERT_MESSAGE("smaller value of range - is inside *closed* range", aRange.isInside(1));
     923           1 :         CPPUNIT_ASSERT_MESSAGE("larger value of range - is inside *closed* range", aRange.isInside(2));
     924             : 
     925             :         // center for proper interval that works for ints, too
     926           1 :         aRange.expand(3);
     927           1 :         CPPUNIT_ASSERT_MESSAGE("center - must be half of the range", aRange.getCenter()==2);
     928             : 
     929             :         // check overlap
     930           1 :         Type aRange2(0,1);
     931           1 :         CPPUNIT_ASSERT_MESSAGE("range overlapping *includes* upper bound", aRange.overlaps(aRange2));
     932           1 :         CPPUNIT_ASSERT_MESSAGE("range overlapping *includes* upper bound, but only barely", !aRange.overlapsMore(aRange2));
     933             : 
     934           1 :         Type aRange3(0,2);
     935           1 :         CPPUNIT_ASSERT_MESSAGE("range overlapping is fully overlapping now", aRange.overlapsMore(aRange3));
     936             : 
     937             :         // check intersect
     938           1 :         Type aRange4(3,4);
     939           1 :         aRange.intersect(aRange4);
     940           1 :         CPPUNIT_ASSERT_MESSAGE("range intersection is yielding empty range!", !aRange.isEmpty());
     941             : 
     942           1 :         Type aRange5(5,6);
     943           1 :         aRange.intersect(aRange5);
     944           1 :         CPPUNIT_ASSERT_MESSAGE("range intersection is yielding nonempty range!", aRange.isEmpty());
     945             : 
     946             :         // just so that this compiles -
     947           1 :         Type aRange6( aRange );
     948             :         (void)aRange6;
     949           1 :     }
     950             : 
     951           1 :     void check()
     952             :     {
     953           1 :         implCheck<B1DRange>();
     954           1 :     }
     955             : 
     956             :     // Change the following lines only, if you add, remove or rename
     957             :     // member functions of the current class,
     958             :     // because these macros are need by auto register mechanism.
     959             : 
     960           2 :     CPPUNIT_TEST_SUITE(b1Xrange);
     961           1 :     CPPUNIT_TEST(check);
     962           5 :     CPPUNIT_TEST_SUITE_END();
     963             : }; // class b1Xrange
     964             : 
     965           3 : class b2Xrange : public CppUnit::TestFixture
     966             : {
     967             : public:
     968           2 :     template<class Type> void implCheck()
     969             :     {
     970             :         // cohen sutherland clipping
     971           2 :         Type aRange(0,0,10,10);
     972             : 
     973           2 :         CPPUNIT_ASSERT_MESSAGE("(0,0) is outside range!",
     974             :                                tools::getCohenSutherlandClipFlags(B2IPoint(0,0),aRange) == 0);
     975           2 :         CPPUNIT_ASSERT_MESSAGE("(-1,-1) is inside range!",
     976             :                                tools::getCohenSutherlandClipFlags(B2IPoint(-1,-1),aRange) ==
     977             :                                (tools::RectClipFlags::LEFT|tools::RectClipFlags::TOP));
     978           2 :         CPPUNIT_ASSERT_MESSAGE("(10,10) is outside range!",
     979             :                                tools::getCohenSutherlandClipFlags(B2IPoint(10,10),aRange) == 0);
     980           2 :         CPPUNIT_ASSERT_MESSAGE("(11,11) is inside range!",
     981             :                                tools::getCohenSutherlandClipFlags(B2IPoint(11,11),aRange) ==
     982             :                                (tools::RectClipFlags::RIGHT|tools::RectClipFlags::BOTTOM));
     983             : 
     984             :         // just so that this compiles -
     985           2 :         Type aRange1( aRange );
     986             :         (void)aRange1;
     987           2 :     }
     988             : 
     989           1 :     void check()
     990             :     {
     991           1 :         implCheck<B2DRange>();
     992           1 :         implCheck<B2IRange>();
     993           1 :     }
     994             : 
     995             :     // Change the following lines only, if you add, remove or rename
     996             :     // member functions of the current class,
     997             :     // because these macros are need by auto register mechanism.
     998             : 
     999           2 :     CPPUNIT_TEST_SUITE(b2Xrange);
    1000           1 :     CPPUNIT_TEST(check);
    1001           5 :     CPPUNIT_TEST_SUITE_END();
    1002             : }; // class b2Xrange
    1003             : 
    1004           3 : class b2ibox : public CppUnit::TestFixture
    1005             : {
    1006             : public:
    1007           1 :     void TestBox()
    1008             :     {
    1009             :         // cohen sutherland clipping
    1010           1 :         B2IBox aBox(0,0,10,10);
    1011             : 
    1012           2 :         CPPUNIT_ASSERT_MESSAGE("(0,0) is outside range!",
    1013           1 :                                tools::getCohenSutherlandClipFlags(B2IPoint(0,0),aBox) == 0);
    1014           2 :         CPPUNIT_ASSERT_MESSAGE("(-1,-1) is inside range!",
    1015             :                                tools::getCohenSutherlandClipFlags(B2IPoint(-1,-1),aBox) ==
    1016           1 :                                (tools::RectClipFlags::LEFT|tools::RectClipFlags::TOP));
    1017           2 :         CPPUNIT_ASSERT_MESSAGE("(9,9) is outside range!",
    1018           1 :                                tools::getCohenSutherlandClipFlags(B2IPoint(9,9),aBox) == 0);
    1019           2 :         CPPUNIT_ASSERT_MESSAGE("(10,10) is inside range!",
    1020             :                                tools::getCohenSutherlandClipFlags(B2IPoint(10,10),aBox) ==
    1021           1 :                                (tools::RectClipFlags::RIGHT|tools::RectClipFlags::BOTTOM));
    1022             : 
    1023             :         // just so that this compiles -
    1024           1 :         B2IBox aBox1( aBox );
    1025             :         (void)aBox1;
    1026           1 :     }
    1027             : 
    1028             :     // Change the following lines only, if you add, remove or rename
    1029             :     // member functions of the current class,
    1030             :     // because these macros are need by auto register mechanism.
    1031           2 :     CPPUNIT_TEST_SUITE(b2ibox);
    1032           1 :     CPPUNIT_TEST(TestBox);
    1033           5 :     CPPUNIT_TEST_SUITE_END();
    1034             : }; // class b2ibox
    1035             : 
    1036           3 : class b2dtuple : public CppUnit::TestFixture
    1037             : {
    1038             : public:
    1039             :     // insert your test code here.
    1040             :     // this is only demonstration code
    1041           1 :     void EmptyMethod()
    1042             :     {
    1043             :           // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
    1044           1 :     }
    1045             : 
    1046             :     // Change the following lines only, if you add, remove or rename
    1047             :     // member functions of the current class,
    1048             :     // because these macros are need by auto register mechanism.
    1049             : 
    1050           2 :     CPPUNIT_TEST_SUITE(b2dtuple);
    1051           1 :     CPPUNIT_TEST(EmptyMethod);
    1052           5 :     CPPUNIT_TEST_SUITE_END();
    1053             : }; // class b2dtuple
    1054             : 
    1055           6 : class bcolor : public CppUnit::TestFixture
    1056             : {
    1057             :     BColor maWhite;
    1058             :     BColor maBlack;
    1059             :     BColor maRed;
    1060             :     BColor maGreen;
    1061             :     BColor maBlue;
    1062             :     BColor maYellow;
    1063             :     BColor maMagenta;
    1064             :     BColor maCyan;
    1065             : 
    1066             : public:
    1067           3 :     bcolor() :
    1068             :         maWhite(1,1,1),
    1069             :         maBlack(0,0,0),
    1070             :         maRed(1,0,0),
    1071             :         maGreen(0,1,0),
    1072             :         maBlue(0,0,1),
    1073             :         maYellow(1,1,0),
    1074             :         maMagenta(1,0,1),
    1075           3 :         maCyan(0,1,1)
    1076           3 :     {}
    1077             : 
    1078             :     // insert your test code here.
    1079           1 :     void hslTest()
    1080             :     {
    1081           2 :         CPPUNIT_ASSERT_MESSAGE("white",
    1082           1 :                                tools::rgb2hsl(maWhite) == BColor(0,0,1));
    1083           2 :         CPPUNIT_ASSERT_MESSAGE("black",
    1084           1 :                                tools::rgb2hsl(maBlack) == BColor(0,0,0));
    1085           2 :         CPPUNIT_ASSERT_MESSAGE("red",
    1086           1 :                                tools::rgb2hsl(maRed) == BColor(0,1,0.5));
    1087           2 :         CPPUNIT_ASSERT_MESSAGE("green",
    1088           1 :                                tools::rgb2hsl(maGreen) == BColor(120,1,0.5));
    1089           2 :         CPPUNIT_ASSERT_MESSAGE("blue",
    1090           1 :                                tools::rgb2hsl(maBlue) == BColor(240,1,0.5));
    1091           2 :         CPPUNIT_ASSERT_MESSAGE("yellow",
    1092           1 :                                tools::rgb2hsl(maYellow) == BColor(60,1,0.5));
    1093           2 :         CPPUNIT_ASSERT_MESSAGE("magenta",
    1094           1 :                                tools::rgb2hsl(maMagenta) == BColor(300,1,0.5));
    1095           2 :         CPPUNIT_ASSERT_MESSAGE("cyan",
    1096           1 :                                tools::rgb2hsl(maCyan) == BColor(180,1,0.5));
    1097           2 :         CPPUNIT_ASSERT_MESSAGE("third hue case",
    1098           1 :                                tools::rgb2hsl(BColor(0,0.5,1)) == BColor(210,1,0.5));
    1099             : 
    1100           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip white",
    1101           1 :                                tools::hsl2rgb(tools::rgb2hsl(maWhite)) == maWhite);
    1102           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip black",
    1103           1 :                                tools::hsl2rgb(tools::rgb2hsl(maBlack)) == maBlack);
    1104           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip red",
    1105           1 :                                tools::hsl2rgb(tools::rgb2hsl(maRed)) == maRed);
    1106           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip green",
    1107           1 :                                tools::hsl2rgb(tools::rgb2hsl(maGreen)) == maGreen);
    1108           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip blue",
    1109           1 :                                tools::hsl2rgb(tools::rgb2hsl(maBlue)) == maBlue);
    1110           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip yellow",
    1111           1 :                                tools::hsl2rgb(tools::rgb2hsl(maYellow)) == maYellow);
    1112           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip magenta",
    1113           1 :                                tools::hsl2rgb(tools::rgb2hsl(maMagenta)) == maMagenta);
    1114           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip cyan",
    1115           1 :                                tools::hsl2rgb(tools::rgb2hsl(maCyan)) == maCyan);
    1116             : 
    1117           2 :         CPPUNIT_ASSERT_MESSAGE("grey10",
    1118           1 :                                tools::rgb2hsl(maWhite*.1) == BColor(0,0,.1));
    1119           2 :         CPPUNIT_ASSERT_MESSAGE("grey90",
    1120           1 :                                tools::rgb2hsl(maWhite*.9) == BColor(0,0,.9));
    1121           2 :         CPPUNIT_ASSERT_MESSAGE("red/2",
    1122           1 :                                tools::rgb2hsl(maRed*.5) == BColor(0,1,0.25));
    1123           2 :         CPPUNIT_ASSERT_MESSAGE("green/2",
    1124           1 :                                tools::rgb2hsl(maGreen*.5) == BColor(120,1,0.25));
    1125           2 :         CPPUNIT_ASSERT_MESSAGE("blue/2",
    1126           1 :                                tools::rgb2hsl(maBlue*.5) == BColor(240,1,0.25));
    1127           2 :         CPPUNIT_ASSERT_MESSAGE("yellow/2",
    1128           1 :                                tools::rgb2hsl(maYellow*.5) == BColor(60,1,0.25));
    1129           2 :         CPPUNIT_ASSERT_MESSAGE("magenta/2",
    1130           1 :                                tools::rgb2hsl(maMagenta*.5) == BColor(300,1,0.25));
    1131           2 :         CPPUNIT_ASSERT_MESSAGE("cyan/2",
    1132           1 :                                tools::rgb2hsl(maCyan*.5) == BColor(180,1,0.25));
    1133             : 
    1134           2 :         CPPUNIT_ASSERT_MESSAGE("pastel",
    1135           1 :                                tools::rgb2hsl(BColor(.75,.25,.25)) == BColor(0,.5,.5));
    1136           1 :     }
    1137             : 
    1138             :     // insert your test code here.
    1139           1 :     void hsvTest()
    1140             :     {
    1141           2 :         CPPUNIT_ASSERT_MESSAGE("white",
    1142           1 :                                tools::rgb2hsv(maWhite) == BColor(0,0,1));
    1143           2 :         CPPUNIT_ASSERT_MESSAGE("black",
    1144           1 :                                tools::rgb2hsv(maBlack) == BColor(0,0,0));
    1145           2 :         CPPUNIT_ASSERT_MESSAGE("red",
    1146           1 :                                tools::rgb2hsv(maRed) == BColor(0,1,1));
    1147           2 :         CPPUNIT_ASSERT_MESSAGE("green",
    1148           1 :                                tools::rgb2hsv(maGreen) == BColor(120,1,1));
    1149           2 :         CPPUNIT_ASSERT_MESSAGE("blue",
    1150           1 :                                tools::rgb2hsv(maBlue) == BColor(240,1,1));
    1151           2 :         CPPUNIT_ASSERT_MESSAGE("yellow",
    1152           1 :                                tools::rgb2hsv(maYellow) == BColor(60,1,1));
    1153           2 :         CPPUNIT_ASSERT_MESSAGE("magenta",
    1154           1 :                                tools::rgb2hsv(maMagenta) == BColor(300,1,1));
    1155           2 :         CPPUNIT_ASSERT_MESSAGE("cyan",
    1156           1 :                                tools::rgb2hsv(maCyan) == BColor(180,1,1));
    1157             : 
    1158           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip white",
    1159           1 :                                tools::hsv2rgb(tools::rgb2hsv(maWhite)) == maWhite);
    1160           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip black",
    1161           1 :                                tools::hsv2rgb(tools::rgb2hsv(maBlack)) == maBlack);
    1162           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip red",
    1163           1 :                                tools::hsv2rgb(tools::rgb2hsv(maRed)) == maRed);
    1164           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip green",
    1165           1 :                                tools::hsv2rgb(tools::rgb2hsv(maGreen)) == maGreen);
    1166           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip blue",
    1167           1 :                                tools::hsv2rgb(tools::rgb2hsv(maBlue)) == maBlue);
    1168           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip yellow",
    1169           1 :                                tools::hsv2rgb(tools::rgb2hsv(maYellow)) == maYellow);
    1170           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip magenta",
    1171           1 :                                tools::hsv2rgb(tools::rgb2hsv(maMagenta)) == maMagenta);
    1172           2 :         CPPUNIT_ASSERT_MESSAGE("roundtrip cyan",
    1173           1 :                                tools::hsv2rgb(tools::rgb2hsv(maCyan)) == maCyan);
    1174             : 
    1175           2 :         CPPUNIT_ASSERT_MESSAGE("grey10",
    1176           1 :                                tools::rgb2hsv(maWhite*.1) == BColor(0,0,.1));
    1177           2 :         CPPUNIT_ASSERT_MESSAGE("grey90",
    1178           1 :                                tools::rgb2hsv(maWhite*.9) == BColor(0,0,.9));
    1179           2 :         CPPUNIT_ASSERT_MESSAGE("red/2",
    1180           1 :                                tools::rgb2hsv(maRed*.5) == BColor(0,1,0.5));
    1181           2 :         CPPUNIT_ASSERT_MESSAGE("green/2",
    1182           1 :                                tools::rgb2hsv(maGreen*.5) == BColor(120,1,0.5));
    1183           2 :         CPPUNIT_ASSERT_MESSAGE("blue/2",
    1184           1 :                                tools::rgb2hsv(maBlue*.5) == BColor(240,1,0.5));
    1185           2 :         CPPUNIT_ASSERT_MESSAGE("yellow/2",
    1186           1 :                                tools::rgb2hsv(maYellow*.5) == BColor(60,1,0.5));
    1187           2 :         CPPUNIT_ASSERT_MESSAGE("magenta/2",
    1188           1 :                                tools::rgb2hsv(maMagenta*.5) == BColor(300,1,0.5));
    1189           2 :         CPPUNIT_ASSERT_MESSAGE("cyan/2",
    1190           1 :                                tools::rgb2hsv(maCyan*.5) == BColor(180,1,0.5));
    1191             : 
    1192           2 :         CPPUNIT_ASSERT_MESSAGE("pastel",
    1193           1 :                                tools::rgb2hsv(BColor(.5,.25,.25)) == BColor(0,.5,.5));
    1194           1 :     }
    1195             : 
    1196           1 :     void ciexyzTest()
    1197             :     {
    1198           1 :         tools::rgb2ciexyz(maWhite);
    1199           1 :         tools::rgb2ciexyz(maBlack);
    1200           1 :         tools::rgb2ciexyz(maRed);
    1201           1 :         tools::rgb2ciexyz(maGreen);
    1202           1 :         tools::rgb2ciexyz(maBlue);
    1203           1 :         tools::rgb2ciexyz(maYellow);
    1204           1 :         tools::rgb2ciexyz(maMagenta);
    1205           1 :         tools::rgb2ciexyz(maCyan);
    1206           1 :     }
    1207             : 
    1208             :     // Change the following lines only, if you add, remove or rename
    1209             :     // member functions of the current class,
    1210             :     // because these macros are need by auto register mechanism.
    1211             : 
    1212           2 :     CPPUNIT_TEST_SUITE(bcolor);
    1213           1 :     CPPUNIT_TEST(hslTest);
    1214           1 :     CPPUNIT_TEST(hsvTest);
    1215           1 :     CPPUNIT_TEST(ciexyzTest);
    1216           5 :     CPPUNIT_TEST_SUITE_END();
    1217             : }; // class b2dvector
    1218             : 
    1219           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dsvgdimpex);
    1220           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2drange);
    1221           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolyrange);
    1222           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhommatrix);
    1223           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpoint);
    1224           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygon);
    1225           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygontools);
    1226           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolypolygon);
    1227           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b1Xrange);
    1228           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2Xrange);
    1229           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2ibox);
    1230           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dtuple);
    1231           1 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::bcolor);
    1232             : } // namespace basegfx2d
    1233             : 
    1234           4 : CPPUNIT_PLUGIN_IMPLEMENT();
    1235             : 
    1236             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11