| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 Deque<CountCopy, 1> other(deque); | 598 Deque<CountCopy, 1> other(deque); |
| 599 counter = 0; | 599 counter = 0; |
| 600 deque = std::move(other); // Move assignment. | 600 deque = std::move(other); // Move assignment. |
| 601 EXPECT_EQ(0, counter); | 601 EXPECT_EQ(0, counter); |
| 602 | 602 |
| 603 counter = 0; | 603 counter = 0; |
| 604 Deque<CountCopy, 1> yetAnother(std::move(deque)); // Move construction. | 604 Deque<CountCopy, 1> yetAnother(std::move(deque)); // Move construction. |
| 605 EXPECT_EQ(0, counter); | 605 EXPECT_EQ(0, counter); |
| 606 } | 606 } |
| 607 | 607 |
| 608 TEST(DequeTest, RemoveWhileIterating) |
| 609 { |
| 610 Deque<int> deque; |
| 611 for (int i = 0; i < 10; ++i) |
| 612 deque.append(i); |
| 613 |
| 614 // All numbers present. |
| 615 { |
| 616 int i = 0; |
| 617 for (int v : deque) |
| 618 EXPECT_EQ(i++, v); |
| 619 } |
| 620 |
| 621 // Remove the even numbers while iterating. |
| 622 for (auto it = deque.begin(); it != deque.end(); ++it) { |
| 623 if (*it % 2 == 0) { |
| 624 deque.remove(it); |
| 625 --it; |
| 626 } |
| 627 } |
| 628 |
| 629 // Only odd numbers left. |
| 630 { |
| 631 int i = 1; |
| 632 for (int v : deque) |
| 633 EXPECT_EQ(i + 2, v); |
| 634 } |
| 635 } |
| 636 |
| 608 } // anonymous namespace | 637 } // anonymous namespace |
| 609 | 638 |
| 610 } // namespace WTF | 639 } // namespace WTF |
| OLD | NEW |