]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/uuid/test/test_tagging.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / uuid / test / test_tagging.cpp
1 // (C) Copyright Andy Tompkins 2009. Permission to copy, use, modify, sell and
2 // distribute this software is granted provided this copyright notice appears
3 // in all copies. This software is provided "as is" without express or implied
4 // warranty, and with no claim as to its suitability for any purpose.
5
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // https://www.boost.org/LICENSE_1_0.txt)
9
10 // libs/uuid/test/test_tagging.cpp -------------------------------//
11
12 #include <boost/uuid/uuid.hpp>
13 #include <boost/uuid/uuid_generators.hpp>
14 #include <boost/detail/lightweight_test.hpp>
15
16 class object
17 {
18 public:
19 object()
20 : tag(boost::uuids::random_generator()())
21 , state(0)
22 {}
23
24 explicit object(int state)
25 : tag(boost::uuids::random_generator()())
26 , state(state)
27 {}
28
29 object(object const& rhs)
30 : tag(rhs.tag)
31 , state(rhs.state)
32 {}
33
34 bool operator==(object const& rhs) const {
35 return tag == rhs.tag;
36 }
37 bool operator!=(object const& rhs) const {
38 return !(operator==(rhs));
39 }
40
41 object& operator=(object const& rhs) {
42 tag = rhs.tag;
43 state = rhs.state;
44 return *this;
45 }
46
47 int get_state() const { return state; }
48 void set_state(int new_state) { state = new_state; }
49
50 private:
51 boost::uuids::uuid tag;
52
53 int state;
54 };
55
56 template <typename elem, typename traits>
57 std::basic_ostream<elem, traits>& operator<<(std::basic_ostream<elem, traits>& os, object const& o)
58 {
59 os << o.get_state();
60 return os;
61 }
62
63 int main(int, char*[])
64 {
65 object o1(1);
66
67 object o2 = o1;
68 BOOST_TEST_EQ(o1, o2);
69
70 o2.set_state(2);
71 BOOST_TEST_EQ(o1, o2);
72
73 object o3;
74 o3.set_state(3);
75
76 BOOST_TEST_NE(o1, o3);
77 BOOST_TEST_NE(o2, o3);
78
79 return boost::report_errors();
80 }