C function mock get data pointer contents

31 views
Skip to first unread message

Grant Dare

unread,
Nov 3, 2022, 7:29:54 PM11/3/22
to cpputest
Hi!

I am trying to mock a c function which takes a pointer to a data buffer and a length and then writes this to eeprom. I want to be able to check the data that was passed into this function through mock.

```
int Eeprom_WriteBuffer(uint32_t address, uint8_t *data, uint16_t data_len)
{
mock("eeprom").setData("Eeprom_WriteBuffer_data", data);
return mock("eeprom").actualCall("Eeprom_WriteBuffer")
.withParameter("address", address)
.withParameter("data", data)
.withParameter("data_len", data_len)
.withOutputParameter("data", data)
.returnIntValueOrDefault(-1);
}
```

and I want to be able to pull data[0 - data_len) out so that in my test I can evaluate if my man in the middle function wrote what I expected it to.

Any idea how I can do this? I can't find how to perform this in the manual

Bas Vodde

unread,
Nov 4, 2022, 6:05:51 AM11/4/22
to cppu...@googlegroups.com

Hi Grant,

Do you mean call getData?

It feels too obvious, so I guess I’m missing something.

Thanks!

Bas

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/baae8dba-3435-480b-be26-5b1c250b468an%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages