Hello
SPC sent you a page for the C API for mocking. But I think your question is more about substituting test-doubles. In C you have fewer choices for substituting test-doubles into your program for test. Options are:
You can find a lot about this in my book.
Even when mocking C, I never use the C-API in CppUMock. I'll write the mock in C++, providing the C linkage (or other) needed. Here's an example:
#include "CppUTestExt/MockSupport.h"
extern "C"
{
#include "IOReadWrite.h"
}
void IOWrite(IOAddress addr, IOData data)
{
mock("IO")
.actualCall("IOWrite")
.withParameter("addr", (int)addr)
.withParameter("data", (int)data);
}
IOData IORead(IOAddress addr)
{
return (IOData)mock("IO")
.actualCall("IORead")
.withParameter("addr", (int)addr)
.returnValue().getIntValue();
}
Hope that helps!
James
p.s. Now for a second shameless plug: I'll be delivering live web delivered TDD training course where we go through the details of linker substitution and mocking (among other things). Here is a link to the course information https://wingman-sw.com/training/remote-delivered-tdd
James Grenning - Author of TDD for Embedded C - wingman-sw.com/tddec
wingman-sw.com
wingman-sw.com/blog
twitter.com/jwgrenning
facebook.com/wingman.sw

--
You received this message because you are subscribed to the Google Groups "cpputest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpputest+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.