}
TEST_F(IndestructibleTest, access) {
- const Indestructible<map<string, int>> data{
+ static const Indestructible<map<string, int>> data{
map<string, int>{{"key1", 17}, {"key2", 19}, {"key3", 23}}};
auto& m = *data;
int state = 0;
int value = 0;
- auto sing = make_unique<Indestructible<Magic>>(
+ static Indestructible<Magic> sing(
[&] {
++state;
value = 7;
EXPECT_EQ(1, state);
EXPECT_EQ(7, value);
- sing = nullptr;
+ sing.~Indestructible();
EXPECT_EQ(1, state);
}
int value = 0;
int moves = 0;
- Indestructible<Magic> sing( // move assignment
+ static Indestructible<Magic> sing( // move assignment
[&] {
++state;
value = 7;
EXPECT_EQ(7, value);
EXPECT_EQ(0, moves);
- Indestructible<Magic> move_ctor(std::move(sing)); // move constructor
+ // move constructor
+ static Indestructible<Magic> move_ctor(std::move(sing));
EXPECT_EQ(1, state);
EXPECT_EQ(1, moves);
- Indestructible<Magic> move_assign = std::move(move_ctor); // move assignment
+ // move assignment
+ static Indestructible<Magic> move_assign = std::move(move_ctor);
EXPECT_EQ(1, state);
EXPECT_EQ(2, moves);
}