| 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 if (m_counter) | 550 if (m_counter) |
| 551 ++*m_counter; | 551 ++*m_counter; |
| 552 return *this; | 552 return *this; |
| 553 } | 553 } |
| 554 | 554 |
| 555 private: | 555 private: |
| 556 int* m_counter; | 556 int* m_counter; |
| 557 }; | 557 }; |
| 558 | 558 |
| 559 TEST(DequeTest, MoveShouldNotMakeCopy) { | 559 TEST(DequeTest, MoveShouldNotMakeCopy) { |
| 560 // Because data in inline buffer may be swapped or moved individually, we forc
e the creation of out-of-line buffer | 560 // Because data in inline buffer may be swapped or moved individually, we |
| 561 // so we can make sure there's no element-wise copy/move. | 561 // force the creation of out-of-line buffer so we can make sure there's no |
| 562 // element-wise copy/move. |
| 562 Deque<CountCopy, 1> deque; | 563 Deque<CountCopy, 1> deque; |
| 563 int counter = 0; | 564 int counter = 0; |
| 564 deque.append(CountCopy(&counter)); | 565 deque.append(CountCopy(&counter)); |
| 565 deque.append(CountCopy(&counter)); | 566 deque.append(CountCopy(&counter)); |
| 566 | 567 |
| 567 Deque<CountCopy, 1> other(deque); | 568 Deque<CountCopy, 1> other(deque); |
| 568 counter = 0; | 569 counter = 0; |
| 569 deque = std::move(other); // Move assignment. | 570 deque = std::move(other); // Move assignment. |
| 570 EXPECT_EQ(0, counter); | 571 EXPECT_EQ(0, counter); |
| 571 | 572 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 598 { | 599 { |
| 599 int i = 1; | 600 int i = 1; |
| 600 for (int v : deque) | 601 for (int v : deque) |
| 601 EXPECT_EQ(i + 2, v); | 602 EXPECT_EQ(i + 2, v); |
| 602 } | 603 } |
| 603 } | 604 } |
| 604 | 605 |
| 605 } // anonymous namespace | 606 } // anonymous namespace |
| 606 | 607 |
| 607 } // namespace WTF | 608 } // namespace WTF |
| OLD | NEW |