|
// TestComplex1.cpp: implementation of the CTestComplex class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TestComplex.h"
#include "TestComplex1.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTestComplex::CTestComplex()
{
}
CTestComplex::~CTestComplex()
{
}
void CTestComplex::testAdd()
{
CComplex temp;
temp = *m_p1 + *m_p2;
WCEUNIT_ASSERT(CComplex(30, 70) == temp);
}
void CTestComplex::testEqual()
{
CComplex temp2; //Below test should fail.
WCEUNIT_ASSERT_FAIL(temp2 == *m_p3);
CComplex temp1; //Below test should pass.
temp1 = *m_p1 + *m_p2;
WCEUNIT_ASSERT_EQUALS(temp1, *m_p3);
//To check the equality of the real and imaginary members.
WCEUNIT_DOUBLE_EQUALS(temp1.GetReal(), m_p3->GetReal());
WCEUNIT_DOUBLE_EQUALS(temp1.GetImaginary(), m_p3->GetImaginary());
}
void CTestComplex::testException()
{
//This fuction is only to demonstrate the exception test.
//It throws CUserException. This test will fail as the expected exception
//is CFileException.
CUserException e;
THROW(&e);
}
void CTestComplex::InitializeTest()
{
m_p1 = new CComplex(10, 20);
m_p2 = new CComplex(20, 50);
m_p3 = new CComplex(30, 70);
}
void CTestComplex::CleanUpTest()
{
delete m_p1;
delete m_p2;
delete m_p3;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
A person who like to know about new things, peolple and make frineds. I strarted programming in 2000 with fortran but my first love in programming is C++. Also programmed in VB, MFC and for Windows CE.
Graduated in Physics and done masteres in Computer application. Physics and astronomy are my area of intrest. Karate is also one of my hobbies, BTW I am a Black Belt in Karate.