| 61 | LAZY_INSTANCE_INITIALIZER; |
| 62 | |
| 63 | TEST(LazyInstanceTest, Basic) { |
| 64 | { |
| 65 | butil::ShadowingAtExitManager shadow; |
| 66 | |
| 67 | EXPECT_EQ(0, constructed_seq_.GetNext()); |
| 68 | EXPECT_EQ(0, destructed_seq_.GetNext()); |
| 69 | |
| 70 | lazy_logger.Get(); |
| 71 | EXPECT_EQ(2, constructed_seq_.GetNext()); |
| 72 | EXPECT_EQ(1, destructed_seq_.GetNext()); |
| 73 | |
| 74 | lazy_logger.Pointer(); |
| 75 | EXPECT_EQ(3, constructed_seq_.GetNext()); |
| 76 | EXPECT_EQ(2, destructed_seq_.GetNext()); |
| 77 | } |
| 78 | EXPECT_EQ(4, constructed_seq_.GetNext()); |
| 79 | EXPECT_EQ(4, destructed_seq_.GetNext()); |
| 80 | } |
| 81 | |
| 82 | static butil::LazyInstance<SlowConstructor> lazy_slow = |
| 83 | LAZY_INSTANCE_INITIALIZER; |