Chromium Code Reviews| Index: tests/RecorderTest.cpp |
| diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp |
| index e04a9e9f6033d1919411cca3d0f5f5f93085de46..8ce9f7b748aaaa02008f42f0ac0115c1442d1b79 100644 |
| --- a/tests/RecorderTest.cpp |
| +++ b/tests/RecorderTest.cpp |
| @@ -8,17 +8,19 @@ |
| static const int kRecordTypes = SK_RECORD_TYPES(COUNT); |
| #undef COUNT |
| -// Tallies the types of commands it sees into histogram. |
| +// Tallies the types of commands it sees into a histogram. |
| class Tally { |
| public: |
| - explicit Tally(int histogram[kRecordTypes]) : fHistogram(histogram) {} |
| + Tally() { bzero(&fHistogram, sizeof(fHistogram)); } |
|
f(malita)
2014/04/08 23:08:31
sk_bzero?
mtklein
2014/04/08 23:11:56
ooooops, done.
|
| - template <typename T> void operator()(const T&) { |
| - ++fHistogram[T::kType]; |
| - } |
| + template <typename T> |
| + void operator()(const T&) { ++fHistogram[T::kType]; } |
| + |
| + template <typename T> |
| + int count() const { return fHistogram[T::kType]; } |
| private: |
| - int* fHistogram; |
| + int fHistogram[kRecordTypes]; |
| }; |
| DEF_TEST(Recorder, r) { |
| @@ -27,10 +29,8 @@ DEF_TEST(Recorder, r) { |
| recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); |
| - int histogram[kRecordTypes]; |
| - bzero(&histogram, sizeof(histogram)); |
| - |
| - record.visit(Tally(histogram)); |
| + Tally tally; |
| + record.visit(tally); |
| - REPORTER_ASSERT(r, 1 == histogram[SkRecords::DrawRect::kType]); |
| + REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); |
| } |