1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org/ |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #include "VectorTests.h" |
---|
30 | #include "OgreVector2.h" |
---|
31 | #include "OgreVector3.h" |
---|
32 | #include "OgreVector4.h" |
---|
33 | |
---|
34 | // Register the suite |
---|
35 | CPPUNIT_TEST_SUITE_REGISTRATION( VectorTests ); |
---|
36 | |
---|
37 | using namespace Ogre; |
---|
38 | |
---|
39 | void VectorTests::setUp() |
---|
40 | { |
---|
41 | } |
---|
42 | |
---|
43 | void VectorTests::tearDown() |
---|
44 | { |
---|
45 | } |
---|
46 | |
---|
47 | |
---|
48 | void VectorTests::testVector2Scaler() |
---|
49 | { |
---|
50 | CPPUNIT_ASSERT_EQUAL(Vector2(1, 1) + Vector2(2, 2), Vector2(3, 3)); |
---|
51 | CPPUNIT_ASSERT_EQUAL(1 + Vector2(2), Vector2(3, 3)); |
---|
52 | Vector2 v1; |
---|
53 | v1 = 1; |
---|
54 | CPPUNIT_ASSERT_EQUAL(v1, Vector2(1, 1)); |
---|
55 | v1 = 0.0; |
---|
56 | CPPUNIT_ASSERT_EQUAL(v1, Vector2::ZERO); |
---|
57 | v1 += 3; |
---|
58 | CPPUNIT_ASSERT_EQUAL(v1, Vector2(3, 3)); |
---|
59 | |
---|
60 | v1 = 3 - Vector2(2); |
---|
61 | CPPUNIT_ASSERT_EQUAL(v1, Vector2(1)); |
---|
62 | v1 = Vector2(5) - 7; |
---|
63 | CPPUNIT_ASSERT_EQUAL(v1, Vector2(-2)); |
---|
64 | v1 -= 4; |
---|
65 | CPPUNIT_ASSERT_EQUAL(v1, Vector2(-6)); |
---|
66 | } |
---|
67 | |
---|
68 | void VectorTests::testVector3Scaler() |
---|
69 | { |
---|
70 | CPPUNIT_ASSERT_EQUAL(Vector3(1, 1, 1) + Vector3(2, 2, 2), Vector3(3, 3, 3)); |
---|
71 | CPPUNIT_ASSERT_EQUAL(1 + Vector3(2), Vector3(3, 3, 3)); |
---|
72 | Vector3 v1; |
---|
73 | v1 = 1; |
---|
74 | CPPUNIT_ASSERT_EQUAL(v1, Vector3(1)); |
---|
75 | v1 = 0.0; |
---|
76 | CPPUNIT_ASSERT_EQUAL(v1, Vector3::ZERO); |
---|
77 | v1 += 3; |
---|
78 | CPPUNIT_ASSERT_EQUAL(v1, Vector3(3)); |
---|
79 | |
---|
80 | v1 = 3 - Vector3(2); |
---|
81 | CPPUNIT_ASSERT_EQUAL(v1, Vector3(1)); |
---|
82 | v1 = Vector3(5) - 7; |
---|
83 | CPPUNIT_ASSERT_EQUAL(v1, Vector3(-2)); |
---|
84 | v1 -= 4; |
---|
85 | CPPUNIT_ASSERT_EQUAL(v1, Vector3(-6)); |
---|
86 | } |
---|
87 | |
---|
88 | void VectorTests::testVector4Scaler() |
---|
89 | { |
---|
90 | CPPUNIT_ASSERT_EQUAL(Vector4(1, 1, 1, 1) + Vector4(2, 2, 2, 2), Vector4(3, 3, 3, 3)); |
---|
91 | CPPUNIT_ASSERT_EQUAL(1 + Vector4(2, 2, 2, 2), Vector4(3, 3, 3, 3)); |
---|
92 | Vector4 v1; |
---|
93 | v1 = 1; |
---|
94 | CPPUNIT_ASSERT_EQUAL(v1, Vector4(1, 1, 1, 1)); |
---|
95 | v1 = 0.0; |
---|
96 | CPPUNIT_ASSERT_EQUAL(v1, Vector4(0,0,0,0)); |
---|
97 | v1 += 3; |
---|
98 | CPPUNIT_ASSERT_EQUAL(v1, Vector4(3,3,3,3)); |
---|
99 | |
---|
100 | v1 = 3 - Vector4(2,2,2,2); |
---|
101 | CPPUNIT_ASSERT_EQUAL(v1, Vector4(1,1,1,1)); |
---|
102 | v1 = Vector4(5,5,5,5) - 7; |
---|
103 | CPPUNIT_ASSERT_EQUAL(v1, Vector4(-2,-2,-2,-2)); |
---|
104 | v1 -= 4; |
---|
105 | CPPUNIT_ASSERT_EQUAL(v1, Vector4(-6,-6,-6,-6)); |
---|
106 | } |
---|