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

Side by Side Diff: webrtc/common_audio/resampler/push_resampler_unittest.cc

Issue 2014183003: Reland of Adding a some checks and switching out a few assert for RTC_[D]CHECK. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webrtc/base/checks.h" // force defintion of RTC_DCHECK_IS_ON
12 #include "webrtc/common_audio/resampler/include/push_resampler.h" 13 #include "webrtc/common_audio/resampler/include/push_resampler.h"
13 14
14 // Quality testing of PushResampler is handled through output_mixer_unittest.cc. 15 // Quality testing of PushResampler is handled through output_mixer_unittest.cc.
15 16
16 namespace webrtc { 17 namespace webrtc {
17 18
18 TEST(PushResamplerTest, VerifiesInputParameters) { 19 TEST(PushResamplerTest, VerifiesInputParameters) {
19 PushResampler<int16_t> resampler; 20 PushResampler<int16_t> resampler;
20 EXPECT_EQ(-1, resampler.InitializeIfNeeded(-1, 16000, 1));
21 EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, -1, 1));
22 EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, 16000, 0));
23 EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, 16000, 3));
24 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1)); 21 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1));
25 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2)); 22 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2));
26 } 23 }
27 24
25 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
26 TEST(PushResamplerTest, VerifiesBadInputParameters1) {
27 PushResampler<int16_t> resampler;
28 EXPECT_DEATH(resampler.InitializeIfNeeded(-1, 16000, 1),
29 "src_sample_rate_hz");
30 }
31
32 TEST(PushResamplerTest, VerifiesBadInputParameters2) {
33 PushResampler<int16_t> resampler;
34 EXPECT_DEATH(resampler.InitializeIfNeeded(16000, -1, 1),
35 "dst_sample_rate_hz");
36 }
37
38 TEST(PushResamplerTest, VerifiesBadInputParameters3) {
39 PushResampler<int16_t> resampler;
40 EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 0), "num_channels");
41 }
42
43 TEST(PushResamplerTest, VerifiesBadInputParameters4) {
44 PushResampler<int16_t> resampler;
45 EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 3), "num_channels");
46 }
47 #endif
48
28 } // namespace webrtc 49 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698