C++ guys hate static_if?

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 14 11:38:20 PDT 2013


On Thursday, March 14, 2013 13:26:18 Andrei Alexandrescu wrote:
> Walter has measured coverage of Phobos unittests a couple of times, it's
> very high. But I agree it would be nice to have it as a target.

Though this is exactly a case where 100% unit test coverage doesn't mean much. 
All that means is that each path has been instantiated and run. It doesn't 
mean that it's covered enough possible instantiations to properly test the 
template. For instance, a simple bug like making it so that hasLength!R ends 
up choosing a static if path which assumes random access wouldn't be caught 
unless you happened to test that template with a range which has length but 
doesn't have random access, and even with thorough testing, there's bound to 
be some particular genre of range that gets missed in the unit tests.

But barring something that makes it impossible or unreasonable, we really 
should be shooting for 100% code coverage. assert(0) would a prime case where 
it's impossible (even std.datetime only had 98% or 99% code coverage the last 
time I checked, precisely because of assert(0)), and I'm sure that there are 
other cases, but we should be able to get close.

- Jonathan M Davis


More information about the Digitalmars-d mailing list