libjpeg-turbo: upgrade to release 2.1.5.1
[LibreOffice.git] / basegfx / test / VectorTest.cxx
blob680a421231718f55050dbad9c5bbfc9d2d3d07ac
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/TestFixture.h>
21 #include <cppunit/extensions/HelperMacros.h>
23 #include <basegfx/vector/b2dvector.hxx>
25 namespace basegfx
27 class VectorTest : public CppUnit::TestFixture
29 public:
30 void testCross()
32 B2DVector aVector(1.0, 1.0);
33 double aResult = aVector.cross(B2DVector(1.0, 1.0));
34 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, aResult, 1E-12);
37 void testScalar()
40 B2DVector aVector(1.0, 1.0);
41 double aResult = aVector.scalar(B2DVector(1.0, 1.0));
42 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0, aResult, 1E-12);
45 B2IVector aVector(1, 1);
46 double aResult = aVector.scalar(B2IVector(1, 1));
47 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0, aResult, 1E-12);
51 void testSetLength()
54 B2DVector aVector(1.0, 1.0);
55 aVector = aVector.setLength(std::sqrt(2.0));
56 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, aVector.getX(), 1E-12);
57 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, aVector.getY(), 1E-12);
60 B2IVector aVector(1, 1);
61 aVector = aVector.setLength(std::sqrt(2.0));
62 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aVector.getX());
63 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aVector.getY());
67 void testGetLength()
69 B2DVector aVector(1.0, 1.0);
70 CPPUNIT_ASSERT_DOUBLES_EQUAL(std::sqrt(2.0), aVector.getLength(), 1E-12);
73 CPPUNIT_TEST_SUITE(VectorTest);
74 CPPUNIT_TEST(testCross);
75 CPPUNIT_TEST(testScalar);
76 CPPUNIT_TEST(testSetLength);
77 CPPUNIT_TEST(testGetLength);
78 CPPUNIT_TEST_SUITE_END();
81 } // namespace basegfx
83 CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::VectorTest);
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */