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

Generated by: LCOV version 1.10