9 #include <boost/test/unit_test.hpp>
14 namespace tt = boost::test_tools;
24 bool constructor_called =
false;
25 bool destructor_called =
false;
28 MyCache(
int value,
bool* ctor,
bool* dtor) : m_value{value}, m_dtor{dtor} {
31 ~MyCache() { (*m_dtor) =
true; }
36 BOOST_CHECK(!constructor_called);
37 BOOST_CHECK(!destructor_called);
41 MagneticFieldProvider::Cache::make<MyCache>(42, &constructor_called,
43 BOOST_CHECK(constructor_called);
44 BOOST_CHECK(!destructor_called);
46 MyCache&
v = cache.get<MyCache>();
47 BOOST_CHECK_EQUAL(v.m_value, 42);
50 MyCache&
v2 = cache.get<MyCache>();
51 BOOST_CHECK_EQUAL(v2.m_value, 65);
54 BOOST_CHECK(constructor_called);
55 BOOST_CHECK(destructor_called);
63 MyCache(
int value) : m_value(value) {}
65 MyCache(
const MyCache&) =
delete;
66 MyCache&
operator=(
const MyCache&) =
delete;
69 MyCache(MyCache&&) =
default;
72 auto cache = MagneticFieldProvider::Cache::make<MyCache>(42);