1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <vector>
16 #include <map>
17 #include <gtest/gtest.h>
18 #include <cstdlib>
19 #include <cmath>
20 #include <climits>
21 #include <cstdint>
22 #include "audio_proresampler_process.h"
23 #include "audio_engine_log.h"
24 #include "securec.h"
25
26 using namespace testing::ext;
27 using namespace testing;
28
29 class AudioProResamplerProcessTest : public testing::Test {
30 public:
31 void SetUp();
32 void TearDown();
33 };
34
SetUp()35 void AudioProResamplerProcessTest::SetUp() {}
36
TearDown()37 void AudioProResamplerProcessTest::TearDown() {}
38
39 /*
40 * @tc.name : Test SingleStagePolyphaseResamplerSetRate API
41 * @tc.type : FUNC
42 * @tc.number: SingleStagePolyphaseResamplerSetRate_01
43 * @tc.desc : Test SingleStagePolyphaseResamplerSetRate, set decimateFactor is
44 * 0 and interpolateFactor is 0.
45 */
46 HWTEST_F(AudioProResamplerProcessTest, SingleStagePolyphaseResamplerSetRate_01, TestSize.Level0)
47 {
48 SingleStagePolyphaseResamplerState state;
49 uint32_t decimateFactor = 0;
50 uint32_t interpolateFactor = 0;
51 int32_t ret = SingleStagePolyphaseResamplerSetRate(&state, decimateFactor, interpolateFactor);
52 EXPECT_EQ(ret, RESAMPLER_ERR_INVALID_ARG);
53 }
54
55 /*
56 * @tc.name : Test SingleStagePolyphaseResamplerSetRate API
57 * @tc.type : FUNC
58 * @tc.number: SingleStagePolyphaseResamplerSetRate_02
59 * @tc.desc : Test SingleStagePolyphaseResamplerSetRate, set decimateFactor is
60 * 0 and interpolateFactor is 2.
61 */
62 HWTEST_F(AudioProResamplerProcessTest, SingleStagePolyphaseResamplerSetRate_02, TestSize.Level0)
63 {
64 SingleStagePolyphaseResamplerState state;
65 uint32_t decimateFactor = 0;
66 uint32_t interpolateFactor = 2;
67 int32_t ret = SingleStagePolyphaseResamplerSetRate(&state, decimateFactor, interpolateFactor);
68 EXPECT_EQ(ret, RESAMPLER_ERR_INVALID_ARG);
69 }
70
71 /*
72 * @tc.name : Test SingleStagePolyphaseResamplerSetRate API
73 * @tc.type : FUNC
74 * @tc.number: SingleStagePolyphaseResamplerSetRate_03
75 * @tc.desc : Test SingleStagePolyphaseResamplerSetRate, set decimateFactor is
76 * 2 and interpolateFactor is 0.
77 */
78 HWTEST_F(AudioProResamplerProcessTest, SingleStagePolyphaseResamplerSetRate_03, TestSize.Level0)
79 {
80 SingleStagePolyphaseResamplerState state;
81 uint32_t decimateFactor = 2;
82 uint32_t interpolateFactor = 0;
83 int32_t ret = SingleStagePolyphaseResamplerSetRate(&state, decimateFactor, interpolateFactor);
84 EXPECT_EQ(ret, RESAMPLER_ERR_INVALID_ARG);
85 }