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

Side by Side Diff: webrtc/modules/video_coding/utility/moving_average_unittest.cc

Issue 2310853002: Refactor QualityScaler and MovingAverage (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/video_coding/utility/moving_average.h"
12
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 TEST(MovingAverageTest, GetAverage) {
16 webrtc::MovingAverage moving_average;
17 moving_average.AddSample(1);
18 moving_average.AddSample(1);
19 moving_average.AddSample(3);
20 moving_average.AddSample(3);
21 EXPECT_EQ(moving_average.GetAverage(4), 2);
22 EXPECT_EQ(moving_average.GetAverage(2), 3);
23 }
24
25 TEST(MovingAverageTest, Reset) {
26 webrtc::MovingAverage moving_average;
27 moving_average.AddSample(1);
28 EXPECT_EQ(1, moving_average.GetAverage(1));
29 moving_average.Reset();
30 EXPECT_EQ(0, moving_average.GetAverage(1));
31 }
32
33 TEST(MovingAverageTest, ManySamples) {
34 webrtc::MovingAverage moving_average(10);
35 for (int i = 1; i < 11; i++) {
36 moving_average.AddSample(i);
37 }
38 EXPECT_EQ(moving_average.GetAverage(), 5);
39 moving_average.Reset();
40 for (int i = 1; i < 2001; i++) {
41 moving_average.AddSample(i);
42 }
43 EXPECT_EQ(moving_average.GetAverage(), 1995);
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698