eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.24k stars 170 forks source link

Test crash when verify on invocation with nullptr passed as C string. #137

Closed OskiKervinen-MF closed 6 years ago

OskiKervinen-MF commented 6 years ago

If you call a mocked method with a char* parameter with the value nullptr, if verifying it fails, the test exe crashes.

Example:

void verificationShouldTolerateNullString(){
        struct RefEater {
            virtual int eatChar(char*) = 0;
        };

        Mock<RefEater> mock;
        When( Method( mock, eatChar ) ).AlwaysReturn( 0 );

        RefEater& obj = mock.get();
        obj.eatChar( nullptr );

        Verify(Method(mock,eatChar)).Exactly(1);
        ASSERT_THROW(Verify(Method(mock, eatChar)).Exactly(3), fakeit::VerificationException); // Crash here.
    }