| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Tests UpdateFactor. | 42 // Tests UpdateFactor. |
| 43 TEST(IntelligibilityUtilsTest, TestUpdateFactor) { | 43 TEST(IntelligibilityUtilsTest, TestUpdateFactor) { |
| 44 EXPECT_EQ(0, intelligibility::UpdateFactor(0, 0, 0)); | 44 EXPECT_EQ(0, intelligibility::UpdateFactor(0, 0, 0)); |
| 45 EXPECT_EQ(4, intelligibility::UpdateFactor(4, 2, 3)); | 45 EXPECT_EQ(4, intelligibility::UpdateFactor(4, 2, 3)); |
| 46 EXPECT_EQ(3, intelligibility::UpdateFactor(4, 2, 1)); | 46 EXPECT_EQ(3, intelligibility::UpdateFactor(4, 2, 1)); |
| 47 EXPECT_EQ(2, intelligibility::UpdateFactor(2, 4, 3)); | 47 EXPECT_EQ(2, intelligibility::UpdateFactor(2, 4, 3)); |
| 48 EXPECT_EQ(3, intelligibility::UpdateFactor(2, 4, 1)); | 48 EXPECT_EQ(3, intelligibility::UpdateFactor(2, 4, 1)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Tests cplxfinite, cplxnormal, and zerofudge. | 51 // Tests zerofudge. |
| 52 TEST(IntelligibilityUtilsTest, TestCplx) { | 52 TEST(IntelligibilityUtilsTest, TestCplx) { |
| 53 complex<float> t0(1.f, 0.f); | 53 complex<float> t0(1.f, 0.f); |
| 54 EXPECT_TRUE(intelligibility::cplxfinite(t0)); | |
| 55 EXPECT_FALSE(intelligibility::cplxnormal(t0)); | |
| 56 t0 = intelligibility::zerofudge(t0); | 54 t0 = intelligibility::zerofudge(t0); |
| 57 EXPECT_NE(t0.imag(), 0.f); | 55 EXPECT_NE(t0.imag(), 0.f); |
| 58 EXPECT_NE(t0.real(), 0.f); | 56 EXPECT_NE(t0.real(), 0.f); |
| 59 const complex<float> t1(1.f, std::sqrt(-1.f)); | |
| 60 EXPECT_FALSE(intelligibility::cplxfinite(t1)); | |
| 61 EXPECT_FALSE(intelligibility::cplxnormal(t1)); | |
| 62 const complex<float> t2(1.f, 1.f); | |
| 63 EXPECT_TRUE(intelligibility::cplxfinite(t2)); | |
| 64 EXPECT_TRUE(intelligibility::cplxnormal(t2)); | |
| 65 } | 57 } |
| 66 | 58 |
| 67 // Tests NewMean and AddToMean. | 59 // Tests NewMean and AddToMean. |
| 68 TEST(IntelligibilityUtilsTest, TestMeanUpdate) { | 60 TEST(IntelligibilityUtilsTest, TestMeanUpdate) { |
| 69 const complex<float> data[] = {{3, 8}, {7, 6}, {2, 1}, {8, 9}, {0, 6}}; | 61 const complex<float> data[] = {{3, 8}, {7, 6}, {2, 1}, {8, 9}, {0, 6}}; |
| 70 const complex<float> means[] = {{3, 8}, {5, 7}, {4, 5}, {5, 6}, {4, 6}}; | 62 const complex<float> means[] = {{3, 8}, {5, 7}, {4, 5}, {5, 6}, {4, 6}}; |
| 71 complex<float> mean(3, 8); | 63 complex<float> mean(3, 8); |
| 72 for (size_t i = 0; i < arraysize(data); i++) { | 64 for (size_t i = 0; i < arraysize(data); i++) { |
| 73 EXPECT_EQ(means[i], NewMean(mean, data[i], i + 1)); | 65 EXPECT_EQ(means[i], NewMean(mean, data[i], i + 1)); |
| 74 AddToMean(data[i], i + 1, &mean); | 66 AddToMean(data[i], i + 1, &mean); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 EXPECT_LT(out_data[i][j].real(), 1.0f); | 171 EXPECT_LT(out_data[i][j].real(), 1.0f); |
| 180 EXPECT_GT(out_data[i][j].imag(), 0.0f); | 172 EXPECT_GT(out_data[i][j].imag(), 0.0f); |
| 181 EXPECT_LT(out_data[i][j].imag(), 1.0f); | 173 EXPECT_LT(out_data[i][j].imag(), 1.0f); |
| 182 } | 174 } |
| 183 } | 175 } |
| 184 } | 176 } |
| 185 | 177 |
| 186 } // namespace intelligibility | 178 } // namespace intelligibility |
| 187 | 179 |
| 188 } // namespace webrtc | 180 } // namespace webrtc |
| OLD | NEW |