xref: /aosp_15_r20/external/webrtc/common_audio/resampler/push_resampler_unittest.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "common_audio/resampler/include/push_resampler.h"
12 
13 #include "rtc_base/checks.h"  // RTC_DCHECK_IS_ON
14 #include "test/gtest.h"
15 #include "test/testsupport/rtc_expect_death.h"
16 
17 // Quality testing of PushResampler is done in audio/remix_resample_unittest.cc.
18 
19 namespace webrtc {
20 
TEST(PushResamplerTest,VerifiesInputParameters)21 TEST(PushResamplerTest, VerifiesInputParameters) {
22   PushResampler<int16_t> resampler;
23   EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1));
24   EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2));
25   EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 8));
26 }
27 
28 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
TEST(PushResamplerDeathTest,VerifiesBadInputParameters1)29 TEST(PushResamplerDeathTest, VerifiesBadInputParameters1) {
30   PushResampler<int16_t> resampler;
31   RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(-1, 16000, 1),
32                    "src_sample_rate_hz");
33 }
34 
TEST(PushResamplerDeathTest,VerifiesBadInputParameters2)35 TEST(PushResamplerDeathTest, VerifiesBadInputParameters2) {
36   PushResampler<int16_t> resampler;
37   RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, -1, 1),
38                    "dst_sample_rate_hz");
39 }
40 
TEST(PushResamplerDeathTest,VerifiesBadInputParameters3)41 TEST(PushResamplerDeathTest, VerifiesBadInputParameters3) {
42   PushResampler<int16_t> resampler;
43   RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 0),
44                    "num_channels");
45 }
46 #endif
47 
48 }  // namespace webrtc
49