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
28
#include <
qa_utils/wx_utils/unit_test_utils.h
>
29
30
// Code under test
31
#include <
math/vector3.h
>
32
36
BOOST_AUTO_TEST_SUITE
( VECTOR3TESTS )
37
38
BOOST_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_TEST
(
v1
.Cross(
v2
) ==
VECTOR3I
( -2, 4, -2 ) );
44
}
45
46
BOOST_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_TEST
(
v1
.Dot(
v2
) == 1 );
52
}
53
54
BOOST_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
60
BOOST_TEST
(
v1
==
v3
);
61
BOOST_TEST
(
v1
!=
v2
);
62
}
63
64
BOOST_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_TEST
(
v1
==
VECTOR3
( 5, 5, 5 ) );
71
}
72
73
BOOST_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_TEST
(
v1
==
VECTOR3
( 1, 1, 1 ) );
80
}
81
82
83
BOOST_AUTO_TEST_SUITE_END
()
VECTOR3
Define a general 3D-vector.
Definition:
vector3.h:55
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition:
test_api_enums.cpp:131
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
v2
VECTOR3I v2(2, 1, 0)
Test suite for KiCad math code.
BOOST_TEST
BOOST_TEST(v1.Cross(v2)==VECTOR3I(-2, 4, -2))
v1
v1
Definition:
test_vector3.cpp:77
v3
VECTOR3I v3(1, 1, 1)
unit_test_utils.h
vector3.h
src
qa
tests
libs
kimath
math
test_vector3.cpp
Generated on Sun Dec 22 2024 00:05:31 for KiCad PCB EDA Suite by
1.9.6