MockIO

MockIO might seem like a mysterious thing. You might think that it’s extra work that won’t be needed and just takes time from the production code. Let’s clear up some of the mystery around MockIO and look at its full interface and some of its implementation. I hope you will see that it’s not that much trouble.

MockIO’s public interface consists of the usual create/destroy functions, along with the functions for programming the expectations and assuring that all expectations are met.

mocks/MockIO.h
 
#ifndef D_MockIO_H
 
#define D_MockIO_H
 
#include "IO.h"
 
void​ MockIO_Create(​int​ maxExpectations);
 
void​ MockIO_Destroy(​void​);
 
void​ MockIO_Expect_Write(ioAddress offset, ioData data);
 
void​ MockIO_Expect_ReadThenReturn(ioAddress ...

Get Test Driven Development for Embedded C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.