proxygen
DestructorCheckTest.cpp File Reference

Go to the source code of this file.

Classes

class  Derived
 

Functions

 TEST (DestructorCheckTest, WithoutGuard)
 
 TEST (DestructorCheckTest, SingleGuard)
 
 TEST (DestructorCheckTest, SingleGuardDestroyed)
 
 TEST (DestructorCheckTest, MultipleGuards)
 
 TEST (DestructorCheckTest, MultipleGuardsDestroyed)
 

Function Documentation

TEST ( DestructorCheckTest  ,
WithoutGuard   
)

Definition at line 26 of file DestructorCheckTest.cpp.

26  {
27  Derived d;
28 }
TEST ( DestructorCheckTest  ,
SingleGuard   
)

Definition at line 30 of file DestructorCheckTest.cpp.

References ASSERT_FALSE, and s.

30  {
31  Derived d;
32  Derived::Safety s(d);
33  ASSERT_FALSE(s.destroyed());
34 }
static set< string > s
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
TEST ( DestructorCheckTest  ,
SingleGuardDestroyed   
)

Definition at line 36 of file DestructorCheckTest.cpp.

References ASSERT_FALSE, ASSERT_TRUE, and s.

36  {
37  auto d = std::make_unique<Derived>();
38  Derived::Safety s(*d);
39  ASSERT_FALSE(s.destroyed());
40  d.reset();
41  ASSERT_TRUE(s.destroyed());
42 }
static set< string > s
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
TEST ( DestructorCheckTest  ,
MultipleGuards   
)

Definition at line 44 of file DestructorCheckTest.cpp.

References ASSERT_FALSE.

44  {
45  Derived d;
46  auto s1 = std::make_unique<Derived::Safety>(d);
47  auto s2 = std::make_unique<Derived::Safety>(d);
48  auto s3 = std::make_unique<Derived::Safety>(d);
49 
50  // Remove the middle of the list.
51  ASSERT_FALSE(s2->destroyed());
52  s2.reset();
53 
54  // Add in a link after a removal has occurred.
55  auto s4 = std::make_unique<Derived::Safety>(d);
56 
57  // Remove the beginning of the list.
58  ASSERT_FALSE(s1->destroyed());
59  s1.reset();
60  // Remove the end of the list.
61  ASSERT_FALSE(s4->destroyed());
62  s4.reset();
63  // Remove the last remaining of the list.
64  ASSERT_FALSE(s3->destroyed());
65  s3.reset();
66 }
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
TEST ( DestructorCheckTest  ,
MultipleGuardsDestroyed   
)

Definition at line 68 of file DestructorCheckTest.cpp.

References ASSERT_FALSE, and ASSERT_TRUE.

68  {
69  auto d = std::make_unique<Derived>();
70  auto s1 = std::make_unique<Derived::Safety>(*d);
71  auto s2 = std::make_unique<Derived::Safety>(*d);
72  auto s3 = std::make_unique<Derived::Safety>(*d);
73  auto s4 = std::make_unique<Derived::Safety>(*d);
74 
75  // Remove something from the list.
76  ASSERT_FALSE(s2->destroyed());
77  s2.reset();
78 
79  ASSERT_FALSE(s1->destroyed());
80  ASSERT_FALSE(s3->destroyed());
81  ASSERT_FALSE(s4->destroyed());
82 
83  d.reset();
84 
85  ASSERT_TRUE(s1->destroyed());
86  ASSERT_TRUE(s3->destroyed());
87  ASSERT_TRUE(s4->destroyed());
88 }
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865