| 342 | } |
| 343 | |
| 344 | void TPointerTest::TestIntrPtr() { |
| 345 | { |
| 346 | TIntrusivePtr<TOp> p, p2; |
| 347 | TOp3 op3; |
| 348 | { |
| 349 | TVector<TIntrusivePtr<TOp>> f1; |
| 350 | { |
| 351 | TVector<TIntrusivePtr<TOp>> f2; |
| 352 | f2.push_back(new TOp); |
| 353 | p = new TOp; |
| 354 | f2.push_back(p); |
| 355 | Attach(&op3, &f2[1]); |
| 356 | f1 = f2; |
| 357 | UNIT_ASSERT_VALUES_EQUAL(f1[0]->RefCount(), 2); |
| 358 | UNIT_ASSERT_VALUES_EQUAL(f1[1]->RefCount(), 3); |
| 359 | UNIT_ASSERT_EQUAL(f1[1].Get(), op3.Op2.Get()); |
| 360 | UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 3); |
| 361 | UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 2); |
| 362 | UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 4); |
| 363 | } |
| 364 | p2 = p; |
| 365 | } |
| 366 | UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 1); |
| 367 | UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 3); |
| 368 | UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 3); |
| 369 | } |
| 370 | UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0); |
| 371 | } |
| 372 | |
| 373 | namespace NTestIntrusiveConvertion { |
| 374 | struct TA: public TSimpleRefCount<TA> { |