diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-05-19 12:39:12 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-19 21:18:28 +0000 |
commit | 7ec8eaa59308c39c8256300a488a618a3354a5bd (patch) | |
tree | e699d36ca013881018e2cc014a13f6c7ebdc5e36 /core/fxcrt/cfx_unowned_ptr_unittest.cpp | |
parent | 92c13a7d495c54d86ac8faf8a56a017da2ad39ff (diff) | |
download | pdfium-7ec8eaa59308c39c8256300a488a618a3354a5bd.tar.xz |
Back-fill some functionality for CFX_UnownedPtr
Add Release() method, type-convertible compares and assigns, and
right hand vs. left hand comparisons.
Change-Id: I96b1112e328802143d314aa6c92948f26583fa90
Reviewed-on: https://pdfium-review.googlesource.com/5731
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_unowned_ptr_unittest.cpp')
-rw-r--r-- | core/fxcrt/cfx_unowned_ptr_unittest.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/fxcrt/cfx_unowned_ptr_unittest.cpp b/core/fxcrt/cfx_unowned_ptr_unittest.cpp index 586c4bbb2e..6218679fa2 100644 --- a/core/fxcrt/cfx_unowned_ptr_unittest.cpp +++ b/core/fxcrt/cfx_unowned_ptr_unittest.cpp @@ -34,6 +34,15 @@ void AssignDangling() { delete ptr2; } +void ReleaseDangling() { + Clink* ptr1 = new Clink(); + Clink* ptr2 = new Clink(); + ptr2->next_ = ptr1; + delete ptr1; + ptr2->next_.Release(); + delete ptr2; +} + } // namespace TEST(fxcrt, UnownedPtrOk) { @@ -69,6 +78,23 @@ TEST(fxcrt, UnownedAssignNotOk) { #endif } +TEST(fxcrt, UnownedReleaseOk) { + Clink* ptr1 = new Clink(); + Clink* ptr2 = new Clink(); + ptr2->next_ = ptr1; + ptr2->next_.Release(); + delete ptr1; + delete ptr2; +} + +TEST(fxcrt, UnownedReleaseNotOk) { +#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) + EXPECT_DEATH(ReleaseDangling(), ""); +#else + ReleaseDangling(); +#endif +} + TEST(fxcrt, UnownedOperatorEQ) { int foo; CFX_UnownedPtr<int> ptr1; @@ -78,6 +104,7 @@ TEST(fxcrt, UnownedOperatorEQ) { EXPECT_TRUE(ptr1 == ptr2); CFX_UnownedPtr<int> ptr3(&foo); + EXPECT_TRUE(&foo == ptr3); EXPECT_TRUE(ptr3 == &foo); EXPECT_FALSE(ptr1 == ptr3); @@ -94,6 +121,7 @@ TEST(fxcrt, UnownedOperatorNE) { EXPECT_FALSE(ptr1 != ptr2); CFX_UnownedPtr<int> ptr3(&foo); + EXPECT_FALSE(&foo != ptr3); EXPECT_FALSE(ptr3 != &foo); EXPECT_TRUE(ptr1 != ptr3); |