Go to the source code of this file.
|
| TEST_CASE ("unique_ptr to single object constructor from pointer", "[unique_ptr][single][constructor]") |
|
| TEST_CASE ("unique_ptr to single object move constructor", "[unique_ptr][single][constructor]") |
|
| TEST_CASE ("unique_ptr to single object move constructor from std::unique_ptr", "[unique_ptr][single][constructor]") |
|
| TEST_CASE ("unique_ptr to single object constructor from pointer and non " "reference deleter", "[unique_ptr][single][constructor]") |
|
| TEST_CASE ("unique_ptr to single object constructor from pointer and reference " "to deleter", "[unique_ptr][single][constructor]") |
|
| TEST_CASE ("unique_ptr to single object constructor from pointer and " "move-reference to deleter", "[unique_ptr][single][constructor]") |
|
| TEST_CASE ("unique_ptr to single object constructor from convertible pointer " "and copied deleter", "[unique_ptr][single][constructor]") |
|
| TEST_CASE ("unique_ptr to single object constructor from convertible object and " "moved deleter", "[unique_ptr][single][constructor]") |
|
◆ TEST_CASE() [1/8]
TEST_CASE |
( |
"unique_ptr to single object constructor from pointer" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
◆ TEST_CASE() [2/8]
TEST_CASE |
( |
"unique_ptr to single object move constructor" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
◆ TEST_CASE() [3/8]
TEST_CASE |
( |
"unique_ptr to single object move constructor from std::unique_ptr" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
Definition at line 79 of file unique_ptr_construction.cpp.
82 std::unique_ptr<int> up(p);
84 REQUIRE(up2.get() == p);
unique_ptr that manages a single object
◆ TEST_CASE() [4/8]
TEST_CASE |
( |
"unique_ptr to single object constructor from pointer and non " "reference deleter" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
Definition at line 87 of file unique_ptr_construction.cpp.
90 bool d1_copied =
false;
91 bool d1_moved =
false;
92 bool d1_called =
false;
93 bool ptr1_deleted =
false;
94 bool d2_copied =
false;
95 bool d2_moved =
false;
96 bool d2_called =
false;
97 bool ptr2_deleted =
false;
98 Deleter d1(&d1_copied, &d1_moved, &d1_called);
99 Deleter d2(&d2_copied, &d2_moved, &d2_called);
101 std::unique_ptr<Foo, Deleter> foo1(
new Foo(ptr1_deleted), d1);
103 REQUIRE(foo2.get() !=
nullptr);
104 REQUIRE(d2_copied == d1_copied);
105 REQUIRE(d2_moved == d1_moved);
106 REQUIRE(d2_called == d1_called);
107 REQUIRE_FALSE(ptr2_deleted);
109 REQUIRE(d2_copied == d1_copied);
110 REQUIRE(d2_moved == d1_moved);
111 REQUIRE(d2_called == d1_called);
112 REQUIRE(ptr2_deleted);
unique_ptr that manages a single object
◆ TEST_CASE() [5/8]
TEST_CASE |
( |
"unique_ptr to single object constructor from pointer and reference " "to deleter" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
Definition at line 116 of file unique_ptr_construction.cpp.
119 bool d1_copied =
false;
120 bool d1_moved =
false;
121 bool d1_called =
false;
122 bool ptr1_deleted =
false;
123 bool d2_copied =
false;
124 bool d2_moved =
false;
125 bool d2_called =
false;
126 bool ptr2_deleted =
false;
127 Deleter d1(&d1_copied, &d1_moved, &d1_called);
128 Deleter d2(&d2_copied, &d2_moved, &d2_called);
130 std::unique_ptr<Foo, Deleter &> foo1(
new Foo(ptr1_deleted), d1);
132 REQUIRE(foo2.get() !=
nullptr);
133 REQUIRE(d2_copied == d1_copied);
134 REQUIRE(d2_moved == d1_moved);
135 REQUIRE(d2_called == d1_called);
136 REQUIRE_FALSE(ptr2_deleted);
138 REQUIRE(d2_copied == d1_copied);
139 REQUIRE(d2_moved == d1_moved);
140 REQUIRE(d2_called == d1_called);
141 REQUIRE(ptr2_deleted);
unique_ptr that manages a single object
◆ TEST_CASE() [6/8]
TEST_CASE |
( |
"unique_ptr to single object constructor from pointer and " "move-reference to deleter" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
Definition at line 145 of file unique_ptr_construction.cpp.
148 bool d1_copied =
false;
149 bool d1_moved =
false;
150 bool d1_called =
false;
151 bool ptr1_deleted =
false;
152 bool d2_copied =
false;
153 bool d2_moved =
false;
154 bool d2_called =
false;
155 bool ptr2_deleted =
false;
156 Deleter d1(&d1_copied, &d1_moved, &d1_called);
157 Deleter d2(&d2_copied, &d2_moved, &d2_called);
159 std::unique_ptr<Foo, Deleter> foo1(
new Foo(ptr1_deleted),
163 REQUIRE(foo2.get() !=
nullptr);
164 REQUIRE(d2_copied == d1_copied);
165 REQUIRE(d2_moved == d1_moved);
166 REQUIRE(d2_called == d1_called);
167 REQUIRE_FALSE(ptr2_deleted);
169 REQUIRE(d2_copied == d1_copied);
170 REQUIRE(d2_moved == d1_moved);
171 REQUIRE(d2_called == d1_called);
172 REQUIRE(ptr2_deleted);
unique_ptr that manages a single object
◆ TEST_CASE() [7/8]
TEST_CASE |
( |
"unique_ptr to single object constructor from convertible pointer " "and copied deleter" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
Definition at line 175 of file unique_ptr_construction.cpp.
178 bool d1_copied =
false;
179 bool d1_moved =
false;
180 bool d1_called =
false;
181 bool ptr1_deleted =
false;
182 bool d2_copied =
false;
183 bool d2_moved =
false;
184 bool d2_called =
false;
185 bool ptr2_deleted =
false;
186 auto clear_all = [&]() {
187 d1_copied = d2_copied = d1_called = d2_called = d1_moved = d2_moved =
190 Deleter d1(&d1_copied, &d1_moved, &d1_called);
191 Deleter d2(&d2_copied, &d2_moved, &d2_called);
193 std::unique_ptr<Foo, Deleter> sup6a(
new Foo(ptr1_deleted), d1);
195 REQUIRE(tup6a.get() !=
nullptr);
196 REQUIRE(d2_copied == d1_copied);
197 REQUIRE(d2_moved == d1_moved);
198 REQUIRE(d2_called == d1_called);
199 REQUIRE_FALSE(ptr2_deleted);
202 std::unique_ptr<Foo, Deleter> sup6b(std::move(sup6a));
203 REQUIRE(sup6b.get() !=
nullptr);
204 REQUIRE_FALSE(ptr2_deleted);
206 REQUIRE(tup6b.get() !=
nullptr);
207 REQUIRE(d2_copied == d1_copied);
208 REQUIRE(d2_moved == d1_moved);
209 REQUIRE(d2_called == d1_called);
210 REQUIRE_FALSE(ptr2_deleted);
213 REQUIRE(ptr2_deleted);
unique_ptr that manages a single object
◆ TEST_CASE() [8/8]
TEST_CASE |
( |
"unique_ptr to single object constructor from convertible object and " "moved deleter" |
, |
|
|
"" |
[unique_ptr][single][constructor] |
|
) |
| |
Definition at line 218 of file unique_ptr_construction.cpp.
221 bool d1_copied =
false;
222 bool d1_moved =
false;
223 bool d1_called =
false;
224 bool ptr1_deleted =
false;
225 bool d2_copied =
false;
226 bool d2_moved =
false;
227 bool d2_called =
false;
228 bool ptr2_deleted =
false;
229 auto clear_all = [&]() {
230 d1_copied = d2_copied = d1_called = d2_called = d1_moved = d2_moved =
233 Deleter d1(&d1_copied, &d1_moved, &d1_called);
234 Deleter d2(&d2_copied, &d2_moved, &d2_called);
236 std::unique_ptr<Foo, Deleter &> sup6a(
new Foo(ptr1_deleted), d1);
238 REQUIRE(tup6a.get() !=
nullptr);
239 REQUIRE(d2_copied == d1_copied);
240 REQUIRE(d2_moved == d1_moved);
241 REQUIRE(d2_called == d1_called);
242 REQUIRE_FALSE(ptr2_deleted);
245 std::unique_ptr<Foo, Deleter> sup6b(std::move(sup6a));
246 REQUIRE(sup6b.get() !=
nullptr);
247 REQUIRE_FALSE(ptr2_deleted);
250 REQUIRE(tup6b.get() !=
nullptr);
251 REQUIRE(d2_copied == d1_copied);
252 REQUIRE(d2_moved == d1_moved);
253 REQUIRE(d2_called == d1_called);
254 REQUIRE_FALSE(ptr2_deleted);
257 REQUIRE(ptr2_deleted);
unique_ptr that manages a single object