meekrosoft / fff

A testing micro framework for creating function test doubles
Other
761 stars 167 forks source link

a POC for keeping return history of custom_fake's #42

Closed us8ies closed 5 years ago

us8ies commented 6 years ago

Hi all, I would like to ask you if this change makes sense.

In my test scenario a Function Under Test was calling mock generated by fff, this mock had a custom_fake defined, this custom_fake was doing calloc and returning pointer to allocated area, then my function under test was storing this ptr in struct field. My idea was to assert that pointers returned by custom_fake and stored in struct field pointing to the same area. I tried to use func_fake.return_val_history[] but it was empty. And I've found that history is stored only in case when custom_fake_seq is set. So I modified returning value from custom_fake and added SAVE_RET_HISTORY.

My test scenario is quite strange, and most probably I will change it. If this change to fff makes sense I can add it to all functions together with tests.

Br, Mykhailo

wulfgarpro commented 5 years ago

@us8ies, please resolve your conflicts before review moves forward.

henningrehn commented 5 years ago

I've run into the exact same thing, this would be a very useful addition.

meekrosoft commented 5 years ago

Closing since #77 implements this feature