| 683 | // Test shrink_to_fit for heap-based containers |
| 684 | template<typename Container> |
| 685 | void test_container_shrink_to_fit() { |
| 686 | Container c; |
| 687 | |
| 688 | // Add many elements |
| 689 | for (int i = 0; i < 50; ++i) { |
| 690 | populate(c, make_shared_int(i)); |
| 691 | } |
| 692 | // Test capacity() - COMPILER ERROR if capacity() doesn't exist |
| 693 | auto large_capacity = c.capacity(); |
| 694 | FL_CHECK(large_capacity > 50); |
| 695 | |
| 696 | // Remove most elements |
| 697 | for (int i = 0; i < 40; ++i) { |
| 698 | c.pop_back(); |
| 699 | } |
| 700 | FL_CHECK(c.capacity() >= large_capacity); // Capacity not reduced yet |
| 701 | |
| 702 | // Shrink - COMPILER ERROR if shrink_to_fit() doesn't exist |
| 703 | c.shrink_to_fit(); |
| 704 | FL_CHECK(c.capacity() <= large_capacity); // Should be reduced |
| 705 | FL_CHECK(c.size() == 10); // Size preserved |
| 706 | } |
| 707 | |
| 708 | // Test max_size |
| 709 | template<typename Container> |
nothing calls this directly
no test coverage detected