Simplify BSTR RAII
[LibreOffice.git] / basegfx / test / B2DPolygonToolsTest.cxx
blob8d9ae4e64bbde1434544ce88e37f16e4c4e463f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <cppunit/TestAssert.h>
21 #include <cppunit/TestFixture.h>
22 #include <cppunit/extensions/HelperMacros.h>
24 #include <basegfx/polygon/b2dpolygontools.hxx>
26 namespace basegfx
28 class b2dpolygontools : public CppUnit::TestFixture
30 public:
31 // insert your test code here.
32 // this is only demonstration code
33 void testIsRectangle()
35 B2DPolygon aRect1(utils::createPolygonFromRect(B2DRange(0, 0, 1, 1)));
37 B2DPolygon aRect2{ { 0, 0 }, { 1, 0 }, { 1, 0.5 }, { 1, 1 }, { 0, 1 } };
38 aRect2.setClosed(true);
40 B2DPolygon aNonRect1{ { 0, 0 }, { 1, 0 }, { 0.5, 1 }, { 0.5, 0 } };
41 aNonRect1.setClosed(true);
43 B2DPolygon aNonRect2{ { 0, 0 }, { 1, 1 }, { 1, 0 }, { 0, 1 } };
44 aNonRect2.setClosed(true);
46 B2DPolygon aNonRect3{ { 0, 0 }, { 1, 0 }, { 1, 1 } };
47 aNonRect3.setClosed(true);
49 B2DPolygon aNonRect4{ { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 } };
51 B2DPolygon aNonRect5{ { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 } };
52 aNonRect5.setControlPoints(1, B2DPoint(1, 0), B2DPoint(-11, 0));
53 aNonRect5.setClosed(true);
55 CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 1",
56 utils::isRectangle(aRect1));
57 CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 2",
58 utils::isRectangle(aRect2));
59 CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 1",
60 !utils::isRectangle(aNonRect1));
61 CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 2",
62 !utils::isRectangle(aNonRect2));
63 CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 3",
64 !utils::isRectangle(aNonRect3));
65 CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 4",
66 !utils::isRectangle(aNonRect4));
67 CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 5",
68 !utils::isRectangle(aNonRect5));
71 // Change the following lines only, if you add, remove or rename
72 // member functions of the current class,
73 // because these macros are need by auto register mechanism.
75 CPPUNIT_TEST_SUITE(b2dpolygontools);
76 CPPUNIT_TEST(testIsRectangle);
77 CPPUNIT_TEST_SUITE_END();
78 }; // class b2dpolygontools
80 } // namespace basegfx
82 CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::b2dpolygontools);
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */