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/audio_processing/utility/block_mean_calculator.h" |
11 #include "webrtc/test/gtest.h" | 12 #include "webrtc/test/gtest.h" |
12 | 13 |
13 #include "webrtc/modules/audio_processing/utility/block_mean_calculator.h" | |
14 | |
15 namespace webrtc { | 14 namespace webrtc { |
16 | 15 |
17 TEST(MeanCalculatorTest, Correctness) { | 16 TEST(MeanCalculatorTest, Correctness) { |
18 const size_t kBlockLength = 10; | 17 const size_t kBlockLength = 10; |
19 BlockMeanCalculator mean_calculator(kBlockLength); | 18 BlockMeanCalculator mean_calculator(kBlockLength); |
20 size_t i = 0; | 19 size_t i = 0; |
21 float reference = 0.0; | 20 float reference = 0.0; |
22 | 21 |
23 for (; i < kBlockLength - 1; ++i) { | 22 for (; i < kBlockLength - 1; ++i) { |
24 mean_calculator.AddValue(static_cast<float>(i)); | 23 mean_calculator.AddValue(static_cast<float>(i)); |
(...skipping 25 matching lines...) Expand all Loading... |
50 for (; i < kBlockLength - 1; ++i) { | 49 for (; i < kBlockLength - 1; ++i) { |
51 mean_calculator.AddValue(static_cast<float>(i)); | 50 mean_calculator.AddValue(static_cast<float>(i)); |
52 EXPECT_FALSE(mean_calculator.EndOfBlock()); | 51 EXPECT_FALSE(mean_calculator.EndOfBlock()); |
53 } | 52 } |
54 mean_calculator.AddValue(static_cast<float>(i)); | 53 mean_calculator.AddValue(static_cast<float>(i)); |
55 EXPECT_TRUE(mean_calculator.EndOfBlock()); | 54 EXPECT_TRUE(mean_calculator.EndOfBlock()); |
56 EXPECT_EQ(mean_calculator.GetLatestMean(), 0.5 * (kBlockLength - 1)); | 55 EXPECT_EQ(mean_calculator.GetLatestMean(), 0.5 * (kBlockLength - 1)); |
57 } | 56 } |
58 | 57 |
59 } // namespace webrtc | 58 } // namespace webrtc |
OLD | NEW |