blob: 2d03184f9b8b993b338ead467d460116cd181724 [file] [log] [blame]
Tomaž Vajngerldfc4d2b2019-01-28 19:54:51 +01001/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
Michael Meeksd037b812026-03-26 15:06:16 +00003 * This file is part of the Collabora Office project.
Tomaž Vajngerldfc4d2b2019-01-28 19:54:51 +01004 *
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ž Vajngerldfc4d2b2019-01-28 19:54:51 +010023
24#include <basegfx/range/b2drange.hxx>
25#include <basegfx/range/b2irange.hxx>
26#include <basegfx/utils/rectcliptools.hxx>
27
28namespace basegfx
29{
30class b2Xrange : public CppUnit::TestFixture
31{
32public:
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
67CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::b2Xrange);
68
69/* vim:set shiftwidth=4 softtabstop=4 expandtab: */