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

Generated by: LCOV version 1.10