source: OGRE/trunk/ogrenew/Tests/OgreMain/src/VectorTests.cpp @ 692

Revision 692, 3.2 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

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-2005 The OGRE Team
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-----------------------------------------------------------------------------
24*/
25#include "VectorTests.h"
26#include "OgreVector2.h"
27#include "OgreVector3.h"
28#include "OgreVector4.h"
29
30// Register the suite
31CPPUNIT_TEST_SUITE_REGISTRATION( VectorTests );
32
33using namespace Ogre;
34
35void VectorTests::setUp()
36{
37}
38
39void VectorTests::tearDown()
40{
41}
42
43
44void VectorTests::testVector2Scaler()
45{
46    CPPUNIT_ASSERT_EQUAL(Vector2(1, 1) + Vector2(2, 2), Vector2(3, 3));
47    CPPUNIT_ASSERT_EQUAL(1 + Vector2(2), Vector2(3, 3));
48    Vector2 v1;
49    v1 = 1;
50    CPPUNIT_ASSERT_EQUAL(v1, Vector2(1, 1));
51    v1 = 0.0;
52    CPPUNIT_ASSERT_EQUAL(v1, Vector2::ZERO);
53    v1 += 3;
54    CPPUNIT_ASSERT_EQUAL(v1, Vector2(3, 3));
55
56    v1 = 3 - Vector2(2);
57    CPPUNIT_ASSERT_EQUAL(v1, Vector2(1));
58    v1 = Vector2(5) - 7;
59    CPPUNIT_ASSERT_EQUAL(v1, Vector2(-2));
60    v1 -= 4;
61    CPPUNIT_ASSERT_EQUAL(v1, Vector2(-6));
62}
63
64void VectorTests::testVector3Scaler()
65{
66    CPPUNIT_ASSERT_EQUAL(Vector3(1, 1, 1) + Vector3(2, 2, 2), Vector3(3, 3, 3));
67    CPPUNIT_ASSERT_EQUAL(1 + Vector3(2), Vector3(3, 3, 3));
68    Vector3 v1;
69    v1 = 1;
70    CPPUNIT_ASSERT_EQUAL(v1, Vector3(1));
71    v1 = 0.0;
72    CPPUNIT_ASSERT_EQUAL(v1, Vector3::ZERO);
73    v1 += 3;
74    CPPUNIT_ASSERT_EQUAL(v1, Vector3(3));
75
76    v1 = 3 - Vector3(2);
77    CPPUNIT_ASSERT_EQUAL(v1, Vector3(1));
78    v1 = Vector3(5) - 7;
79    CPPUNIT_ASSERT_EQUAL(v1, Vector3(-2));
80    v1 -= 4;
81    CPPUNIT_ASSERT_EQUAL(v1, Vector3(-6));
82}
83
84void VectorTests::testVector4Scaler()
85{
86    CPPUNIT_ASSERT_EQUAL(Vector4(1, 1, 1, 1) + Vector4(2, 2, 2, 2), Vector4(3, 3, 3, 3));
87    CPPUNIT_ASSERT_EQUAL(1 + Vector4(2, 2, 2, 2), Vector4(3, 3, 3, 3));
88    Vector4 v1;
89    v1 = 1;
90    CPPUNIT_ASSERT_EQUAL(v1, Vector4(1, 1, 1, 1));
91    v1 = 0.0;
92    CPPUNIT_ASSERT_EQUAL(v1, Vector4(0,0,0,0));
93    v1 += 3;
94    CPPUNIT_ASSERT_EQUAL(v1, Vector4(3,3,3,3));
95
96    v1 = 3 - Vector4(2,2,2,2);
97    CPPUNIT_ASSERT_EQUAL(v1, Vector4(1,1,1,1));
98    v1 = Vector4(5,5,5,5) - 7;
99    CPPUNIT_ASSERT_EQUAL(v1, Vector4(-2,-2,-2,-2));
100    v1 -= 4;
101    CPPUNIT_ASSERT_EQUAL(v1, Vector4(-6,-6,-6,-6));
102}
Note: See TracBrowser for help on using the repository browser.