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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
23
25
26// Code under test
27#include <math/vector3.h>
28
32BOOST_AUTO_TEST_SUITE( VECTOR3TESTS )
33
34BOOST_AUTO_TEST_CASE( test_cross_product, *boost::unit_test::tolerance( 0.000001 ) )
35{
36 VECTOR3I v1( 0, 1, 2 );
37 VECTOR3I v2( 2, 1, 0 );
38
39 BOOST_TEST( v1.Cross( v2 ) == VECTOR3I( -2, 4, -2 ) );
40}
41
42BOOST_AUTO_TEST_CASE( test_dot_product, *boost::unit_test::tolerance( 0.000001 ) )
43{
44 VECTOR3I v1( 0, 1, 2 );
45 VECTOR3I v2( 2, 1, 0 );
46
47 BOOST_TEST( v1.Dot( v2 ) == 1 );
48}
49
50BOOST_AUTO_TEST_CASE( test_equality_ops, *boost::unit_test::tolerance( 0.000001 ) )
51{
52 VECTOR3I v1( 1, 1, 1 );
53 VECTOR3I v2( 2, 2, 2 );
54 VECTOR3I v3( 1, 1, 1 );
55
58}
59
60BOOST_AUTO_TEST_CASE( test_scalar_multiply, *boost::unit_test::tolerance( 0.000001 ) )
61{
62 VECTOR3I v1( 1, 1, 1 );
63
64 v1 *= 5;
65
66 BOOST_TEST( v1 == VECTOR3( 5, 5, 5 ) );
67}
68
69BOOST_AUTO_TEST_CASE( test_scalar_divide, *boost::unit_test::tolerance( 0.000001 ) )
70{
71 VECTOR3I v1( 5, 5, 5 );
72
73 v1 /= 5;
74
75 BOOST_TEST( v1 == VECTOR3( 1, 1, 1 ) );
76}
77
78
Define a general 3D-vector.
Definition vector3.h:55
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST(netlist.find("R_G1 ARM_OUT1 DIE_B R='0.001 / ((SW_STATE)") !=std::string::npos)
VECTOR3I v1(5, 5, 5)
VECTOR2I v2(1, 0)
VECTOR2I v3(-2, 1)
VECTOR3I v2(2, 1, 0)
Test suite for KiCad math code.
VECTOR3I v3(1, 1, 1)
VECTOR3< int > VECTOR3I
Definition vector3.h:231