_ReturnArrayThruPtr not returning values but _ReturnThruPtr works fine

69 views
Skip to first unread message

Christian Cortes

unread,
Sep 25, 2023, 7:39:22 PM9/25/23
to ThrowTheSwitch Forums
Hello everyone, 

I do not understand and i might be doing something wrong here so i will give some detail.

I am mocking a built in 12c_read function (dev, ADDR, read_buff, sizeof(readbuff))
this function works with both given single uint8_t val and an array of uint8_t but cannot get it to work while testing. 

the working example using a single uint8_t val
struct device *i2c_dev = GET(DEV);
uint8_t ADDR = 0x19;
uint8_t val = 0xf;
i2c_read_ExpectAndReturn(dev, ADDR, NULL, sizeof(val));
i2c_read_IgnoreArg_read_buffer(); /// this is that name of the 3rd arg in read function
i2c_read_ReturnThruPtr_read_buffer(&val);

in the situation above, it woks and i am able to go through all branches from the function that i am testing. 

but if i change this to be used as an array It returns all zeros and i cannot test any of the 
logic that checks for non-zero data. 

uint8_t val[] = {0x2, 0x3};
uint8_t size = 2;
i2c_read_ExpectAndReturn(dev, ADDR, NULL, sizeof(val));
i2c_read_IgnoreArg_read_buffer(); /// this is that name of the 3rd arg in read function
i2c_read_ReturnArrayThruPtr_read_buffer(&val, size);

am i not using ReturnArray... correctly? 

thanks. 



Mark Vander Voord

unread,
Sep 25, 2023, 9:30:40 PM9/25/23
to throwth...@googlegroups.com
You're passing a pointer to the array instead of the array pointer on that last line. I'm pretty sure you mean to use this:

i2c_read_ReturnArrayThruPtr_read_buffer(val, size); //notice no & before val

--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/throwtheswitch/0336d599-87ef-4e43-9969-9d27c9eef896n%40googlegroups.com.

Christian Cortes

unread,
Sep 26, 2023, 1:08:13 PM9/26/23
to ThrowTheSwitch Forums
got rid of the & and still get the same ouput. 

this is my current version
Ceedling:: 0.31.1
Unity:: 2.5.4
CMock:: 2.5.4
 CException:: 1.3.3
Reply all
Reply to author
Forward
0 new messages