| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 template <typename OwnPtrDeque> | 174 template <typename OwnPtrDeque> |
| 175 void ownPtrTest() { | 175 void ownPtrTest() { |
| 176 int destructNumber = 0; | 176 int destructNumber = 0; |
| 177 OwnPtrDeque deque; | 177 OwnPtrDeque deque; |
| 178 deque.push_back(WTF::wrapUnique(new DestructCounter(0, &destructNumber))); | 178 deque.push_back(WTF::wrapUnique(new DestructCounter(0, &destructNumber))); |
| 179 deque.push_back(WTF::wrapUnique(new DestructCounter(1, &destructNumber))); | 179 deque.push_back(WTF::wrapUnique(new DestructCounter(1, &destructNumber))); |
| 180 EXPECT_EQ(2u, deque.size()); | 180 EXPECT_EQ(2u, deque.size()); |
| 181 | 181 |
| 182 std::unique_ptr<DestructCounter>& counter0 = deque.front(); | 182 std::unique_ptr<DestructCounter>& counter0 = deque.front(); |
| 183 EXPECT_EQ(0, counter0->get()); | 183 EXPECT_EQ(0, counter0->get()); |
| 184 int counter1 = deque.last()->get(); | 184 int counter1 = deque.back()->get(); |
| 185 EXPECT_EQ(1, counter1); | 185 EXPECT_EQ(1, counter1); |
| 186 EXPECT_EQ(0, destructNumber); | 186 EXPECT_EQ(0, destructNumber); |
| 187 | 187 |
| 188 size_t index = 0; | 188 size_t index = 0; |
| 189 for (auto iter = deque.begin(); iter != deque.end(); ++iter) { | 189 for (auto iter = deque.begin(); iter != deque.end(); ++iter) { |
| 190 std::unique_ptr<DestructCounter>& refCounter = *iter; | 190 std::unique_ptr<DestructCounter>& refCounter = *iter; |
| 191 EXPECT_EQ(index, static_cast<size_t>(refCounter->get())); | 191 EXPECT_EQ(index, static_cast<size_t>(refCounter->get())); |
| 192 EXPECT_EQ(index, static_cast<size_t>((*refCounter).get())); | 192 EXPECT_EQ(index, static_cast<size_t>((*refCounter).get())); |
| 193 index++; | 193 index++; |
| 194 } | 194 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 int m_i; | 263 int m_i; |
| 264 }; | 264 }; |
| 265 | 265 |
| 266 TEST(DequeTest, MoveOnlyType) { | 266 TEST(DequeTest, MoveOnlyType) { |
| 267 Deque<MoveOnly> deque; | 267 Deque<MoveOnly> deque; |
| 268 deque.push_back(MoveOnly(1)); | 268 deque.push_back(MoveOnly(1)); |
| 269 deque.push_back(MoveOnly(2)); | 269 deque.push_back(MoveOnly(2)); |
| 270 EXPECT_EQ(2u, deque.size()); | 270 EXPECT_EQ(2u, deque.size()); |
| 271 | 271 |
| 272 ASSERT_EQ(1, deque.front().value()); | 272 ASSERT_EQ(1, deque.front().value()); |
| 273 ASSERT_EQ(2, deque.last().value()); | 273 ASSERT_EQ(2, deque.back().value()); |
| 274 | 274 |
| 275 MoveOnly oldFirst = deque.takeFirst(); | 275 MoveOnly oldFirst = deque.takeFirst(); |
| 276 ASSERT_EQ(1, oldFirst.value()); | 276 ASSERT_EQ(1, oldFirst.value()); |
| 277 EXPECT_EQ(1u, deque.size()); | 277 EXPECT_EQ(1u, deque.size()); |
| 278 | 278 |
| 279 Deque<MoveOnly> otherDeque; | 279 Deque<MoveOnly> otherDeque; |
| 280 deque.swap(otherDeque); | 280 deque.swap(otherDeque); |
| 281 EXPECT_EQ(1u, otherDeque.size()); | 281 EXPECT_EQ(1u, otherDeque.size()); |
| 282 EXPECT_EQ(0u, deque.size()); | 282 EXPECT_EQ(0u, deque.size()); |
| 283 } | 283 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 EXPECT_EQ(2u, deque.size()); | 629 EXPECT_EQ(2u, deque.size()); |
| 630 EXPECT_EQ(3, deque[0].value1); | 630 EXPECT_EQ(3, deque[0].value1); |
| 631 EXPECT_EQ(4, deque[0].value2); | 631 EXPECT_EQ(4, deque[0].value2); |
| 632 EXPECT_EQ(1, deque[1].value1); | 632 EXPECT_EQ(1, deque[1].value1); |
| 633 EXPECT_EQ(2, deque[1].value2); | 633 EXPECT_EQ(2, deque[1].value2); |
| 634 } | 634 } |
| 635 | 635 |
| 636 } // anonymous namespace | 636 } // anonymous namespace |
| 637 | 637 |
| 638 } // namespace WTF | 638 } // namespace WTF |
| OLD | NEW |