Commit 2739d937 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by facebook-github-bot-1

Fix Build: folly/test/IndestructibleTest.cpp under LSAN

Summary:[Folly] Fix Build: `folly/test/IndestructibleTest.cpp` under LSAN.

Leaks of Meyers singletons are ignored automatically, while normal locals are not. So we make our instances be Meyers singletons.

Differential Revision: D2968368

fb-gh-sync-id: 385ac4491d9a105885af82d85354af929d69cc80
shipit-source-id: 385ac4491d9a105885af82d85354af929d69cc80
parent 9c3e3be0
...@@ -49,7 +49,7 @@ class IndestructibleTest : public testing::Test {}; ...@@ -49,7 +49,7 @@ class IndestructibleTest : public testing::Test {};
} }
TEST_F(IndestructibleTest, access) { 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}}}; map<string, int>{{"key1", 17}, {"key2", 19}, {"key3", 23}}};
auto& m = *data; auto& m = *data;
...@@ -60,7 +60,7 @@ TEST_F(IndestructibleTest, no_destruction) { ...@@ -60,7 +60,7 @@ TEST_F(IndestructibleTest, no_destruction) {
int state = 0; int state = 0;
int value = 0; int value = 0;
auto sing = make_unique<Indestructible<Magic>>( static Indestructible<Magic> sing(
[&] { [&] {
++state; ++state;
value = 7; value = 7;
...@@ -70,7 +70,7 @@ TEST_F(IndestructibleTest, no_destruction) { ...@@ -70,7 +70,7 @@ TEST_F(IndestructibleTest, no_destruction) {
EXPECT_EQ(1, state); EXPECT_EQ(1, state);
EXPECT_EQ(7, value); EXPECT_EQ(7, value);
sing = nullptr; sing.~Indestructible();
EXPECT_EQ(1, state); EXPECT_EQ(1, state);
} }
...@@ -79,7 +79,7 @@ TEST_F(IndestructibleTest, move) { ...@@ -79,7 +79,7 @@ TEST_F(IndestructibleTest, move) {
int value = 0; int value = 0;
int moves = 0; int moves = 0;
Indestructible<Magic> sing( // move assignment static Indestructible<Magic> sing( // move assignment
[&] { [&] {
++state; ++state;
value = 7; value = 7;
...@@ -91,11 +91,13 @@ TEST_F(IndestructibleTest, move) { ...@@ -91,11 +91,13 @@ TEST_F(IndestructibleTest, move) {
EXPECT_EQ(7, value); EXPECT_EQ(7, value);
EXPECT_EQ(0, moves); 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, state);
EXPECT_EQ(1, moves); 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(1, state);
EXPECT_EQ(2, moves); EXPECT_EQ(2, moves);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment