1 #ifndef BOOST_TEST_LESS_THAN_HPP
2 #define BOOST_TEST_LESS_THAN_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)
12 #include <boost/safe_numerics/safe_integer.hpp>
13 #include <boost/safe_numerics/range_value.hpp>
15 // works for both GCC and clang
16 #pragma GCC diagnostic push
17 #pragma GCC diagnostic ignored "-Wunused-value"
19 template<class T1, class T2>
27 using namespace boost::safe_numerics;
28 std::cout << "testing"<< std::boolalpha << std::endl;
31 std::cout << "safe<" << av1 << "> == " << av2 << " -> ";
33 boost::safe_numerics::is_safe<safe_t<T1> >::value,
37 // use auto to avoid checking assignment.
38 auto result = (t1 == v2);
39 std::cout << make_result_display(result);
40 if(expected_result == 'x'){
42 << " ! = "<< av1 << " == " << av2
43 << " failed to detect error in equals"
48 if(result != (expected_result == '=')){
50 << " ! = "<< av1 << " == " << av2
51 << " produced the wrong answer"
56 std::cout << std::endl;
58 catch(const std::exception &){
59 if(expected_result != 'x'){
61 << " == "<< av1 << " == " << av2
62 << " erroneously detected error in equals"
67 catch(const std::exception &){}
70 std::cout << std::endl;
75 std::cout << av1 << " == " << "safe<" << av2 << "> -> ";
77 boost::safe_numerics::is_safe<safe_t<T2> >::value,
81 // use auto to avoid checking assignment.
82 auto result = (v1 == t2);
83 std::cout << make_result_display(result);
84 if(expected_result == 'x'){
86 << " ! = "<< av1 << " == " << av2
87 << " failed to detect error in equals "
92 if(result != (expected_result == '=')){
94 << " ! = "<< av1 << " == " << av2
95 << " produced the wrong answer "
100 std::cout << std::endl;
102 catch(const std::exception &){
103 if(expected_result != 'x'){
105 << " == "<< av1 << " == " << av2
106 << " erroneously detected error in equals"
111 catch(const std::exception &){}
114 std::cout << std::endl;
120 std::cout << "safe<" << av1 << "> < " << "safe<" << av2 << "> -> ";
123 auto result = (t1 == t2);
124 std::cout << make_result_display(result);
125 if(expected_result == 'x'){
127 << " ! = "<< av1 << " == " << av2
128 << " failed to detect error in equals"
133 if(result != (expected_result == '=')){
135 << " ! = "<< av1 << " == " << av2
136 << " produced the wrong answer"
141 std::cout << std::endl;
143 catch(const std::exception &){
144 if(expected_result == '.'){
146 << " == "<< av1 << " == " << av2
147 << " erroneously detected error in equals"
152 catch(const std::exception &){}
155 std::cout << std::endl;
158 return true; // correct result
160 #pragma GCC diagnostic pop
162 #endif // BOOST_TEST_SUBTRACT