Hi,
I am using CppUnit 1.12.0 version on Linux. When I tried to run the programs provided in CppCookbook I am getting errors. Cam Someone please help me?? You can find the programs I tried below:
Complex.cpp -------------
class Complex { friend bool operator ==(const Complex& a, const Complex& b); double real, imaginary; public: Complex( double r, double i = 0 ) : real(r) , imaginary(i) { } };
bool operator ==( const Complex &a, const Complex &b ) { return (a.real== b.real ) && ( a.imaginary== b.imaginary ); } --------------------------------------------------------------------------
ComplexNumberTest.cpp -----------------------
#include "Complex.cpp" #include <cppunit/TestCase.h>
class ComplexNumberTest : public CppUnit::TestCase { public: ComplexNumberTest( std::string name ) : CppUnit::TestCase( name ) {} void runTest() { CPPUNIT_ASSERT( Complex (10, 1) == Complex (10, 1) ); CPPUNIT_ASSERT( !(Complex (1, 1) == Complex (2, 2)) ); } };
int main()
{
ComplexNumberTest obj1("test1"); obj1.runTest(); return 0; }
=============================================================================== After this if I ececute, the below command:
g++ ComplexNumberTest.cpp
I am getting errorrs.
Thanks in Advance.
Regards, Kimo
What are the exact error messages?
Log in to post a comment.
Hi,
I am using CppUnit 1.12.0 version on Linux. When I tried to run the programs provided in CppCookbook I am getting errors. Cam Someone please help me??
You can find the programs I tried below:
Complex.cpp
-------------
class Complex {
friend bool operator ==(const Complex& a, const Complex& b);
double real, imaginary;
public:
Complex( double r, double i = 0 )
: real(r)
, imaginary(i)
{
}
};
bool operator ==( const Complex &a, const Complex &b )
{
return (a.real== b.real ) && ( a.imaginary== b.imaginary );
}
--------------------------------------------------------------------------
ComplexNumberTest.cpp
-----------------------
#include "Complex.cpp"
#include <cppunit/TestCase.h>
class ComplexNumberTest : public CppUnit::TestCase {
public:
ComplexNumberTest( std::string name ) : CppUnit::TestCase( name ) {}
void runTest()
{
CPPUNIT_ASSERT( Complex (10, 1) == Complex (10, 1) );
CPPUNIT_ASSERT( !(Complex (1, 1) == Complex (2, 2)) );
}
};
int main()
{
ComplexNumberTest obj1("test1");
obj1.runTest();
return 0;
}
===============================================================================
After this if I ececute, the below command:
g++ ComplexNumberTest.cpp
I am getting errorrs.
Thanks in Advance.
Regards,
Kimo
What are the exact error messages?