On Sun, Mar 12, 2017 at 12:11 PM John Maddock via Boost < boost@lists.boost.org> wrote:
BTW my experience with both constexpr and noexcept is that it's simply not enough to test at runtime, you have to contrive compile time tests as well, otherwise I can absolutely guarantee things will not work as you expect - trust me I've been there, done that, got the t-shirt!
What that means in practice - and you're not going to like this - is that every runtime test has to have a compile time / constexpr counterpart, things that generate valid "safe" values should compile in a constexpr context (and yes the value needs checking to, again at compile time), while things that would throw at runtime, would be compile-fails. It's a heck of a lot of tests - you might want to write a short program to spew out the files (the expected compile things can all go in one file, but expected failures each need their own test case cpp file).
HTH, John.
I understand that not all tests can be compile-time. But for the ones that can, why does there need to be an equivalent run-time test? I've found that many/most tests of literal types can be conducted at compile time. Am I not testing my `constexpr` functions adequately?