58 ObservedPtr<PseudoObservable> ptr(&obs);
59 EXPECT_TRUE(ptr.Get());
60 EXPECT_EQ(1u, obs.ActiveObservedPtrs());
62 ObservedPtr<PseudoObservable> ptr2(ptr);
63 EXPECT_TRUE(ptr2.Get());
64 EXPECT_EQ(2u, obs.ActiveObservedPtrs());
66 EXPECT_EQ(1u, obs.ActiveObservedPtrs());
68 EXPECT_EQ(0u, obs.ActiveObservedPtrs());
74 ObservedPtr<PseudoObservable> ptr(&obs);
75 EXPECT_TRUE(ptr.Get());
76 EXPECT_EQ(1u, obs.ActiveObservedPtrs());
78 ObservedPtr<PseudoObservable> ptr2;
80 EXPECT_TRUE(ptr2.Get());
81 EXPECT_EQ(2u, obs.ActiveObservedPtrs());
83 EXPECT_EQ(1u, obs.ActiveObservedPtrs());
85 EXPECT_EQ(0u, obs.ActiveObservedPtrs());
91 std::vector<ObservedPtr<PseudoObservable>> vec1;
92 std::vector<ObservedPtr<PseudoObservable>> vec2;
93 vec1.emplace_back(&obs);
94 vec1.emplace_back(&obs);
95 EXPECT_TRUE(vec1[0].Get());
96 EXPECT_TRUE(vec1[1].Get());
97 EXPECT_EQ(2u, obs.ActiveObservedPtrs());
99 EXPECT_TRUE(vec2[0].Get());
100 EXPECT_TRUE(vec2[1].Get());
101 EXPECT_EQ(4u, obs.ActiveObservedPtrs());
103 EXPECT_EQ(2u, obs.ActiveObservedPtrs());
105 EXPECT_EQ(2u, obs.ActiveObservedPtrs());
107 EXPECT_EQ(0u, obs.ActiveObservedPtrs());
109 EXPECT_EQ(0u, obs.ActiveObservedPtrs());
113 std::vector<ObservedPtr<PseudoObservable>> vec1;
115 PseudoObservable obs;
116 vec1.emplace_back(&obs);
117 vec1.emplace_back(&obs);
118 EXPECT_TRUE(vec1[0].Get());
119 EXPECT_TRUE(vec1[1].Get());
120 EXPECT_EQ(2u, obs.ActiveObservedPtrs());
122 EXPECT_FALSE(vec1[0].Get());
123 EXPECT_FALSE(vec1[1].Get());
135 PseudoObservable obs1;
136 PseudoObservable obs2;
137 ObservedPtr<PseudoObservable> ptr(&obs1);
138 EXPECT_EQ(1u, obs1.ActiveObservedPtrs());
139 EXPECT_EQ(0u, obs2.ActiveObservedPtrs());
141 EXPECT_EQ(0u, obs1.ActiveObservedPtrs());
142 EXPECT_EQ(1u, obs2.ActiveObservedPtrs());
146 PseudoObservable obj1;
147 PseudoObservable obj2;
148 ObservedPtr<PseudoObservable> null_ptr1;
149 ObservedPtr<PseudoObservable> obj1_ptr1(&obj1);
150 ObservedPtr<PseudoObservable> obj2_ptr1(&obj2);
151 EXPECT_TRUE(&obj1 == obj1_ptr1);
152 EXPECT_TRUE(obj1_ptr1 == &obj1);
153 EXPECT_TRUE(&obj2 == obj2_ptr1);
154 EXPECT_TRUE(obj2_ptr1 == &obj2);
156 ObservedPtr<PseudoObservable> null_ptr2;
157 EXPECT_TRUE(null_ptr1 == null_ptr2);
159 ObservedPtr<PseudoObservable> obj1_ptr2(&obj1);
160 EXPECT_TRUE(obj1_ptr1 == obj1_ptr2);
162 ObservedPtr<PseudoObservable> obj2_ptr2(&obj2);
163 EXPECT_TRUE(obj2_ptr1 == obj2_ptr2);
165 EXPECT_FALSE(null_ptr1 == obj1_ptr1);
166 EXPECT_FALSE(null_ptr1 == obj2_ptr1);
167 EXPECT_FALSE(obj1_ptr1 == obj2_ptr1);
171 PseudoObservable obj1;
172 PseudoObservable obj2;
173 ObservedPtr<PseudoObservable> null_ptr1;
174 ObservedPtr<PseudoObservable> obj1_ptr1(&obj1);
175 ObservedPtr<PseudoObservable> obj2_ptr1(&obj2);
176 EXPECT_FALSE(&obj1 != obj1_ptr1);
177 EXPECT_FALSE(obj1_ptr1 != &obj1);
178 EXPECT_FALSE(&obj2 != obj2_ptr1);
179 EXPECT_FALSE(obj2_ptr1 != &obj2);
181 ObservedPtr<PseudoObservable> null_ptr2;
182 ObservedPtr<PseudoObservable> obj1_ptr2(&obj1);
183 ObservedPtr<PseudoObservable> obj2_ptr2(&obj2);
184 EXPECT_FALSE(null_ptr1 != null_ptr2);
185 EXPECT_FALSE(obj1_ptr1 != obj1_ptr2);
186 EXPECT_FALSE(obj2_ptr1 != obj2_ptr2);
188 EXPECT_TRUE(null_ptr1 != obj1_ptr1);
189 EXPECT_TRUE(null_ptr1 != obj2_ptr1);
190 EXPECT_TRUE(obj1_ptr1 != obj2_ptr1);
211 SelfObservable thing1;
213 SelfObservable thing2;
214 thing1.m_pOther.Reset(&thing2);
215 thing2.m_pOther.Reset(&thing1);
216 EXPECT_EQ(&thing2, thing1.m_pOther.Get());
217 EXPECT_EQ(&thing1, thing2.m_pOther.Get());
219 EXPECT_FALSE(thing1.m_pOther.Get());