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 16 #include "audio_sampleformat_unittest.h" 17 18 namespace OHOS { 19 namespace Media { 20 namespace Pipeline { 21 using namespace std; 22 using namespace testing; 23 using namespace testing::ext; 24 25 static const int32_t RIGHT_RET = 8; 26 static const int32_t WRONG_RET = -1; 27 SetUpTestCase(void)28void AudioSampleFormatUnitTest::SetUpTestCase(void) 29 { 30 } 31 TearDownTestCase(void)32void AudioSampleFormatUnitTest::TearDownTestCase(void) 33 { 34 } 35 SetUp(void)36void AudioSampleFormatUnitTest::SetUp(void) 37 { 38 } 39 TearDown(void)40void AudioSampleFormatUnitTest::TearDown(void) 41 { 42 } 43 44 /** 45 * @tc.name : Test AudioSampleFormatToBitDepth 46 * @tc.number: AudioSampleFormatToBitDepth_001 47 * @tc.desc : Test SAMPLEFORMAT_INFOS.count(sampleFormat) != 0 48 * Test SAMPLEFORMAT_INFOS.count(sampleFormat) == 0 49 */ 50 HWTEST_F(AudioSampleFormatUnitTest, AudioSampleFormatToBitDepth_001, TestSize.Level0) 51 { 52 // Test SAMPLEFORMAT_INFOS.count(sampleFormat) != 0 53 EXPECT_EQ(AudioSampleFormatToBitDepth(Plugins::SAMPLE_U8), RIGHT_RET); 54 // Test SAMPLEFORMAT_INFOS.count(sampleFormat) == 0 55 EXPECT_EQ(AudioSampleFormatToBitDepth(Plugins::SAMPLE_S16BE), WRONG_RET); 56 } 57 58 } // namespace Pipeline 59 } // namespace Media 60 } // namespace OHOS