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

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

Issue 2310853002: Refactor QualityScaler and MovingAverage (Closed)
Patch Set: update gyp files 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) {
magjed_webrtc 2016/09/07 11:55:16 It's really good that you have added tests! I wou
kthelgason 2016/09/07 12:31:46 Acknowledged.
16 webrtc::MovingAverage moving_average(1024);
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 EXPECT_EQ(*moving_average.GetAverage(0), 0);
24 }
25
26 TEST(MovingAverageTest, Reset) {
27 webrtc::MovingAverage moving_average(5);
28 moving_average.AddSample(1);
29 EXPECT_EQ(1, *moving_average.GetAverage(1));
30 moving_average.Reset();
31 EXPECT_FALSE(moving_average.GetAverage(1));
32 EXPECT_FALSE(moving_average.GetAverage(6));
33 }
34
35 TEST(MovingAverageTest, ManySamples) {
36 webrtc::MovingAverage moving_average(10);
37 for (int i = 1; i < 11; i++) {
38 moving_average.AddSample(i);
39 }
40 EXPECT_EQ(moving_average.GetAverage(), 5);
41 moving_average.Reset();
42 for (int i = 1; i < 2001; i++) {
43 moving_average.AddSample(i);
44 }
45 EXPECT_EQ(moving_average.GetAverage(), 1995);
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698