Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/Tests/OgreMain/src/VectorTests.cpp @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 3.3 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus 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
35CPPUNIT_TEST_SUITE_REGISTRATION( VectorTests );
36
37using namespace Ogre;
38
39void VectorTests::setUp()
40{
41}
42
43void VectorTests::tearDown()
44{
45}
46
47
48void 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
68void 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
88void 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}
Note: See TracBrowser for help on using the repository browser.