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

Side by Side Diff: components/metrics/leak_detector/ranked_set_unittest.cc

Issue 1870233003: Record call site history in LeakDetectorImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify comments in RankedSet Created 4 years, 8 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
« no previous file with comments | « components/metrics/leak_detector/ranked_set.cc ('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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/leak_detector/ranked_set.h" 5 #include "components/metrics/leak_detector/ranked_set.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 size_t index = 0; 314 size_t index = 0;
315 for (const auto& entry : dest) { 315 for (const auto& entry : dest) {
316 EXPECT_LT(index, arraysize(kExpectedValues)); 316 EXPECT_LT(index, arraysize(kExpectedValues));
317 EXPECT_EQ(kExpectedValues[index].value.size(), entry.value.size()); 317 EXPECT_EQ(kExpectedValues[index].value.size(), entry.value.size());
318 EXPECT_EQ(kExpectedValues[index].count, entry.count); 318 EXPECT_EQ(kExpectedValues[index].count, entry.count);
319 ++index; 319 ++index;
320 } 320 }
321 } 321 }
322 322
323 TEST_F(RankedSetTest, Find) {
324 RankedSet set(10);
325 EXPECT_EQ(0U, set.size());
326
327 set.AddSize(0x1234, 15);
328 set.AddSize(0x2345, 20);
329 set.AddSize(0x3456, 10);
330 set.AddSize(0x4567, 30);
331 set.AddSize(0x5678, 25);
332 EXPECT_EQ(5U, set.size());
333
334 auto iter = set.FindSize(0x1234);
335 EXPECT_TRUE(iter != set.end());
336 EXPECT_EQ(0x1234U, iter->value.size());
337 EXPECT_EQ(15, iter->count);
338
339 iter = set.FindSize(0x2345);
340 EXPECT_TRUE(iter != set.end());
341 EXPECT_EQ(0x2345U, iter->value.size());
342 EXPECT_EQ(20, iter->count);
343
344 iter = set.FindSize(0x3456);
345 EXPECT_TRUE(iter != set.end());
346 EXPECT_EQ(0x3456U, iter->value.size());
347 EXPECT_EQ(10, iter->count);
348
349 iter = set.FindSize(0x4567);
350 EXPECT_TRUE(iter != set.end());
351 EXPECT_EQ(0x4567U, iter->value.size());
352 EXPECT_EQ(30, iter->count);
353
354 iter = set.FindSize(0x5678);
355 EXPECT_TRUE(iter != set.end());
356 EXPECT_EQ(0x5678U, iter->value.size());
357 EXPECT_EQ(25, iter->count);
358 }
359
323 } // namespace leak_detector 360 } // namespace leak_detector
324 } // namespace metrics 361 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/leak_detector/ranked_set.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698