1 #ifndef BOOST_TEST_MULTIPLY_HPP
2 #define BOOST_TEST_MULTIPLY_HPP
4 // Copyright (c) 2015 Robert Ramey
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
11 #include <boost/core/demangle.hpp>
13 #include <boost/safe_numerics/safe_integer.hpp>
14 #include <boost/safe_numerics/range_value.hpp>
16 template<class T1, class T2>
24 std::cout << "testing"<< std::endl;
28 using result_type = decltype(t1 * v2);
29 std::cout << "safe<" << av1 << "> * " << av2 << " -> ";
31 boost::safe_numerics::is_safe<safe_t<T1> >::value,
35 boost::safe_numerics::is_safe<result_type>::value,
36 "Expression failed to return safe type"
40 // use auto to avoid checking assignment.
41 auto result = t1 * v2;
42 std::cout << make_result_display(result);
43 if(expected_result == 'x'){
44 const std::type_info & ti = typeid(result);
46 << " *** failed to detect error in multiplication"
47 << boost::core::demangle(ti.name())
52 std::cout << std::endl;
54 catch(const std::exception &){
55 if(expected_result == '.'){
57 << " *** erroneously detected error in multiplication"
62 catch(const std::exception &){}
69 using result_type = decltype(v1 * t2);
70 std::cout << av1 << " * " << "safe<" << av2 << "> -> ";
72 boost::safe_numerics::is_safe<safe_t<T2> >::value,
76 boost::safe_numerics::is_safe<result_type>::value,
77 "Expression failed to return safe type"
81 // use auto to avoid checking assignment.
82 auto result = v1 * t2;
83 std::cout << make_result_display(result);
84 if(expected_result == 'x'){
85 const std::type_info & ti = typeid(result);
87 << " *** failed to detect error in multiplication"
88 << boost::core::demangle(ti.name())
93 std::cout << std::endl;
95 catch(const std::exception &){
96 if(expected_result == '.'){
98 << " *** erroneously detected error in multiplication"
103 catch(const std::exception &){}
112 using result_type = decltype(t1 * t2);
113 std::cout << "safe<" << av1 << "> * " << "safe<" << av2 << "> -> ";
115 boost::safe_numerics::is_safe<result_type>::value,
116 "Expression failed to return safe type"
120 // use auto to avoid checking assignment.
121 auto result = t1 * t2;
122 std::cout << make_result_display(result);
123 if(expected_result == 'x'){
124 const std::type_info & ti = typeid(result);
126 << " *** failed to detect error in multiplication"
127 << boost::core::demangle(ti.name())
132 std::cout << std::endl;
134 catch(const std::exception &){
135 if(expected_result == '.'){
137 << " *** erroneously detected error in multiplication"
142 catch(const std::exception &){}
151 #endif // BOOST_TEST_MULTIPLY