BKGRND: I am testing a new circular buffer module. The buffer parameters are held in a struct. These struct members should be private since the client doesn’t need to touch them. BUT by hiding the members, testing becomes much more difficult. If the struct format is public in the header, I can directly look to make sure I’m pointing at the storage array, that my read index is correct, that my write index is correct, etc. If private, I can only test the interface, and while this is possible, it feels slower and more inefficient.
Q: Is there a proper way to test private variables and functions efficiently? Am I missing something fundamental? In the case of my buffer, should I put a copy of the struct format in my test file and cast the pointer to the hidden struct to access these hidden members?