This test check a potential issue with empty base class * optimization. Some compilers (VC6) do not implement it * correctly resulting ina wrong behavior. */
| 423 | * optimization. Some compilers (VC6) do not implement it |
| 424 | * correctly resulting ina wrong behavior. */ |
| 425 | void TestEbo() { |
| 426 | // We use heap memory as test failure can corrupt vector internal |
| 427 | // representation making executable crash on vector destructor invocation. |
| 428 | // We prefer a simple memory leak, internal corruption should be reveal |
| 429 | // by size or capacity checks. |
| 430 | using V = TVector<int>; |
| 431 | V* pv1 = new V(1, 1); |
| 432 | V* pv2 = new V(10, 2); |
| 433 | |
| 434 | size_t v1Capacity = pv1->capacity(); |
| 435 | size_t v2Capacity = pv2->capacity(); |
| 436 | |
| 437 | pv1->swap(*pv2); |
| 438 | |
| 439 | UNIT_ASSERT(pv1->size() == 10); |
| 440 | UNIT_ASSERT(pv1->capacity() == v2Capacity); |
| 441 | UNIT_ASSERT((*pv1)[5] == 2); |
| 442 | |
| 443 | UNIT_ASSERT(pv2->size() == 1); |
| 444 | UNIT_ASSERT(pv2->capacity() == v1Capacity); |
| 445 | UNIT_ASSERT((*pv2)[0] == 1); |
| 446 | |
| 447 | delete pv2; |
| 448 | delete pv1; |
| 449 | } |
| 450 | |
| 451 | void TestFillInConstructor() { |
| 452 | for (int k = 0; k < 3; ++k) { |