Consensus on unit tests?
Roland McGrath
roland@hack.frob.com
Sat Sep 3 00:32:00 GMT 2016
You asked about the general concept of unit tests, and the following
discussion was only about the technical issues with the specific code in
your example.
I think the general notion of unit tests is a very good one. I don't
see any obvious problems in the approach you've taken to building a unit
test. Of course, any particular refactoring change to enable unit
testing might have issues and "It's for a unit test!" is not any kind of
trump over usual review concerns.
The likely pitfall I would look out for is when breaking some function
out into its own file to make it unit-testable might perturb the
optimization opportunities for the function in the actual build. We
should be careful about that. In your first example, the function was
already global, so there is no particular reason to worry about that
issue.
Thanks,
Roland
More information about the Libc-alpha
mailing list