Files
safe_numerics/test/test.hpp
Robert Ramey 12f5843f90 Fixed problems in testing addition operations
More carefully defined the concepts.  That is the concept of the library is now clear:

Trap at either compile or runtime integer operations which yield a result which differs from the normal arithmetic result.

Pending on this check in:
a) only addition is fixed up so far
b) uses BOOST_TYPEOF... rather than decltype(... - final decision sill pending.
c) comments out some compile time checks which should be re-instated.
d) fixed tests so that they actually work!
2014-04-05 12:22:25 -07:00

41 lines
1.2 KiB
C++

#ifndef SAFE_NUMERIC_TEST_HPP
#define SAFE_NUMERIC_TEST_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
// Copyright (c) 2012 Robert Ramey
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/array/elem.hpp>
#include <boost/preprocessor/array/size.hpp>
#define VALUE_ARRAY_SIZE BOOST_PP_ARRAY_SIZE(VALUES)
#define TEST_EACH_VALUE2(z, value_index2, value_index1) \
TESTX(value_index1, value_index2)
/**/
#define TEST_EACH_VALUE1(z, value_index1, nothing) \
BOOST_PP_REPEAT( \
BOOST_PP_ARRAY_SIZE(VALUES), \
TEST_EACH_VALUE2, \
value_index1 \
)
/**/
#define TEST_EACH_VALUE_PAIR \
BOOST_PP_REPEAT( \
BOOST_PP_ARRAY_SIZE(VALUES), \
TEST_EACH_VALUE1, \
0 \
)
/**/
#endif