| 389 | } |
| 390 | |
| 391 | void |
| 392 | testAssignment() |
| 393 | { |
| 394 | test_vectors const t; |
| 395 | |
| 396 | // operator=(string) |
| 397 | { |
| 398 | fail_loop([&](storage_ptr const& sp) |
| 399 | { |
| 400 | std::string c(t.v1.size(), '*'); |
| 401 | string s(c, sp); |
| 402 | string const s2(t.v1); |
| 403 | s = s2; |
| 404 | BOOST_TEST(s == t.v1); |
| 405 | }); |
| 406 | |
| 407 | fail_loop([&](storage_ptr const& sp) |
| 408 | { |
| 409 | std::string c(t.v2.size(), '*'); |
| 410 | string s(c, sp); |
| 411 | string const s2(t.v1); |
| 412 | s = s2; |
| 413 | BOOST_TEST(s == t.v1); |
| 414 | }); |
| 415 | |
| 416 | fail_loop([&](storage_ptr const& sp) |
| 417 | { |
| 418 | std::string c(t.v1.size(), '*'); |
| 419 | string s(c, sp); |
| 420 | string const s2(t.v2); |
| 421 | s = s2; |
| 422 | BOOST_TEST(s == t.v2); |
| 423 | }); |
| 424 | |
| 425 | fail_loop([&](storage_ptr const& sp) |
| 426 | { |
| 427 | std::string c(t.v2.size(), '*'); |
| 428 | string s(c, sp); |
| 429 | string const s2(t.v2); |
| 430 | s = s2; |
| 431 | BOOST_TEST(s == t.v2); |
| 432 | }); |
| 433 | } |
| 434 | |
| 435 | // operator=(string&&) |
| 436 | { |
| 437 | // same storage |
| 438 | |
| 439 | fail_loop([&](storage_ptr const& sp) |
| 440 | { |
| 441 | std::string c(t.v1.size(), '*'); |
| 442 | string s(c, sp); |
| 443 | string s2(t.v1, sp); |
| 444 | s = std::move(s2); |
| 445 | BOOST_TEST(s == t.v1); |
| 446 | BOOST_TEST(s2.empty()); |
| 447 | BOOST_TEST( |
| 448 | *s.storage() == |