| Tomaž Vajngerl | dfc4d2b | 2019-01-28 19:54:51 +0100 | [diff] [blame] | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| Michael Meeks | d037b81 | 2026-03-26 15:06:16 +0000 | [diff] [blame] | 3 | * This file is part of the Collabora Office project. |
| Tomaž Vajngerl | dfc4d2b | 2019-01-28 19:54:51 +0100 | [diff] [blame] | 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> |
| Tomaž Vajngerl | dfc4d2b | 2019-01-28 19:54:51 +0100 | [diff] [blame] | 23 | |
| 24 | #include <basegfx/range/b2drange.hxx> |
| 25 | #include <basegfx/range/b2irange.hxx> |
| 26 | #include <basegfx/utils/rectcliptools.hxx> |
| 27 | |
| 28 | namespace basegfx |
| 29 | { |
| 30 | class b2Xrange : public CppUnit::TestFixture |
| 31 | { |
| 32 | public: |
| 33 | template <class Type> void implCheck() |
| 34 | { |
| 35 | // cohen sutherland clipping |
| 36 | Type aRange(0, 0, 10, 10); |
| 37 | |
| 38 | CPPUNIT_ASSERT_MESSAGE("(0,0) is outside range!", |
| 39 | utils::getCohenSutherlandClipFlags(B2IPoint(0, 0), aRange) == 0); |
| 40 | CPPUNIT_ASSERT_MESSAGE("(-1,-1) is inside range!", |
| 41 | utils::getCohenSutherlandClipFlags(B2IPoint(-1, -1), aRange) |
| 42 | == (utils::RectClipFlags::LEFT | utils::RectClipFlags::TOP)); |
| 43 | CPPUNIT_ASSERT_MESSAGE("(10,10) is outside range!", |
| 44 | utils::getCohenSutherlandClipFlags(B2IPoint(10, 10), aRange) == 0); |
| 45 | CPPUNIT_ASSERT_MESSAGE("(11,11) is inside range!", |
| 46 | utils::getCohenSutherlandClipFlags(B2IPoint(11, 11), aRange) |
| 47 | == (utils::RectClipFlags::RIGHT | utils::RectClipFlags::BOTTOM)); |
| 48 | } |
| 49 | |
| 50 | void check() |
| 51 | { |
| 52 | implCheck<B2DRange>(); |
| 53 | implCheck<B2IRange>(); |
| 54 | } |
| 55 | |
| 56 | // Change the following lines only, if you add, remove or rename |
| 57 | // member functions of the current class, |
| 58 | // because these macros are need by auto register mechanism. |
| 59 | |
| 60 | CPPUNIT_TEST_SUITE(b2Xrange); |
| 61 | CPPUNIT_TEST(check); |
| 62 | CPPUNIT_TEST_SUITE_END(); |
| 63 | }; // class b2Xrange |
| 64 | |
| 65 | } // namespace basegfx |
| 66 | |
| 67 | CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::b2Xrange); |
| 68 | |
| 69 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |