cppunit - problem z niewlasciwymi testami

0

witam,

spotkaliscie sie moze z problemem kiedy podczas testow jednostkowych program wysypuje sie jedynie wtedy kiedy ktorys z testow jest niepoprawny ( w CPPUNIT_ASSERT( ) podamy false) ?

plik main.cpp

#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>


#include <cppunit/ui/text/TestRunner.h>

#include "ComplexNumberTest.h"

#include <stdio.h>
#include <iostream>
using namespace std;

int
main( int argc, char* argv[] )
{
	CppUnit::TextUi::TestRunner runner;
	  runner.addTest( ComplexNumberTest::suite() );
	  runner.run();
	return 0;
}

plik complexNumberTest.h

#include <cppunit/extensions/HelperMacros.h>
#include "Complex.h"

class ComplexNumberTest : public CppUnit::TestFixture  {
private:
  Complex *m_10_1, *m_1_1, *m_11_2;
public:
  void setUp()
  {
    m_10_1 = new Complex( 10, 1 );
    m_1_1 = new Complex( 1, 1 );
    m_11_2 = new Complex( 11, 2 );
  }

  void tearDown()
  {
    delete m_10_1;
    delete m_1_1;
    delete m_11_2;
  }

  void testEquality()
  {
    CPPUNIT_ASSERT( *m_10_1 == *m_10_1 );
    CPPUNIT_ASSERT( !(*m_10_1 == *m_11_2) );
    CPPUNIT_ASSERT( !(*m_10_1 == *m_11_2) );
    CPPUNIT_ASSERT( !(*m_10_1 == *m_11_2) );
    CPPUNIT_ASSERT( !(*m_10_1 == *m_11_2) );
    CPPUNIT_ASSERT( !(*m_10_1 == *m_11_2) );

  }

  void testAddition()
  {
	  CPPUNIT_ASSERT( (*m_10_1 == *m_11_2) );
  }

public:
  static CppUnit::Test *suite()
  {
    CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "ComplexNumberTest" );
    suiteOfTests->addTest( new CppUnit::TestCaller<ComplexNumberTest>(
                                   "testEquality",
                                   &ComplexNumberTest::testEquality ) );
    suiteOfTests->addTest( new CppUnit::TestCaller<ComplexNumberTest>(
                                   "testAddition",
                                   &ComplexNumberTest::testAddition ) );
    return suiteOfTests;
  }
};

plik complex.h

 
#ifndef COMPLEX_H_
#define COMPLEX_H_


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;
}

#endif /* COMPLEX_H_ */

z gory dzieki za jakiekolwiek wskazowki, bo nawet nie wiem czy wina lezy po stronie kodu czy moze jakos zle cppunita dolaczylem ;/ kod zaczerpniety stad http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html . Kiedy program sie wysypuje wypisuje
"This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."

PS: korzystam z eclipse'a jakby to mialo jakies znaczenie

0

kiedyś korzystałem z cppunita i wszystko mi działało. teraz unit testy piszę w googletest i sobie chwalę

1 użytkowników online, w tym zalogowanych: 0, gości: 1