MCPcopy Create free account
hub / github.com/boostorg/json / testAssign

Method testAssign

test/array.cpp:320–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318 }
319
320 void
321 testAssign()
322 {
323 // operator=(array const&)
324 {
325 {
326 array a1({1, true, str_});
327 array a2({nullptr, object{}, 1.f});
328 a2 = a1;
329 check(a1);
330 check(a2);
331 check_storage(a1, storage_ptr{});
332 check_storage(a2, storage_ptr{});
333 }
334
335 fail_loop([&](storage_ptr const& sp)
336 {
337 array a1({1, true, str_});
338 array a2({nullptr, object{}, 1.f}, sp);
339 a2 = a1;
340 check(a1);
341 check(a2);
342 check_storage(a1, storage_ptr{});
343 check_storage(a2, sp);
344 });
345
346 // self-assign
347 {
348 array a({1, true, str_});
349 auto& a1 = a;
350 auto& a2 = a;
351 a1 = a2;
352 check(a);
353 }
354
355 // copy from child
356 {
357 array a({1, {1,2,3}, 3});
358 a = a.at(1).as_array();
359 BOOST_TEST(
360 a == array({1, 2, 3}));
361 }
362 }
363
364 // operator=(array&&)
365 {
366 {
367 array a1({1, true, str_});
368 array a2({nullptr, object{}, 1.f});
369 a2 = std::move(a1);
370 BOOST_TEST(a1.empty());
371 check(a2);
372 }
373
374 // empty
375 {
376 array a1;
377 array a2;

Callers

nothing calls this directly

Calls 5

checkFunction · 0.85
check_storageFunction · 0.85
fail_loopFunction · 0.85
arrayClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected