Reputation: 13125
I need to mock a free function interface in my unit tests. For this reason, I include the mocked function as a static member in a class. I can the save the state of this mock in static class members. I've included the function free
in this class to free the memory associated with the static members, which gets called at the end of each test case. This function is effectively a destructor. What would be a good name for the constructor equivalent of this function? That is, the function that is called on construction of the test fixture for each test case?
Upvotes: 0
Views: 76
Reputation: 15758
If the function only allocates data structures without initialising them, allocate
or a variation thereof would seem appropriate (this is also the name used by the C++ STL Allocators).
If the function only initializes data structures allocated elsewhere (for example on the stack or as direct members of another object), initialize
or a variation thereof would seem appropriate.
If the function does both allocation and initialization, create
is a common name (prefix) used in C for such functions.
Upvotes: 1