#46 test suite helper macros wrong

-- deleted --
closed-fixed
5
2002-06-15
2002-06-06
Anonymous
No

When using the helper macros to create a test suite,
the test names are given incorrect names. For the
following macros:

CPPUNIT_TEST_SUITE(PointTest);
CPPUNIT_TEST(testEquality);
CPPUNIT_TEST(testMidpoint);
CPPUNIT_TEST(testOverflow);
CPPUNIT_TEST_SUITE_END();

the tests are named "9PointTest.testEquality",
"9PointTest.testMidpoint", and
"9PointTest.testOverflow". When I build the suite
manually, the test names are correct:

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

produces the expected names "PointTest.testEquality,
"PointTest.testMidpoint", and "PointTest.testOverflow"
without the 9's.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    The compiler I'm using is gcc 3.0.4, and the OS is IRIX 6.5.

     
  • Baptiste Lepilleur

    Logged In: YES
    user_id=196852

    Is CppUnit configured to use RTTI ?
    => What are the values of:
    CPPUNIT_HAVE_RTTI
    CPPUNIT_USE_TYPEINFO_NAME
    in your config-auto.h file ?

    Baptiste.

     
  • Nobody/Anonymous

    Logged In: NO

    Yes, CPPUNIT_HAVE_RTTI is 1, and
    CPPUNIT_USE_TYPEINFO_NAME is 1. The same problem
    is happening under linux with gcc 3.1.

     
  • Baptiste Lepilleur

    Logged In: YES
    user_id=196852

    Unfortunately this does not help much.
    I need the value of the symbol indicated below to know if test
    name are generated using RTTI or macro.

    Those can be found in include/cppunit/config-auto.h in the
    place where cppunit was installed.

    Baptiste.

     
  • Nobody/Anonymous

    Logged In: NO

    This is the line in my config-auto.h

    #define CPPUNIT_USE_TYPEINFO_NAME
    CPPUNIT_HAVE_RTTI

     
  • Baptiste Lepilleur

    • assigned_to: nobody --> blep
     
  • Baptiste Lepilleur

    Logged In: YES
    user_id=196852

    Well, it's seems to be a gcc RTTI issue. Could you compile
    the following code and give me the output (to see what is gcc
    3.0 RTTI name format):

    #include <typeinfo>

    class Dummy
    {
    };

    void main()
    {
    printf( "1) %s\n", typeid( Dummy ).name() );
    printf( "2) %s\n", typeid( int ).name() );
    }

     
  • Nobody/Anonymous

    Logged In: NO

    Running the code you gave me results in this:

    1) 5Dummy
    2) i

    I get the same results for gcc 2.95 and gcc 3.1

     
  • Baptiste Lepilleur

    Logged In: YES
    user_id=196852

    AH, we finally got it. It is a gcc 3.0 bug. type_info::name is
    supposed a clean string representing the type. Including the
    length of the type in the string clearly does not fit the bill. It
    should be reported as a gcc bug (and int should probably be
    returned as 'int' instead of 'i').

    In the mean time, you can disable the use for type_info with
    --disable-typeinfo-name (see install-unix for details).

    I'll add a work around in cppunit to skip the numeric character
    at the beginning of the type string.

    Thanks,
    Baptiste.

     
  • Baptiste Lepilleur

    • status: open --> open-remind
     
  • Baptiste Lepilleur

    • milestone: --> -- deleted --
    • status: open-remind --> closed-fixed
     
  • Baptiste Lepilleur

    Logged In: YES
    user_id=196852

    I added the work around. It is available in the current CVS
    version.

    Baptiste.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks