vendredi 26 février 2016

How to mockup correctly function with output parameter using CppUTest?

I try mockup function with output parameter of type char **. My code is as follows:

1) Mockup

int get_phy_addr(char **a) {
  mock_c()->actualCall("get_phy_addr")->withOutputParameter("a", a);
  return mock_c()->returnValue().value.intValue;
}

2) Mockup call in test code

mock().expectOneCall("get_phy_addr").withOutputParameterReturning("a", "00E2F3", 6).andReturnValue(0x00);

However I obtain segfault when I try use returned pointer in rest of the tested function.

Aucun commentaire:

Enregistrer un commentaire