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
|
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "Point.h"
#include "TestPoint.h"
#include <iostream>
#include <cmath>
using namespace std;
CPPUNIT_TEST_SUITE_REGISTRATION (TestPoint);
TestPoint::TestPoint(){}
TestPoint::~TestPoint(){}
void TestPoint::setUp(void)
{
PointA=new Point();
PointB=new Point(1.0,1.0);
PointC=new Point(2.5,2.5);
}
void TestPoint::tearDown(void)
{
delete PointA;
delete PointB;
delete PointC;
}
void TestPoint:: testx(void){
cout<<" CPPUNIT_ASSERT_EQUAL( 0.0, PointA->x()) "<<endl;
CPPUNIT_ASSERT_EQUAL( 0.0, PointA->x());
//If I uncomment this output does not show OK, see bewlo
//CPPUNIT_ASSERT_EQUAL( 2.0, PointB->x());
//CPPUNIT_ASSERT_EQUAL( 2.5, PointC->x());
}
void TestPoint:: testy(void){
CPPUNIT_ASSERT_EQUAL( 0.0, PointA->y());
//CPPUNIT_ASSERT_EQUAL( 3.0, PointB->y());
//CPPUNIT_ASSERT_EQUAL( 2.0, PointC->y());
}
void TestPoint:: addTest (void){
Point sum=PointA->add(PointB);
CPPUNIT_ASSERT_EQUAL(1.0,sum.x());
CPPUNIT_ASSERT_EQUAL(1.0,sum.y());
}
void TestPoint:: subTest (void){
Point sub_=PointA->add(PointB);
CPPUNIT_ASSERT_EQUAL(1.0,sub_.x());
CPPUNIT_ASSERT_EQUAL(1.0,sub_.y());
}
void TestPoint::distTest (void){
CPPUNIT_ASSERT_EQUAL( 0.0, PointA->dist(PointA));
CPPUNIT_ASSERT_EQUAL( 1.0, PointB->dist(PointB));
CPPUNIT_ASSERT_EQUAL( 2.0, PointC->dist(PointC));
}
|