Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: tests/LListTest.cpp

Issue 1459663002: simplify insertion methods for SkTLList (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix gcc? Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkRandom.h" 8 #include "SkRandom.h"
9 #include "SkTInternalLList.h" 9 #include "SkTInternalLList.h"
10 #include "SkTLList.h" 10 #include "SkTLList.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 REPORTER_ASSERT(reporter, iter1.get()->fID == iter2.get()->fID); 145 REPORTER_ASSERT(reporter, iter1.get()->fID == iter2.get()->fID);
146 iter3.init(list2, Iter::kHead_IterStart); 146 iter3.init(list2, Iter::kHead_IterStart);
147 iter4.init(list2, Iter::kTail_IterStart); 147 iter4.init(list2, Iter::kTail_IterStart);
148 REPORTER_ASSERT(reporter, iter3.get()->fID == iter1.get()->fID); 148 REPORTER_ASSERT(reporter, iter3.get()->fID == iter1.get()->fID);
149 REPORTER_ASSERT(reporter, iter4.get()->fID == iter1.get()->fID); 149 REPORTER_ASSERT(reporter, iter4.get()->fID == iter1.get()->fID);
150 REPORTER_ASSERT(reporter, list1 == list2); 150 REPORTER_ASSERT(reporter, list1 == list2);
151 151
152 list2.reset(); 152 list2.reset();
153 153
154 // use both before/after in-place construction on an empty list 154 // use both before/after in-place construction on an empty list
155 SkNEW_INSERT_IN_LLIST_BEFORE(&list2, list2.headIter(), ListElement, (1)) ; 155 list2.addBefore(list2.headIter(), 1);
156 REPORTER_ASSERT(reporter, list2 == list1); 156 REPORTER_ASSERT(reporter, list2 == list1);
157 list2.reset(); 157 list2.reset();
158 158
159 SkNEW_INSERT_IN_LLIST_AFTER(&list2, list2.tailIter(), ListElement, (1)); 159 list2.addAfter(list2.tailIter(), 1);
160 REPORTER_ASSERT(reporter, list2 == list1); 160 REPORTER_ASSERT(reporter, list2 == list1);
161 161
162 // add an element to the second list, check that iters are still valid 162 // add an element to the second list, check that iters are still valid
163 iter3.init(list2, Iter::kHead_IterStart); 163 iter3.init(list2, Iter::kHead_IterStart);
164 iter4.init(list2, Iter::kTail_IterStart); 164 iter4.init(list2, Iter::kTail_IterStart);
165 list2.addToHead(ListElement(2)); 165 list2.addToHead(ListElement(2));
166 166
167 REPORTER_ASSERT(reporter, iter3.get()->fID == iter1.get()->fID); 167 REPORTER_ASSERT(reporter, iter3.get()->fID == iter1.get()->fID);
168 REPORTER_ASSERT(reporter, iter4.get()->fID == iter1.get()->fID); 168 REPORTER_ASSERT(reporter, iter4.get()->fID == iter1.get()->fID);
169 REPORTER_ASSERT(reporter, 1 == Iter(list2, Iter::kTail_IterStart).get()- >fID); 169 REPORTER_ASSERT(reporter, 1 == Iter(list2, Iter::kTail_IterStart).get()- >fID);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 Iter prev(iter); 204 Iter prev(iter);
205 Iter next(iter); 205 Iter next(iter);
206 next.next(); 206 next.next();
207 prev.prev(); 207 prev.prev();
208 208
209 SkASSERT(iter.get()); 209 SkASSERT(iter.get());
210 // insert either before or after the iterator, then chec k that the 210 // insert either before or after the iterator, then chec k that the
211 // surrounding sequence is correct. 211 // surrounding sequence is correct.
212 if (2 == insertionMethod) { 212 if (2 == insertionMethod) {
213 SkNEW_INSERT_IN_LLIST_BEFORE(&list1, iter, ListEleme nt, (id)); 213 list1.addBefore(iter, id);
214 Iter newItem(iter); 214 Iter newItem(iter);
215 newItem.prev(); 215 newItem.prev();
216 REPORTER_ASSERT(reporter, newItem.get()->fID == id); 216 REPORTER_ASSERT(reporter, newItem.get()->fID == id);
217 217
218 if (next.get()) { 218 if (next.get()) {
219 REPORTER_ASSERT(reporter, next.prev()->fID == it er.get()->fID); 219 REPORTER_ASSERT(reporter, next.prev()->fID == it er.get()->fID);
220 } 220 }
221 if (prev.get()) { 221 if (prev.get()) {
222 REPORTER_ASSERT(reporter, prev.next()->fID == id ); 222 REPORTER_ASSERT(reporter, prev.next()->fID == id );
223 } 223 }
224 } else { 224 } else {
225 SkNEW_INSERT_IN_LLIST_AFTER(&list1, iter, ListElemen t, (id)); 225 list1.addAfter(iter, id);
226 Iter newItem(iter); 226 Iter newItem(iter);
227 newItem.next(); 227 newItem.next();
228 REPORTER_ASSERT(reporter, newItem.get()->fID == id); 228 REPORTER_ASSERT(reporter, newItem.get()->fID == id);
229 229
230 if (next.get()) { 230 if (next.get()) {
231 REPORTER_ASSERT(reporter, next.prev()->fID == id ); 231 REPORTER_ASSERT(reporter, next.prev()->fID == id );
232 } 232 }
233 if (prev.get()) { 233 if (prev.get()) {
234 REPORTER_ASSERT(reporter, prev.next()->fID == it er.get()->fID); 234 REPORTER_ASSERT(reporter, prev.next()->fID == it er.get()->fID);
235 } 235 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 REPORTER_ASSERT(reporter, count == list1.count()); 279 REPORTER_ASSERT(reporter, count == list1.count());
280 } 280 }
281 list1.reset(); 281 list1.reset();
282 } 282 }
283 } 283 }
284 284
285 DEF_TEST(LList, reporter) { 285 DEF_TEST(LList, reporter) {
286 TestTInternalLList(reporter); 286 TestTInternalLList(reporter);
287 TestTLList(reporter); 287 TestTLList(reporter);
288 } 288 }
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698