| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "base/metrics/persistent_sample_map.h" | 5 #include "base/metrics/persistent_sample_map.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/persistent_histogram_allocator.h" | 10 #include "base/metrics/persistent_histogram_allocator.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 it->Get(&min, &max, &count); | 227 it->Get(&min, &max, &count); |
| 228 EXPECT_EQ(15, min); | 228 EXPECT_EQ(15, min); |
| 229 EXPECT_EQ(16, max); | 229 EXPECT_EQ(16, max); |
| 230 EXPECT_EQ(3, count); | 230 EXPECT_EQ(3, count); |
| 231 | 231 |
| 232 it->Next(); | 232 it->Next(); |
| 233 EXPECT_TRUE(it->Done()); | 233 EXPECT_TRUE(it->Done()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Only run this test on builds that support catching a DCHECK crash. | 236 // Only run this test on builds that support catching a DCHECK crash. |
| 237 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST | 237 #if DCHECK_IS_ON() && GTEST_HAS_DEATH_TEST |
| 238 TEST(PersistentSampleMapIteratorDeathTest, IterateDoneTest) { | 238 TEST(PersistentSampleMapIteratorDeathTest, IterateDoneTest) { |
| 239 std::unique_ptr<PersistentHistogramAllocator> allocator = | 239 std::unique_ptr<PersistentHistogramAllocator> allocator = |
| 240 CreateHistogramAllocator(64 << 10); // 64 KiB | 240 CreateHistogramAllocator(64 << 10); // 64 KiB |
| 241 HistogramSamples::Metadata meta; | 241 HistogramSamples::Metadata meta; |
| 242 PersistentSampleMap samples(1, allocator.get(), &meta); | 242 PersistentSampleMap samples(1, allocator.get(), &meta); |
| 243 | 243 |
| 244 std::unique_ptr<SampleCountIterator> it = samples.Iterator(); | 244 std::unique_ptr<SampleCountIterator> it = samples.Iterator(); |
| 245 | 245 |
| 246 EXPECT_TRUE(it->Done()); | 246 EXPECT_TRUE(it->Done()); |
| 247 | 247 |
| 248 HistogramBase::Sample min; | 248 HistogramBase::Sample min; |
| 249 HistogramBase::Sample max; | 249 HistogramBase::Sample max; |
| 250 HistogramBase::Count count; | 250 HistogramBase::Count count; |
| 251 EXPECT_DEATH(it->Get(&min, &max, &count), ""); | 251 EXPECT_DEATH(it->Get(&min, &max, &count), ""); |
| 252 | 252 |
| 253 EXPECT_DEATH(it->Next(), ""); | 253 EXPECT_DEATH(it->Next(), ""); |
| 254 | 254 |
| 255 samples.Accumulate(1, 100); | 255 samples.Accumulate(1, 100); |
| 256 it = samples.Iterator(); | 256 it = samples.Iterator(); |
| 257 EXPECT_FALSE(it->Done()); | 257 EXPECT_FALSE(it->Done()); |
| 258 } | 258 } |
| 259 #endif | 259 #endif |
| 260 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST | 260 // DCHECK_IS_ON() && GTEST_HAS_DEATH_TEST |
| 261 | 261 |
| 262 } // namespace | 262 } // namespace |
| 263 } // namespace base | 263 } // namespace base |
| OLD | NEW |