
On Wed, Feb 22, 2012 at 9:40 AM, Robert Ramey <ramey@rrsd.com> wrote:
Ben Robinson wrote:
It would appear there is interest in this library. Therefore, I am making the full source available on GitHub here:
https://github.com/cppmaven/VerifiedInt
The library consists of three header files:
verified_int.hpp (the integer class) verified_int_policies.hpp (the overflow handling policies) detail/verified_int_overflow_detection.hpp (the TMP overflow detection routines)
In addition, you will notice that some of the hundreds of unit tests make use of the metaassert.hpp capability. The VerifiedInt library contains a number of static assertions. MetaAssert allows me to write unit tests, which will pass only if the static assertion fails instead of passing. The trick is to convert what would be a compiler error into a runtime exception, and then detect the exception in the unit test.
Note that boost testing handles this by detecting failure to compile as a legitmate, expecte result. That is there exists the concept that a test must fail to compile in order to be considered as passing the test.
It is always possible to write a build system, which will invert the return code from the compiler, to make non-compiling source pass the build.
My solution using metaassert does not depend in any way on the build system, nor does it depend on any specific unit testing framework. The solution is implemented fully in portable source code, and allows you to unit tests failing static assertions, using which whatever build system and unit testing framework you desire. Thank you, Ben Robinson
Robert Ramey
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost