]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/util/math_equals.cpp
4 // Copyright (c) 2015 Oracle and/or its affiliates.
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
13 #include <geometry_test_common.hpp>
16 #include <boost/geometry/util/condition.hpp>
17 #include <boost/geometry/util/math.hpp>
19 namespace bgm
= bg::math
;
24 BOOST_CHECK(bgm::equals(0, 0));
25 BOOST_CHECK(bgm::equals(1, 1));
26 BOOST_CHECK(bgm::equals(123456, 123456));
28 T eps
= std::numeric_limits
<T
>::epsilon();
31 BOOST_CHECK(bgm::equals(0, 0+eps
));
32 BOOST_CHECK(bgm::equals(0+eps
, 0));
33 BOOST_CHECK(bgm::equals(1, 1+eps
));
34 BOOST_CHECK(bgm::equals(1+eps
, 1));
35 BOOST_CHECK(bgm::equals(12345+eps
, 12345));
38 if (BOOST_GEOMETRY_CONDITION(std::numeric_limits
<T
>::has_infinity
))
40 T inf
= std::numeric_limits
<T
>::infinity();
41 BOOST_CHECK(!bgm::equals(0, inf
));
42 BOOST_CHECK(!bgm::equals(0, -inf
));
43 BOOST_CHECK(!bgm::equals(1, inf
));
44 BOOST_CHECK(!bgm::equals(1, -inf
));
45 BOOST_CHECK(!bgm::equals(12345, inf
));
46 BOOST_CHECK(!bgm::equals(12345, -inf
));
47 BOOST_CHECK(!bgm::equals(inf
, 0));
48 BOOST_CHECK(!bgm::equals(-inf
, 0));
49 BOOST_CHECK(!bgm::equals(inf
, 1));
50 BOOST_CHECK(!bgm::equals(-inf
, 1));
51 BOOST_CHECK(!bgm::equals(inf
, 12345));
52 BOOST_CHECK(!bgm::equals(-inf
, 12345));
53 BOOST_CHECK(bgm::equals(inf
, inf
));
54 BOOST_CHECK(bgm::equals(-inf
, -inf
));
55 BOOST_CHECK(!bgm::equals(inf
, -inf
));
56 BOOST_CHECK(!bgm::equals(-inf
, inf
));
59 if (BOOST_GEOMETRY_CONDITION(std::numeric_limits
<T
>::has_quiet_NaN
))
61 T nan
= std::numeric_limits
<T
>::quiet_NaN();
62 BOOST_CHECK(!bgm::equals(0, nan
));
63 BOOST_CHECK(!bgm::equals(nan
, 0));
64 BOOST_CHECK(!bgm::equals(nan
, nan
));
65 BOOST_CHECK(!bgm::equals(1, nan
));
66 BOOST_CHECK(!bgm::equals(nan
, 1));
67 BOOST_CHECK(!bgm::equals(12345, nan
));
68 BOOST_CHECK(!bgm::equals(nan
, 12345));
72 int test_main(int, char* [])