Commit b422f6b5 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Fix folly/test:singleton_test - Singleton.SharedPtrUsage

Reviewed By: yfeldblum

Differential Revision: D4856138

fbshipit-source-id: 19eee4f8c4108ef168d82d5e9b1f2d65ff9b03bd
parent e15da103
......@@ -202,7 +202,18 @@ TEST(Singleton, SharedPtrUsage) {
auto& vault = *SingletonVault::singleton<SharedPtrUsageTag>();
EXPECT_EQ(vault.registeredSingletonCount(), 0);
SingletonSharedPtrUsage<Watchdog> watchdog_singleton;
std::vector<std::unique_ptr<Watchdog>> watchdog_instances;
SingletonSharedPtrUsage<Watchdog> watchdog_singleton(
[&] {
watchdog_instances.push_back(std::make_unique<Watchdog>());
return watchdog_instances.back().get();
},
[&](Watchdog* ptr) {
// Make sure that only second instance is destroyed. First instance is
// expected to be leaked.
EXPECT_EQ(watchdog_instances[1].get(), ptr);
watchdog_instances[1].reset();
});
EXPECT_EQ(vault.registeredSingletonCount(), 1);
SingletonSharedPtrUsage<ChildWatchdog> child_watchdog_singleton;
......
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