Avoid potential negative array index access to cached text.
[LibreOffice.git] / basegfx / test / B2XRangeTest.cxx
blob0a7c9930e782aa4033b1ea2c3d989796f5a4e8df
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/range/b2drange.hxx>
25 #include <basegfx/range/b2irange.hxx>
26 #include <basegfx/utils/rectcliptools.hxx>
28 namespace basegfx
30 class b2Xrange : public CppUnit::TestFixture
32 public:
33 template <class Type> void implCheck()
35 // cohen sutherland clipping
36 Type aRange(0, 0, 10, 10);
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));
50 void check()
52 implCheck<B2DRange>();
53 implCheck<B2IRange>();
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.
60 CPPUNIT_TEST_SUITE(b2Xrange);
61 CPPUNIT_TEST(check);
62 CPPUNIT_TEST_SUITE_END();
63 }; // class b2Xrange
65 } // namespace basegfx
67 CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::b2Xrange);
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */