proxygen
SingletonTestGlobal.cpp File Reference
#include <memory>
#include <vector>
#include <folly/Benchmark.h>
#include <folly/Singleton.h>
#include <folly/portability/GTest.h>
#include <folly/test/SingletonTestStructs.h>

Go to the source code of this file.

Functions

 TEST (Singleton, BasicGlobalUsage)
 

Function Documentation

TEST ( Singleton  ,
BasicGlobalUsage   
)

Definition at line 40 of file SingletonTestGlobal.cpp.

References Watchdog::creation_order(), folly::SingletonVault::destroyInstances(), EXPECT_EQ, EXPECT_GE, EXPECT_NE, folly::SingletonVault::singleton(), folly::size(), and folly::Singleton< T, Tag, VaultTag >::try_get().

40  {
42  EXPECT_GE(SingletonVault::singleton()->registeredSingletonCount(), 1);
43  EXPECT_EQ(SingletonVault::singleton()->livingSingletonCount(), 0);
44 
45  {
46  std::shared_ptr<GlobalWatchdog> wd1 = Singleton<GlobalWatchdog>::try_get();
47  EXPECT_NE(wd1, nullptr);
49  std::shared_ptr<GlobalWatchdog> wd2 = Singleton<GlobalWatchdog>::try_get();
50  EXPECT_NE(wd2, nullptr);
51  EXPECT_EQ(wd1.get(), wd2.get());
53  }
54 
55  SingletonVault::singleton()->destroyInstances();
57 }
static Singleton< ShutdownSocketSet, PrivateTag > singleton
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_GE(val1, val2)
Definition: gtest.h:1932
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
static std::vector< Watchdog * > & creation_order()
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926