Skip to content

Incorrectly parsing of derived class  #1

@kindkaktus

Description

@kindkaktus

cxxtest has difficulties parsing derived classes. Consider the following code:

#include "cxxtest/TestSuite.h"

class MyTestBase : public CxxTest::TestSuite 
{};

class MyTest : public MyTestBase
{
public:
    void test1()
    {}
};

class MyTest2 : public MyTestBase
{
public:
    void test2()
    {}
};

After calling
python-2.7\python cxxtest\bin\cxxtestgen --have-eh --have-std --part -o mytest.cpp MyTest.h

The generated mytest.cpp erroneously creates test1() test case for MyTest2 suite, which obviously results in compilation error "error C2039: 'test1' : is not a member of 'MyTest2'" later on. Below is a generated mytest.cpp

include "MyTest.h"

static MyTest suite_MyTest;

static CxxTest::List Tests_MyTest = { 0, 0 };
CxxTest::StaticSuiteDescription suiteDescription_MyTest( "MyTest.h", 10, "MyTest", suite_MyTest, Tests_MyTest );

static class TestDescription_suite_MyTest_test1 : public CxxTest::RealTestDescription {
public:
 TestDescription_suite_MyTest_test1() : CxxTest::RealTestDescription( Tests_MyTest, suiteDescription_MyTest, 13, "test1" ) {}
 void runTest() { suite_MyTest.test1(); }
} testDescription_suite_MyTest_test1;

static MyTest2 suite_MyTest2;

static CxxTest::List Tests_MyTest2 = { 0, 0 };
CxxTest::StaticSuiteDescription suiteDescription_MyTest2( "MyTest.h", 18, "MyTest2", suite_MyTest2, Tests_MyTest2 );

static class TestDescription_suite_MyTest2_test1 : public CxxTest::RealTestDescription {
public:
 TestDescription_suite_MyTest2_test1() : CxxTest::RealTestDescription( Tests_MyTest2, suiteDescription_MyTest2, 13, "test1" ) {}
 void runTest() { suite_MyTest2.test1(); }
} testDescription_suite_MyTest2_test1;

static class TestDescription_suite_MyTest2_test2 : public CxxTest::RealTestDescription {
public:
 TestDescription_suite_MyTest2_test2() : CxxTest::RealTestDescription( Tests_MyTest2, suiteDescription_MyTest2, 21, "test2" ) {}
 void runTest() { suite_MyTest2.test2(); }
} testDescription_suite_MyTest2_test2;

Renaming MyTest to MyNewTest makes the problem go.

What I found remarkable for the same version of Python (2.7.3) the issue shows up on Windows only, not on Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions