]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/test/writing-test-ts/fp-no-comparison-for-incomplete-types-test.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / test / test / writing-test-ts / fp-no-comparison-for-incomplete-types-test.cpp
1 // (C) Copyright Raffi Enficiaud 2019
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/test for the library home page.
7
8 #define BOOST_TEST_MAIN
9 #include <boost/test/unit_test.hpp>
10
11 // https://github.com/boostorg/test/issues/209
12 // no floating point comparison for abstract types.
13 struct abstract
14 {
15 virtual ~abstract() = 0;
16 bool operator==(const abstract &) const { return true; }
17 };
18
19 std::ostream &operator<<(std::ostream &ostr, const abstract &) {
20 return ostr << "compared";
21 }
22
23 // the test is checking the compilation of the following snippet
24 void foo(abstract &a)
25 {
26 // pre-C++11 compilers use a copy of the arguments in the
27 // expansion of the BOOST_TEST macro
28 #if !defined(BOOST_TEST_MACRO_LIMITED_SUPPORT)
29 BOOST_TEST(a == a);
30 BOOST_TEST_CHECK(a == a);
31 BOOST_TEST_REQUIRE(a == a);
32 BOOST_TEST_WARN(a == a);
33 #endif
34 BOOST_CHECK_EQUAL(a, a);
35 }
36
37 // we need at least one test
38 BOOST_AUTO_TEST_CASE(dummy)
39 {
40 const int x = 1;
41 BOOST_TEST(x == 1);
42 }