1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
27 class VectorTest
: public CppUnit::TestFixture
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);
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);
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());
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: */