mirror of
https://github.com/boostorg/safe_numerics.git
synced 2026-02-02 21:12:17 +00:00
35 lines
817 B
C++
35 lines
817 B
C++
#include <iostream>
|
|
#include <ostream>
|
|
#include <cassert>
|
|
|
|
#include "../include/checked_result.hpp"
|
|
|
|
bool test1(){
|
|
using namespace boost::numeric;
|
|
checked_result<int> x_min = {
|
|
std::numeric_limits<checked_result<int> >::min()
|
|
};
|
|
std::cout << "checked_result<int> min = " << x_min << std::endl;
|
|
|
|
checked_result<int> x_max = {
|
|
std::numeric_limits<checked_result<int>>::max()
|
|
};
|
|
std::cout << "checked_result<int> max = " << x_max << std::endl;
|
|
return true;
|
|
}
|
|
|
|
bool test2(){
|
|
using namespace boost::numeric;
|
|
checked_result<int> x1(0);
|
|
assert(0 == x1);
|
|
checked_result<int> x2(exception_type::overflow_error, "exception message");
|
|
assert(! x2.no_exception());
|
|
return true;
|
|
}
|
|
|
|
int main(){
|
|
return (
|
|
test1() &&
|
|
test2()
|
|
) ? 0 : 1;
|
|
} |