1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include "FTPoint.h"
class FTPointTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE( FTPointTest);
CPPUNIT_TEST( testConstructor);
CPPUNIT_TEST( testOperatorEqual);
CPPUNIT_TEST( testOperatorNotEqual);
CPPUNIT_TEST( testOperatorPlusEquals);
CPPUNIT_TEST_SUITE_END();
public:
FTPointTest() : CppUnit::TestCase( "FTPoint Test")
{}
FTPointTest( const std::string& name) : CppUnit::TestCase(name) {}
void testConstructor()
{
FTPoint point1;
CPPUNIT_ASSERT( point1.x == 0.0f);
CPPUNIT_ASSERT( point1.y == 0.0f);
CPPUNIT_ASSERT( point1.z == 0.0f);
FTPoint point2( 1.0f, 2.0f, 3.0f);
CPPUNIT_ASSERT( point2.x == 1.0f);
CPPUNIT_ASSERT( point2.y == 2.0f);
CPPUNIT_ASSERT( point2.z == 3.0f);
FT_Vector ftVector;
ftVector.x = 4;
ftVector.y = 23;
FTPoint point3( ftVector);
CPPUNIT_ASSERT( point3.x == 4.0f);
CPPUNIT_ASSERT( point3.y == 23.0f);
CPPUNIT_ASSERT( point3.z == 0.0f);
}
void testOperatorEqual()
{
FTPoint point1( 1.0f, 2.0f, 3.0f);
FTPoint point2( 1.0f, 2.0f, 3.0f);
FTPoint point3( -1.0f, 2.3f, 23.0f);
CPPUNIT_ASSERT( point1 == point1);
CPPUNIT_ASSERT( point1 == point2);
CPPUNIT_ASSERT( !(point1 == point3));
}
void testOperatorNotEqual()
{
FTPoint point1( 1.0f, 2.0f, 3.0f);
FTPoint point2( 1.0f, 2.0f, 3.0f);
FTPoint point3( -1.0f, 2.3f, 23.0f);
CPPUNIT_ASSERT( !(point1 != point1));
CPPUNIT_ASSERT( !(point1 != point2));
CPPUNIT_ASSERT( point1 != point3);
}
void testOperatorPlusEquals()
{
FTPoint point1( 1.0f, 2.0f, 3.0f);
FTPoint point2( -2.0f, 21.0f, 0.0f);
FTPoint point3( -1.0f, 23.0f, 3.0f);
point1 += point2;
CPPUNIT_ASSERT( point1 == point3);
}
void setUp()
{}
void tearDown()
{}
private:
};
CPPUNIT_TEST_SUITE_REGISTRATION( FTPointTest);