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

Side by Side Diff: third_party/WebKit/Source/platform/PODRedBlackTreeTest.cpp

Issue 2615813003: Migrate WTF::Vector::append() to ::push_back() [part 14 of N] (Closed)
Patch Set: rebase, small fix in FontSettings.h Created 3 years, 11 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void InsertionAndDeletionTest(const int32_t seed, const int treeSize) { 163 void InsertionAndDeletionTest(const int32_t seed, const int treeSize) {
164 initRandom(seed); 164 initRandom(seed);
165 const int maximumValue = treeSize; 165 const int maximumValue = treeSize;
166 // Build the tree. 166 // Build the tree.
167 PODRedBlackTree<int> tree; 167 PODRedBlackTree<int> tree;
168 Vector<int> values; 168 Vector<int> values;
169 for (int i = 0; i < treeSize; i++) { 169 for (int i = 0; i < treeSize; i++) {
170 int value = nextRandom(maximumValue); 170 int value = nextRandom(maximumValue);
171 tree.add(value); 171 tree.add(value);
172 ASSERT_TRUE(tree.checkInvariants()) << "Test failed for seed " << seed; 172 ASSERT_TRUE(tree.checkInvariants()) << "Test failed for seed " << seed;
173 values.append(value); 173 values.push_back(value);
174 } 174 }
175 // Churn the tree's contents. 175 // Churn the tree's contents.
176 for (int i = 0; i < treeSize; i++) { 176 for (int i = 0; i < treeSize; i++) {
177 // Pick a random value to remove. 177 // Pick a random value to remove.
178 int index = nextRandom(treeSize); 178 int index = nextRandom(treeSize);
179 int value = values[index]; 179 int value = values[index];
180 // Remove this value. 180 // Remove this value.
181 tree.remove(value); 181 tree.remove(value);
182 ASSERT_TRUE(tree.checkInvariants()) << "Test failed for seed " << seed; 182 ASSERT_TRUE(tree.checkInvariants()) << "Test failed for seed " << seed;
183 // Replace it with a new one. 183 // Replace it with a new one.
184 value = nextRandom(maximumValue); 184 value = nextRandom(maximumValue);
185 values[index] = value; 185 values[index] = value;
186 tree.add(value); 186 tree.add(value);
187 ASSERT_TRUE(tree.checkInvariants()) << "Test failed for seed " << seed; 187 ASSERT_TRUE(tree.checkInvariants()) << "Test failed for seed " << seed;
188 } 188 }
189 } 189 }
190 } // anonymous namespace 190 } // anonymous namespace
191 191
192 TEST(PODRedBlackTreeTest, RandomDeletionAndInsertionRegressionTest1) { 192 TEST(PODRedBlackTreeTest, RandomDeletionAndInsertionRegressionTest1) {
193 InsertionAndDeletionTest(12311, 100); 193 InsertionAndDeletionTest(12311, 100);
194 } 194 }
195 195
196 } // namespace blink 196 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/PODIntervalTreeTest.cpp ('k') | third_party/WebKit/Source/platform/SharedBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698