keeganwitt / gmock

Automatically exported from code.google.com/p/gmock
6 stars 2 forks source link

EXPECT_CALL leads to "unknown file:error: SEH exception with code 0xc0000005 thrown in the test body" #133

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Try to mock the function of a class
using ::testing::Return;
using ::testing::Test;
using ::testing::NiceMock;

class OsInterfaceCPP
{  

public: 

    OsInterfaceCPP(void){};
    virtual ~OsInterfaceCPP(void){};
    virtual int add_test(int a, int b) = 0;
    int calladdtest(int aa, int bb)
    {
        return add_test(aa,bb);
    }
};  
class OsCPPApis : public OsInterfaceCPP 
{  
public: 
    OsCPPApis(void){};
    virtual ~OsCPPApis(void){};
    virtual int add_test(int aa, int bb)
    {
        return (aa+bb);
    }
};

class MockedOSCPPApis : public  OsCPPApis
{
public:
    MockedOSCPPApis(void){};
    virtual ~MockedOSCPPApis(void){};
    MOCK_METHOD2(add_test, int(int aaa, int bbb));
};

OSapiTestFunc::OSapiTestFunc(void){}

OSapiTestFunc::~OSapiTestFunc(void){}

void OSapiTestFunc::SetUp(){}

void OSapiTestFunc::TearDown(){}

void OSapiTestFunc::RunTests()
{
    int argc=0;
    char **argv = 0;
    ::testing::InitGoogleMock(&argc, argv); 

}

TEST_F(OSapiTestFunc, OS_Test1)
{

    OsCPPApis TestOscppapis;
    MockedOSCPPApis Testmockosapi;
    int a, b;
    a = 2;
    b = 5;
    bool test1var = true;
    EXPECT_CALL(Testmockosapi,add_test(a, b));

    TestOscppapis.add_test(5,3);
}

2. My project has multiple threads, one of the thread call RUN_ALL_TESTS
3. The above code leased to SEH exception
tools: VS2010, windows 7 

Original issue reported on code.google.com by hussain....@gmail.com on 28 Dec 2012 at 10:02

GoogleCodeExporter commented 8 years ago
You are talking about googlemock, not gmock.

Original comment by JohnnyJianHY on 19 Feb 2013 at 11:42