| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium 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 "core/fxcrt/cfx_retain_ptr.h" | 5 #include "core/fxcrt/cfx_retain_ptr.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "testing/fx_string_testhelpers.h" | 9 #include "testing/fx_string_testhelpers.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 CFX_RetainPtr<PseudoRetainable> obj2_ptr2(&obj2); | 218 CFX_RetainPtr<PseudoRetainable> obj2_ptr2(&obj2); |
| 219 EXPECT_FALSE(null_ptr1 != null_ptr2); | 219 EXPECT_FALSE(null_ptr1 != null_ptr2); |
| 220 EXPECT_FALSE(obj1_ptr1 != obj1_ptr2); | 220 EXPECT_FALSE(obj1_ptr1 != obj1_ptr2); |
| 221 EXPECT_FALSE(obj2_ptr1 != obj2_ptr2); | 221 EXPECT_FALSE(obj2_ptr1 != obj2_ptr2); |
| 222 } | 222 } |
| 223 EXPECT_TRUE(null_ptr1 != obj1_ptr1); | 223 EXPECT_TRUE(null_ptr1 != obj1_ptr1); |
| 224 EXPECT_TRUE(null_ptr1 != obj2_ptr1); | 224 EXPECT_TRUE(null_ptr1 != obj2_ptr1); |
| 225 EXPECT_TRUE(obj1_ptr1 != obj2_ptr1); | 225 EXPECT_TRUE(obj1_ptr1 != obj2_ptr1); |
| 226 } | 226 } |
| 227 | 227 |
| 228 TEST(fxcrt, RetainPtrLessThan) { |
| 229 PseudoRetainable objs[2]; |
| 230 CFX_RetainPtr<PseudoRetainable> obj1_ptr(&objs[0]); |
| 231 CFX_RetainPtr<PseudoRetainable> obj2_ptr(&objs[1]); |
| 232 EXPECT_TRUE(obj1_ptr < obj2_ptr); |
| 233 EXPECT_FALSE(obj2_ptr < obj1_ptr); |
| 234 } |
| 235 |
| 228 TEST(fxcrt, RetainPtrBool) { | 236 TEST(fxcrt, RetainPtrBool) { |
| 229 PseudoRetainable obj1; | 237 PseudoRetainable obj1; |
| 230 CFX_RetainPtr<PseudoRetainable> null_ptr; | 238 CFX_RetainPtr<PseudoRetainable> null_ptr; |
| 231 CFX_RetainPtr<PseudoRetainable> obj1_ptr(&obj1); | 239 CFX_RetainPtr<PseudoRetainable> obj1_ptr(&obj1); |
| 232 bool null_bool = !!null_ptr; | 240 bool null_bool = !!null_ptr; |
| 233 bool obj1_bool = !!obj1_ptr; | 241 bool obj1_bool = !!obj1_ptr; |
| 234 EXPECT_FALSE(null_bool); | 242 EXPECT_FALSE(null_bool); |
| 235 EXPECT_TRUE(obj1_bool); | 243 EXPECT_TRUE(obj1_bool); |
| 236 } | 244 } |
| 237 | 245 |
| 238 TEST(fxcrt, RetainPtrMakeRetained) { | 246 TEST(fxcrt, RetainPtrMakeRetained) { |
| 239 auto ptr = pdfium::MakeRetain<CFX_Retainable>(); | 247 auto ptr = pdfium::MakeRetain<CFX_Retainable>(); |
| 240 EXPECT_TRUE(ptr->HasOneRef()); | 248 EXPECT_TRUE(ptr->HasOneRef()); |
| 241 { | 249 { |
| 242 CFX_RetainPtr<CFX_Retainable> other = ptr; | 250 CFX_RetainPtr<CFX_Retainable> other = ptr; |
| 243 EXPECT_FALSE(ptr->HasOneRef()); | 251 EXPECT_FALSE(ptr->HasOneRef()); |
| 244 } | 252 } |
| 245 EXPECT_TRUE(ptr->HasOneRef()); | 253 EXPECT_TRUE(ptr->HasOneRef()); |
| 246 } | 254 } |
| OLD | NEW |