OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 | 6 |
7 #include "base/test/opaque_ref_counted.h" | 7 #include "base/test/opaque_ref_counted.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 scoped_refptr<SelfAssign> p1(new SelfAssign); | 197 scoped_refptr<SelfAssign> p1(new SelfAssign); |
198 scoped_refptr<SelfAssign> p2(new SelfAssign); | 198 scoped_refptr<SelfAssign> p2(new SelfAssign); |
199 | 199 |
200 EXPECT_EQ(p1, p1); | 200 EXPECT_EQ(p1, p1); |
201 EXPECT_EQ(p2, p2); | 201 EXPECT_EQ(p2, p2); |
202 | 202 |
203 EXPECT_NE(p1, p2); | 203 EXPECT_NE(p1, p2); |
204 EXPECT_NE(p2, p1); | 204 EXPECT_NE(p2, p1); |
205 } | 205 } |
206 | 206 |
207 TEST(RefCountedUnitTest, NullptrEquality) { | |
208 scoped_refptr<SelfAssign> ptr_to_an_instance(new SelfAssign); | |
209 scoped_refptr<SelfAssign> null_ptr; | |
danakj
2016/05/18 01:12:34
nit: ptr_to_nullptr might be easier to read here
Rob Percival
2016/05/18 01:17:01
Done.
| |
210 | |
211 EXPECT_NE(nullptr, ptr_to_an_instance); | |
212 EXPECT_NE(ptr_to_an_instance, nullptr); | |
213 EXPECT_EQ(nullptr, null_ptr); | |
214 EXPECT_EQ(null_ptr, nullptr); | |
215 } | |
216 | |
207 TEST(RefCountedUnitTest, ConvertibleEquality) { | 217 TEST(RefCountedUnitTest, ConvertibleEquality) { |
208 scoped_refptr<Derived> p1(new Derived); | 218 scoped_refptr<Derived> p1(new Derived); |
209 scoped_refptr<SelfAssign> p2; | 219 scoped_refptr<SelfAssign> p2; |
210 | 220 |
211 EXPECT_NE(p1, p2); | 221 EXPECT_NE(p1, p2); |
212 EXPECT_NE(p2, p1); | 222 EXPECT_NE(p2, p1); |
213 | 223 |
214 p2 = p1; | 224 p2 = p1; |
215 | 225 |
216 EXPECT_EQ(p1, p2); | 226 EXPECT_EQ(p1, p2); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 | 498 |
489 TEST(RefCountedUnitTest, TestOverloadResolutionMove) { | 499 TEST(RefCountedUnitTest, TestOverloadResolutionMove) { |
490 scoped_refptr<Derived> derived(new Derived); | 500 scoped_refptr<Derived> derived(new Derived); |
491 scoped_refptr<SelfAssign> expected(derived); | 501 scoped_refptr<SelfAssign> expected(derived); |
492 EXPECT_EQ(expected, Overloaded(std::move(derived))); | 502 EXPECT_EQ(expected, Overloaded(std::move(derived))); |
493 | 503 |
494 scoped_refptr<Other> other(new Other); | 504 scoped_refptr<Other> other(new Other); |
495 scoped_refptr<Other> other2(other); | 505 scoped_refptr<Other> other2(other); |
496 EXPECT_EQ(other2, Overloaded(std::move(other))); | 506 EXPECT_EQ(other2, Overloaded(std::move(other))); |
497 } | 507 } |
OLD | NEW |