#pragma once #include class IPort { public: virtual unsigned char inb(unsigned short) const = 0; virtual void outb(unsigned char, unsigned short) const = 0; }; class MockPort : public IPort { public: MOCK_METHOD(unsigned char, inb, (unsigned short), (const, override)); MOCK_METHOD(void, outb, (unsigned char, unsigned short), (const, override)); }; static std::unique_ptr mockPort; // mock free functions extern "C" { unsigned char inb(unsigned short v) { EXPECT_TRUE(mockPort) << "MockPort was not set up by the test fixture"; return mockPort->inb(v); } void outb(unsigned char p, unsigned short v) { EXPECT_TRUE(mockPort) << "MockPort was not set up by the test fixture"; return mockPort->outb(p, v); } }