OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/video_coding/utility/moving_average.h" | 11 #include "webrtc/modules/video_coding/utility/moving_average.h" |
12 | 12 |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "webrtc/test/gtest.h" |
14 | 14 |
15 TEST(MovingAverageTest, EmptyAverage) { | 15 TEST(MovingAverageTest, EmptyAverage) { |
16 webrtc::MovingAverage moving_average(1); | 16 webrtc::MovingAverage moving_average(1); |
17 EXPECT_EQ(0u, moving_average.size()); | 17 EXPECT_EQ(0u, moving_average.size()); |
18 EXPECT_FALSE(moving_average.GetAverage(0)); | 18 EXPECT_FALSE(moving_average.GetAverage(0)); |
19 } | 19 } |
20 | 20 |
21 // Test single value. | 21 // Test single value. |
22 TEST(MovingAverageTest, OneElement) { | 22 TEST(MovingAverageTest, OneElement) { |
23 webrtc::MovingAverage moving_average(1); | 23 webrtc::MovingAverage moving_average(1); |
(...skipping 29 matching lines...) Expand all Loading... |
53 for (int i = 1; i < 11; i++) { | 53 for (int i = 1; i < 11; i++) { |
54 moving_average.AddSample(i); | 54 moving_average.AddSample(i); |
55 } | 55 } |
56 EXPECT_EQ(*moving_average.GetAverage(), 5); | 56 EXPECT_EQ(*moving_average.GetAverage(), 5); |
57 moving_average.Reset(); | 57 moving_average.Reset(); |
58 for (int i = 1; i < 2001; i++) { | 58 for (int i = 1; i < 2001; i++) { |
59 moving_average.AddSample(i); | 59 moving_average.AddSample(i); |
60 } | 60 } |
61 EXPECT_EQ(*moving_average.GetAverage(), 1995); | 61 EXPECT_EQ(*moving_average.GetAverage(), 1995); |
62 } | 62 } |
OLD | NEW |