KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_vector3.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
29
30// Code under test
31#include <math/vector3.h>
32
36BOOST_AUTO_TEST_SUITE( VECTOR3TESTS )
37
38BOOST_AUTO_TEST_CASE( test_cross_product, *boost::unit_test::tolerance( 0.000001 ) )
39{
40 VECTOR3I v1( 0, 1, 2 );
41 VECTOR3I v2( 2, 1, 0 );
42
43 BOOST_CHECK( v1.Cross( v2 ) == VECTOR3I(-2, 4 ,-2) );
44}
45
46BOOST_AUTO_TEST_CASE( test_dot_product, *boost::unit_test::tolerance( 0.000001 ) )
47{
48 VECTOR3I v1( 0, 1, 2 );
49 VECTOR3I v2( 2, 1, 0 );
50
51 BOOST_CHECK( v1.Dot( v2 ) == 1 );
52}
53
54BOOST_AUTO_TEST_CASE( test_equality_ops, *boost::unit_test::tolerance( 0.000001 ) )
55{
56 VECTOR3I v1( 1, 1, 1 );
57 VECTOR3I v2( 2, 2, 2 );
58 VECTOR3I v3( 1, 1, 1 );
59
62}
63
64BOOST_AUTO_TEST_CASE( test_scalar_multiply, *boost::unit_test::tolerance( 0.000001 ) )
65{
66 VECTOR3I v1( 1, 1, 1 );
67
68 v1 *= 5;
69
70 BOOST_CHECK( v1 == VECTOR3( 5, 5, 5 ) );
71}
72
73BOOST_AUTO_TEST_CASE( test_scalar_divide, *boost::unit_test::tolerance( 0.000001 ) )
74{
75 VECTOR3I v1( 5, 5, 5 );
76
77 v1 /= 5;
78
79 BOOST_CHECK( v1 == VECTOR3( 1, 1, 1 ) );
80}
81
82
83BOOST_AUTO_TEST_SUITE_END()
Define a general 3D-vector.
Definition: vector3.h:54
BOOST_AUTO_TEST_CASE(ConvertToKicadUnit)
Test conversation from Altium internal units into KiCad internal units.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
VECTOR3I v2(2, 1, 0)
Test suite for KiCad math code.
BOOST_CHECK(v1.Cross(v2)==VECTOR3I(-2, 4,-2))
v1
VECTOR3I v3(1, 1, 1)