Debian Codegraph @

src/test/ZMFTypesTest.cpp

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libzmf 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
10 #include <algorithm>
11 #include <vector>
12
13 #include <boost/math/constants/constants.hpp>
14
15 #include <cppunit/TestFixture.h>
16 #include <cppunit/extensions/HelperMacros.h>
17
18 #include <librevenge-stream/librevenge-stream.h>
19
20 #include "ZMFTypes.h"
21
22 namespace test
23 {
24
25 using libzmf::BoundingBox;
26 using libzmf::Point;
27
28 class ZMFTypesTest : public CPPUNIT_NS::TestFixture
29 {
30 public:
31 virtual void setUp() override;
32 virtual void tearDown() override;
33
34 private:
35 CPPUNIT_TEST_SUITE(ZMFTypesTest);
36 CPPUNIT_TEST(testBBoxQuadrants);
37 CPPUNIT_TEST_SUITE_END();
38
39 private:
40 void testBBoxQuadrants();
41 };
42
43 void ZMFTypesTest::setUp()
44 {
45 }
46
47 void ZMFTypesTest::tearDown()
48 {
49 }
50
51 void ZMFTypesTest::testBBoxQuadrants()
52 {
53 std::vector<BoundingBox> bboxes =
54 {
55 BoundingBox({Point(10, 10), Point(12, 10), Point(12, 12), Point(10, 12)}),
56 // current implementation reverses bbox rotation before calculating quadrants,
57 // so the first point will not be on the right side (quadrant 1 or 4) because in these cases it has rotation pi
58 //BoundingBox({Point(12, 10), Point(10, 10), Point(10, 12), Point(12, 12)}),
59 BoundingBox({Point(10, 12), Point(12, 12), Point(12, 10), Point(10, 10)}),
60 //BoundingBox({Point(12, 12), Point(10, 12), Point(10, 10), Point(12, 10)}),
61
62 BoundingBox({Point(10, 10), Point(14, 10), Point(14, 12), Point(10, 12)}),
63 BoundingBox({Point(10, 10), Point(12, 10), Point(12, 14), Point(10, 14)}),
64 };
65 std::vector<int> p1Quadrants =
66 {
67 2,
68 //1,
69 3,
70 //4,
71
72 2,
73 2,
74 };
75 std::vector<int> p2Quadrants =
76 {
77 1,
78 //2,
79 4,
80 //3,
81
82 1,
83 1,
84 };
85
86 for (size_t i = 0; i < bboxes.size(); ++i)
87 {
88 CPPUNIT_ASSERT_EQUAL(p1Quadrants[i], bboxes[i].p1Quadrant());
89 CPPUNIT_ASSERT_EQUAL(p2Quadrants[i], bboxes[i].p2Quadrant());
90 }
91 }
92
93 CPPUNIT_TEST_SUITE_REGISTRATION(ZMFTypesTest);
94
95 }
96
97 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */