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

Unified Diff: base/metrics/sparse_histogram_unittest.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/sparse_histogram_unittest.cc
diff --git a/base/metrics/sparse_histogram_unittest.cc b/base/metrics/sparse_histogram_unittest.cc
index 5d5dbcbb9b1fb6bc79871c83f84de0e4f748d703..6cddd1fdb16d635c617482f94bdb6c693dfea6b7 100644
--- a/base/metrics/sparse_histogram_unittest.cc
+++ b/base/metrics/sparse_histogram_unittest.cc
@@ -4,9 +4,9 @@
#include "base/metrics/sparse_histogram.h"
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/persistent_histogram_allocator.h"
@@ -73,14 +73,14 @@ class SparseHistogramTest : public testing::TestWithParam<bool> {
PersistentHistogramAllocator::ReleaseGlobalAllocatorForTesting();
}
- scoped_ptr<SparseHistogram> NewSparseHistogram(const std::string& name) {
- return scoped_ptr<SparseHistogram>(new SparseHistogram(name));
+ std::unique_ptr<SparseHistogram> NewSparseHistogram(const std::string& name) {
+ return std::unique_ptr<SparseHistogram>(new SparseHistogram(name));
}
const bool use_persistent_histogram_allocator_;
StatisticsRecorder* statistics_recorder_;
- scoped_ptr<char[]> allocator_memory_;
+ std::unique_ptr<char[]> allocator_memory_;
PersistentMemoryAllocator* allocator_ = nullptr;
private:
@@ -94,57 +94,57 @@ INSTANTIATE_TEST_CASE_P(HeapAndPersistent,
TEST_P(SparseHistogramTest, BasicTest) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
- scoped_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
EXPECT_EQ(0, snapshot->TotalCount());
EXPECT_EQ(0, snapshot->sum());
histogram->Add(100);
- scoped_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
EXPECT_EQ(1, snapshot1->TotalCount());
EXPECT_EQ(1, snapshot1->GetCount(100));
histogram->Add(100);
histogram->Add(101);
- scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
EXPECT_EQ(3, snapshot2->TotalCount());
EXPECT_EQ(2, snapshot2->GetCount(100));
EXPECT_EQ(1, snapshot2->GetCount(101));
}
TEST_P(SparseHistogramTest, BasicTestAddCount) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
- scoped_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
EXPECT_EQ(0, snapshot->TotalCount());
EXPECT_EQ(0, snapshot->sum());
histogram->AddCount(100, 15);
- scoped_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
EXPECT_EQ(15, snapshot1->TotalCount());
EXPECT_EQ(15, snapshot1->GetCount(100));
histogram->AddCount(100, 15);
histogram->AddCount(101, 25);
- scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
EXPECT_EQ(55, snapshot2->TotalCount());
EXPECT_EQ(30, snapshot2->GetCount(100));
EXPECT_EQ(25, snapshot2->GetCount(101));
}
TEST_P(SparseHistogramTest, AddCount_LargeValuesDontOverflow) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
- scoped_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
EXPECT_EQ(0, snapshot->TotalCount());
EXPECT_EQ(0, snapshot->sum());
histogram->AddCount(1000000000, 15);
- scoped_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
EXPECT_EQ(15, snapshot1->TotalCount());
EXPECT_EQ(15, snapshot1->GetCount(1000000000));
histogram->AddCount(1000000000, 15);
histogram->AddCount(1010000000, 25);
- scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
EXPECT_EQ(55, snapshot2->TotalCount());
EXPECT_EQ(30, snapshot2->GetCount(1000000000));
EXPECT_EQ(25, snapshot2->GetCount(1010000000));
@@ -170,7 +170,8 @@ TEST_P(SparseHistogramTest, MacroBasicTest) {
: 0),
sparse_histogram->flags());
- scoped_ptr<HistogramSamples> samples = sparse_histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples =
+ sparse_histogram->SnapshotSamples();
EXPECT_EQ(3, samples->TotalCount());
EXPECT_EQ(2, samples->GetCount(100));
EXPECT_EQ(1, samples->GetCount(200));
@@ -195,7 +196,7 @@ TEST_P(SparseHistogramTest, MacroInLoopTest) {
}
TEST_P(SparseHistogramTest, Serialize) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
histogram->SetFlags(HistogramBase::kIPCSerializationSourceFlag);
Pickle pickle;
« no previous file with comments | « base/metrics/sparse_histogram.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698