10 #define BOOST_TEST_MODULE ChangeMonitorTest
11 #include <boost/test/unit_test.hpp>
52 auto&& res1 = monitor(var);
58 auto&& res2 = monitor(1);
59 BOOST_CHECK((!!res2));
60 BOOST_TEST((res2.value() == 0));
66 auto&& res3 = monitor(1);
71 bool detected =
false;
72 if (
auto prevVal = monitor(2); prevVal) {
74 BOOST_CHECK((!!prevVal));
75 BOOST_TEST((prevVal.value() == 1));
79 BOOST_CHECK((detected));
94 auto&& res1 = monitor(var);
100 auto&& res2 = monitor(1);
101 BOOST_CHECK((!!res2));
102 BOOST_TEST((res2.value() == 0));
108 auto&& res3 = monitor(1);
109 BOOST_CHECK((!res3));
113 bool detected =
false;
114 if (
auto prevVal = monitor(2); prevVal) {
116 BOOST_CHECK((!!prevVal));
117 BOOST_TEST((prevVal.value() == 1));
121 BOOST_CHECK((detected));
bool hasReference() const
Returns whether a reference value is present.
Helper to check if an object has changed. Thread-safe.
bool hasReference() const
Returns whether a reference value is present.
void ThreadSafeChangeMonitor_documentationTest()
Data_t const & reference() const
Classes to detect the change of object values.
Helper to check if an object has changed.
Data_t const & reference() const
Returns the reference value; undefined if hasReference() is false.