| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Clear |vec| and verify that it is empty. | 76 // Clear |vec| and verify that it is empty. |
| 77 vec.Clear(); | 77 vec.Clear(); |
| 78 EXPECT_TRUE(vec.Empty()); | 78 EXPECT_TRUE(vec.Empty()); |
| 79 | 79 |
| 80 // Now copy the empty vector and verify that the copy becomes empty too. | 80 // Now copy the empty vector and verify that the copy becomes empty too. |
| 81 vec.CopyTo(&vec_copy); | 81 vec.CopyTo(&vec_copy); |
| 82 EXPECT_TRUE(vec_copy.Empty()); | 82 EXPECT_TRUE(vec_copy.Empty()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Try to copy to a NULL pointer. Nothing should happen. | |
| 86 TEST_F(AudioVectorTest, CopyToNull) { | |
| 87 AudioVector vec; | |
| 88 AudioVector* vec_copy = NULL; | |
| 89 vec.PushBack(array_, array_length()); | |
| 90 vec.CopyTo(vec_copy); | |
| 91 } | |
| 92 | |
| 93 // Test the PushBack method with another AudioVector as input argument. | 85 // Test the PushBack method with another AudioVector as input argument. |
| 94 TEST_F(AudioVectorTest, PushBackVector) { | 86 TEST_F(AudioVectorTest, PushBackVector) { |
| 95 static const size_t kLength = 10; | 87 static const size_t kLength = 10; |
| 96 AudioVector vec1(kLength); | 88 AudioVector vec1(kLength); |
| 97 AudioVector vec2(kLength); | 89 AudioVector vec2(kLength); |
| 98 // Set the first vector to [0, 1, ..., kLength - 1]. | 90 // Set the first vector to [0, 1, ..., kLength - 1]. |
| 99 // Set the second vector to [kLength, kLength + 1, ..., 2 * kLength - 1]. | 91 // Set the second vector to [kLength, kLength + 1, ..., 2 * kLength - 1]. |
| 100 for (size_t i = 0; i < kLength; ++i) { | 92 for (size_t i = 0; i < kLength; ++i) { |
| 101 vec1[i] = static_cast<int16_t>(i); | 93 vec1[i] = static_cast<int16_t>(i); |
| 102 vec2[i] = static_cast<int16_t>(i + kLength); | 94 vec2[i] = static_cast<int16_t>(i + kLength); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 EXPECT_NEAR((i + 1) * 100 / (kFadeLength + 1), | 377 EXPECT_NEAR((i + 1) * 100 / (kFadeLength + 1), |
| 386 vec1[kLength - kFadeLength + i], 1); | 378 vec1[kLength - kFadeLength + i], 1); |
| 387 } | 379 } |
| 388 // Second part untouched. | 380 // Second part untouched. |
| 389 for (size_t i = kLength; i < vec1.Size(); ++i) { | 381 for (size_t i = kLength; i < vec1.Size(); ++i) { |
| 390 EXPECT_EQ(100, vec1[i]); | 382 EXPECT_EQ(100, vec1[i]); |
| 391 } | 383 } |
| 392 } | 384 } |
| 393 | 385 |
| 394 } // namespace webrtc | 386 } // namespace webrtc |
| OLD | NEW |