[Cppunit-devel] Segmentation fault
                
                Brought to you by:
                
                    blep
                    
                
            
            
        
        
        
    | 
      
      
      From: drkm <dar...@ya...> - 2003-07-12 02:08:33
      
     | 
|   Hello.
  I adapted the samples in the cookbook, like following, and have at
run time a segmentation fault.  I don't see why.  I use CppUnit 1.8.0,
GCC 3.2 20020818 (prerelease), and Cygwin.  I compiled with
    g++ -o complex.o -c complex.cc -Wall -ansi -pedantic
    g++ -o complex -Wall -lcppunit
  My source :
    #include <functional>
    #include <iostream>
    #include <string>
    #include <cppunit/TestAssert.h>
    #include <cppunit/TestFixture.h>
    #include <cppunit/TestResult.h>
    #include <cppunit/XmlOutputter.h>
    #include <cppunit/extensions/HelperMacros.h>
    #include <cppunit/extensions/TestFactoryRegistry.h>
    #include <cppunit/ui/text/TestRunner.h>
    namespace cu = CppUnit ;
    class Complex
    {
    public:
      friend bool operator==( Complex const & , Complex const & ) ;
      Complex( double r , double i = 0 )
        : real( r )
        , imaginary( i )
      { }
    private:
      double real ;
      double imaginary ;
    } ;
    bool operator==( Complex const & a , Complex const & b )
    {
      std::equal_to< double >       eq ;
      return eq( a.real , b.real ) && eq( a.imaginary , b.imaginary ) ;
    }
    class ComplexNumberTest
      : public cu::TestFixture
    {
      CPPUNIT_TEST_SUITE( ComplexNumberTest ) ;
      CPPUNIT_TEST( testEquality ) ;
      CPPUNIT_TEST_SUITE_END() ;
    public:
      void testEquality()
      {
        CPPUNIT_ASSERT( Complex( 10 , 1 ) == Complex( 10 , 1 ) ) ;
        CPPUNIT_ASSERT( ! ( Complex( 1 , 1 ) == Complex( 2 , 2 ) ) ) ;
      }
    } ;
    CPPUNIT_TEST_SUITE_REGISTRATION( ComplexNumberTest ) ;
    int main()
    {
      cu::TestFactoryRegistry &     registry(
          cu::TestFactoryRegistry::getRegistry()
        ) ;
      cu::TextUi::TestRunner        runner ;
      cu::XmlOutputter              xmlOut( & runner.result() , std::cerr ) ;
      runner.addTest( registry.makeTest() ) ;
      runner.setOutputter( & xmlOut ) ;
      bool                          suceed( runner.run() ) ;
      return suceed ? 0 : 1 ;
    }
  Thanks for any help.
  Regards,
--drkm
 |