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

Unified Diff: webrtc/base/rollingaccumulator_unittest.cc

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 years, 6 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 | « webrtc/base/rollingaccumulator.h ('k') | webrtc/base/rtccertificate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/rollingaccumulator_unittest.cc
diff --git a/webrtc/base/rollingaccumulator_unittest.cc b/webrtc/base/rollingaccumulator_unittest.cc
deleted file mode 100644
index 7e3d8cdf0e96a17cfc3c5af96f3a28c5bff8d62a..0000000000000000000000000000000000000000
--- a/webrtc/base/rollingaccumulator_unittest.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2011 The WebRTC Project Authors. All rights reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "webrtc/base/gunit.h"
-#include "webrtc/base/rollingaccumulator.h"
-
-namespace rtc {
-
-namespace {
-
-const double kLearningRate = 0.5;
-
-} // namespace
-
-TEST(RollingAccumulatorTest, ZeroSamples) {
- RollingAccumulator<int> accum(10);
-
- EXPECT_EQ(0U, accum.count());
- EXPECT_DOUBLE_EQ(0.0, accum.ComputeMean());
- EXPECT_DOUBLE_EQ(0.0, accum.ComputeVariance());
- EXPECT_EQ(0, accum.ComputeMin());
- EXPECT_EQ(0, accum.ComputeMax());
-}
-
-TEST(RollingAccumulatorTest, SomeSamples) {
- RollingAccumulator<int> accum(10);
- for (int i = 0; i < 4; ++i) {
- accum.AddSample(i);
- }
-
- EXPECT_EQ(4U, accum.count());
- EXPECT_EQ(6, accum.ComputeSum());
- EXPECT_DOUBLE_EQ(1.5, accum.ComputeMean());
- EXPECT_NEAR(2.26666, accum.ComputeWeightedMean(kLearningRate), 0.01);
- EXPECT_DOUBLE_EQ(1.25, accum.ComputeVariance());
- EXPECT_EQ(0, accum.ComputeMin());
- EXPECT_EQ(3, accum.ComputeMax());
-}
-
-TEST(RollingAccumulatorTest, RollingSamples) {
- RollingAccumulator<int> accum(10);
- for (int i = 0; i < 12; ++i) {
- accum.AddSample(i);
- }
-
- EXPECT_EQ(10U, accum.count());
- EXPECT_EQ(65, accum.ComputeSum());
- EXPECT_DOUBLE_EQ(6.5, accum.ComputeMean());
- EXPECT_NEAR(10.0, accum.ComputeWeightedMean(kLearningRate), 0.01);
- EXPECT_NEAR(9.0, accum.ComputeVariance(), 1.0);
- EXPECT_EQ(2, accum.ComputeMin());
- EXPECT_EQ(11, accum.ComputeMax());
-}
-
-TEST(RollingAccumulatorTest, ResetSamples) {
- RollingAccumulator<int> accum(10);
-
- for (int i = 0; i < 10; ++i) {
- accum.AddSample(100);
- }
- EXPECT_EQ(10U, accum.count());
- EXPECT_DOUBLE_EQ(100.0, accum.ComputeMean());
- EXPECT_EQ(100, accum.ComputeMin());
- EXPECT_EQ(100, accum.ComputeMax());
-
- accum.Reset();
- EXPECT_EQ(0U, accum.count());
-
- for (int i = 0; i < 5; ++i) {
- accum.AddSample(i);
- }
-
- EXPECT_EQ(5U, accum.count());
- EXPECT_EQ(10, accum.ComputeSum());
- EXPECT_DOUBLE_EQ(2.0, accum.ComputeMean());
- EXPECT_EQ(0, accum.ComputeMin());
- EXPECT_EQ(4, accum.ComputeMax());
-}
-
-TEST(RollingAccumulatorTest, RollingSamplesDouble) {
- RollingAccumulator<double> accum(10);
- for (int i = 0; i < 23; ++i) {
- accum.AddSample(5 * i);
- }
-
- EXPECT_EQ(10u, accum.count());
- EXPECT_DOUBLE_EQ(875.0, accum.ComputeSum());
- EXPECT_DOUBLE_EQ(87.5, accum.ComputeMean());
- EXPECT_NEAR(105.049, accum.ComputeWeightedMean(kLearningRate), 0.1);
- EXPECT_NEAR(229.166667, accum.ComputeVariance(), 25);
- EXPECT_DOUBLE_EQ(65.0, accum.ComputeMin());
- EXPECT_DOUBLE_EQ(110.0, accum.ComputeMax());
-}
-
-TEST(RollingAccumulatorTest, ComputeWeightedMeanCornerCases) {
- RollingAccumulator<int> accum(10);
- EXPECT_DOUBLE_EQ(0.0, accum.ComputeWeightedMean(kLearningRate));
- EXPECT_DOUBLE_EQ(0.0, accum.ComputeWeightedMean(0.0));
- EXPECT_DOUBLE_EQ(0.0, accum.ComputeWeightedMean(1.1));
-
- for (int i = 0; i < 8; ++i) {
- accum.AddSample(i);
- }
-
- EXPECT_DOUBLE_EQ(3.5, accum.ComputeMean());
- EXPECT_DOUBLE_EQ(3.5, accum.ComputeWeightedMean(0));
- EXPECT_DOUBLE_EQ(3.5, accum.ComputeWeightedMean(1.1));
- EXPECT_NEAR(6.0, accum.ComputeWeightedMean(kLearningRate), 0.1);
-}
-
-} // namespace rtc
« no previous file with comments | « webrtc/base/rollingaccumulator.h ('k') | webrtc/base/rtccertificate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698