Changeset 17012fcf in mainline
- Timestamp:
- 2018-07-05T21:41:24Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bfc972e
- Parents:
- 122c3b8
- git-author:
- Dzejrou <dzejrou@…> (2018-05-15 23:01:09)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/src/internal/test/memory.cpp
r122c3b8 r17012fcf 41 41 42 42 test_unique_ptr(); 43 test_shared_ptr(); 43 44 44 45 return end(); … … 99 100 test_eq("unique_ptr array out of scope", mock::destructor_calls, 10U); 100 101 } 102 103 void memory_test::test_shared_ptr() 104 { 105 mock::clear(); 106 { 107 auto ptr1 = std::make_shared<mock>(); 108 test_eq("shared_ptr make_shared", mock::constructor_calls, 1U); 109 test_eq("shared_ptr unique", ptr1.unique(), true); 110 { 111 auto ptr2 = ptr1; 112 test_eq("shared_ptr copy pt1", ptr1.use_count(), 2U); 113 test_eq("shared_ptr copy pt2", ptr2.use_count(), 2U); 114 test_eq("shared_ptr copy no constructor call", mock::copy_constructor_calls, 0U); 115 test_eq("shared_ptr not unique", ptr1.unique(), false); 116 117 auto ptr3 = std::move(ptr2); 118 test_eq("shared_ptr move pt1", ptr1.use_count(), 2U); 119 test_eq("shared_ptr move pt2", ptr3.use_count(), 2U); 120 121 test_eq("shared_ptr move origin empty", (bool)ptr2, false); 122 } 123 test_eq("shared_ptr copy out of scope", mock::destructor_calls, 0U); 124 } 125 test_eq("shared_ptr original out of scope", mock::destructor_calls, 1U); 126 } 101 127 }
Note:
See TracChangeset
for help on using the changeset viewer.