Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

newbie: Unable to run my programs on CppUnit

Help
kimo
2006-11-15
2013-04-22
  • kimo
    kimo
    2006-11-15

    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

     
    • Code Guru
      Code Guru
      2006-11-15

      What are the exact error messages?