| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 TYPED_TEST(ListOrLinkedHashSetTest, RemoveFirst) { | 48 TYPED_TEST(ListOrLinkedHashSetTest, RemoveFirst) { |
| 49 using Set = TypeParam; | 49 using Set = TypeParam; |
| 50 Set list; | 50 Set list; |
| 51 list.insert(-1); | 51 list.insert(-1); |
| 52 list.insert(0); | 52 list.insert(0); |
| 53 list.insert(1); | 53 list.insert(1); |
| 54 list.insert(2); | 54 list.insert(2); |
| 55 list.insert(3); | 55 list.insert(3); |
| 56 | 56 |
| 57 EXPECT_EQ(-1, list.first()); | 57 EXPECT_EQ(-1, list.front()); |
| 58 EXPECT_EQ(3, list.last()); | 58 EXPECT_EQ(3, list.last()); |
| 59 | 59 |
| 60 list.removeFirst(); | 60 list.removeFirst(); |
| 61 EXPECT_EQ(0, list.first()); | 61 EXPECT_EQ(0, list.front()); |
| 62 | 62 |
| 63 list.removeLast(); | 63 list.removeLast(); |
| 64 EXPECT_EQ(2, list.last()); | 64 EXPECT_EQ(2, list.last()); |
| 65 | 65 |
| 66 list.removeFirst(); | 66 list.removeFirst(); |
| 67 EXPECT_EQ(1, list.first()); | 67 EXPECT_EQ(1, list.front()); |
| 68 | 68 |
| 69 list.removeFirst(); | 69 list.removeFirst(); |
| 70 EXPECT_EQ(2, list.first()); | 70 EXPECT_EQ(2, list.front()); |
| 71 | 71 |
| 72 list.removeFirst(); | 72 list.removeFirst(); |
| 73 EXPECT_TRUE(list.isEmpty()); | 73 EXPECT_TRUE(list.isEmpty()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 TYPED_TEST(ListOrLinkedHashSetTest, AppendOrMoveToLastNewItems) { | 76 TYPED_TEST(ListOrLinkedHashSetTest, AppendOrMoveToLastNewItems) { |
| 77 using Set = TypeParam; | 77 using Set = TypeParam; |
| 78 Set list; | 78 Set list; |
| 79 typename Set::AddResult result = list.appendOrMoveToLast(1); | 79 typename Set::AddResult result = list.appendOrMoveToLast(1); |
| 80 EXPECT_TRUE(result.isNewEntry); | 80 EXPECT_TRUE(result.isNewEntry); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 EXPECT_TRUE(result.isNewEntry); | 165 EXPECT_TRUE(result.isNewEntry); |
| 166 result = list.prependOrMoveToFirst(1); | 166 result = list.prependOrMoveToFirst(1); |
| 167 EXPECT_FALSE(result.isNewEntry); | 167 EXPECT_FALSE(result.isNewEntry); |
| 168 EXPECT_EQ(1UL, list.size()); | 168 EXPECT_EQ(1UL, list.size()); |
| 169 | 169 |
| 170 list.insert(2); | 170 list.insert(2); |
| 171 list.insert(3); | 171 list.insert(3); |
| 172 EXPECT_EQ(3UL, list.size()); | 172 EXPECT_EQ(3UL, list.size()); |
| 173 | 173 |
| 174 // Prepending 2 move it to the beginning. | 174 // Prepending 2 move it to the beginning. |
| 175 EXPECT_EQ(1, list.first()); | 175 EXPECT_EQ(1, list.front()); |
| 176 result = list.prependOrMoveToFirst(2); | 176 result = list.prependOrMoveToFirst(2); |
| 177 EXPECT_FALSE(result.isNewEntry); | 177 EXPECT_FALSE(result.isNewEntry); |
| 178 EXPECT_EQ(2, list.first()); | 178 EXPECT_EQ(2, list.front()); |
| 179 | 179 |
| 180 // Inverse the list by moving each element to the first position. | 180 // Inverse the list by moving each element to the first position. |
| 181 result = list.prependOrMoveToFirst(1); | 181 result = list.prependOrMoveToFirst(1); |
| 182 EXPECT_FALSE(result.isNewEntry); | 182 EXPECT_FALSE(result.isNewEntry); |
| 183 result = list.prependOrMoveToFirst(2); | 183 result = list.prependOrMoveToFirst(2); |
| 184 EXPECT_FALSE(result.isNewEntry); | 184 EXPECT_FALSE(result.isNewEntry); |
| 185 result = list.prependOrMoveToFirst(3); | 185 result = list.prependOrMoveToFirst(3); |
| 186 EXPECT_FALSE(result.isNewEntry); | 186 EXPECT_FALSE(result.isNewEntry); |
| 187 EXPECT_EQ(3UL, list.size()); | 187 EXPECT_EQ(3UL, list.size()); |
| 188 | 188 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 EXPECT_EQ(it, set.end()); | 257 EXPECT_EQ(it, set.end()); |
| 258 --it; | 258 --it; |
| 259 EXPECT_EQ(1, *it); | 259 EXPECT_EQ(1, *it); |
| 260 set.insertBefore(it, -1); | 260 set.insertBefore(it, -1); |
| 261 set.insertBefore(it, 0); | 261 set.insertBefore(it, 0); |
| 262 set.insert(2); | 262 set.insert(2); |
| 263 set.insert(3); | 263 set.insert(3); |
| 264 } | 264 } |
| 265 set.insertBefore(2, 42); | 265 set.insertBefore(2, 42); |
| 266 set.insertBefore(-1, 103); | 266 set.insertBefore(-1, 103); |
| 267 EXPECT_EQ(103, set.first()); | 267 EXPECT_EQ(103, set.front()); |
| 268 if (!canModifyWhileIterating) | 268 if (!canModifyWhileIterating) |
| 269 it = set.find(1); | 269 it = set.find(1); |
| 270 ++it; | 270 ++it; |
| 271 EXPECT_EQ(42, *it); | 271 EXPECT_EQ(42, *it); |
| 272 EXPECT_EQ(7u, set.size()); | 272 EXPECT_EQ(7u, set.size()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 TYPED_TEST(ListOrLinkedHashSetTest, AddReturnIterator) { | 275 TYPED_TEST(ListOrLinkedHashSetTest, AddReturnIterator) { |
| 276 using Set = TypeParam; | 276 using Set = TypeParam; |
| 277 bool canModifyWhileIterating = !std::is_same<Set, LinkedHashSet<int>>::value; | 277 bool canModifyWhileIterating = !std::is_same<Set, LinkedHashSet<int>>::value; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 using Set = TypeParam; | 401 using Set = TypeParam; |
| 402 bool isDeleted = false; | 402 bool isDeleted = false; |
| 403 DummyRefCounted::m_refInvokesCount = 0; | 403 DummyRefCounted::m_refInvokesCount = 0; |
| 404 RefPtr<DummyRefCounted> ptr = adoptRef(new DummyRefCounted(isDeleted)); | 404 RefPtr<DummyRefCounted> ptr = adoptRef(new DummyRefCounted(isDeleted)); |
| 405 EXPECT_EQ(0, DummyRefCounted::m_refInvokesCount); | 405 EXPECT_EQ(0, DummyRefCounted::m_refInvokesCount); |
| 406 | 406 |
| 407 Set set; | 407 Set set; |
| 408 set.insert(ptr); | 408 set.insert(ptr); |
| 409 // Referenced only once (to store a copy in the container). | 409 // Referenced only once (to store a copy in the container). |
| 410 EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount); | 410 EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount); |
| 411 EXPECT_EQ(ptr, set.first()); | 411 EXPECT_EQ(ptr, set.front()); |
| 412 EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount); | 412 EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount); |
| 413 | 413 |
| 414 DummyRefCounted* rawPtr = ptr.get(); | 414 DummyRefCounted* rawPtr = ptr.get(); |
| 415 | 415 |
| 416 EXPECT_TRUE(set.contains(ptr)); | 416 EXPECT_TRUE(set.contains(ptr)); |
| 417 EXPECT_TRUE(set.contains(rawPtr)); | 417 EXPECT_TRUE(set.contains(rawPtr)); |
| 418 EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount); | 418 EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount); |
| 419 | 419 |
| 420 ptr.clear(); | 420 ptr.clear(); |
| 421 EXPECT_FALSE(isDeleted); | 421 EXPECT_FALSE(isDeleted); |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 813 |
| 814 // ... but they don't have any pass-out (like take()) methods. | 814 // ... but they don't have any pass-out (like take()) methods. |
| 815 | 815 |
| 816 set.remove(MoveOnly(3)); | 816 set.remove(MoveOnly(3)); |
| 817 set.clear(); | 817 set.clear(); |
| 818 } | 818 } |
| 819 | 819 |
| 820 } // anonymous namespace | 820 } // anonymous namespace |
| 821 | 821 |
| 822 } // namespace WTF | 822 } // namespace WTF |
| OLD | NEW |