| 453 | } |
| 454 | |
| 455 | void TListTest::TestListWithAutoDeleteClear() { |
| 456 | using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>; |
| 457 | int counter{0}; |
| 458 | { |
| 459 | TListType lst; |
| 460 | UNIT_ASSERT(lst.Empty()); |
| 461 | lst.PushFront(new TSelfCountingInt(counter, 2)); |
| 462 | UNIT_ASSERT_EQUAL(lst.Size(), 1); |
| 463 | UNIT_ASSERT_EQUAL(counter, 1); |
| 464 | lst.PushFront(new TSelfCountingInt(counter, 1)); |
| 465 | UNIT_ASSERT_EQUAL(lst.Size(), 2); |
| 466 | UNIT_ASSERT_EQUAL(counter, 2); |
| 467 | CheckList(lst); |
| 468 | |
| 469 | lst.Clear(); |
| 470 | UNIT_ASSERT(lst.Empty()); |
| 471 | UNIT_ASSERT_EQUAL(counter, 0); |
| 472 | lst.PushFront(new TSelfCountingInt(counter, 1)); |
| 473 | UNIT_ASSERT_EQUAL(lst.Size(), 1); |
| 474 | } |
| 475 | |
| 476 | UNIT_ASSERT_EQUAL(counter, 0); |
| 477 | } |
| 478 | |
| 479 | struct TSecondTag {}; |
| 480 | |