Skip to content

Instantly share code, notes, and snippets.

@madprog
Created June 12, 2017 09:19
FakeIt segmentation fault
#include "tpunit++.hpp"
#include "fakeit.hpp"
using namespace fakeit;
struct MyTests : tpunit::TestFixture {
struct Wrapper {
virtual void open_file(const std::string &filename) const = 0;
};
static Mock<Wrapper> wrapper_mock;
static Wrapper &wrapper;
class Configuration {
public:
Configuration() {
wrapper.open_file("path/to/config_file");
}
};
MyTests() :
TestFixture(TEST(MyTests::failure)) {}
void failure() {
When(Method(wrapper_mock, open_file)).Do([=](const std::string &) -> void {
return;
});
Configuration configuration;
Verify(Method(wrapper_mock, open_file).Using("path/to/config_file"));
}
} __MyTests;
Mock<MyTests::Wrapper> MyTests::wrapper_mock;
MyTests::Wrapper &MyTests::wrapper = MyTests::wrapper_mock.get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment