Skip to content

Commit

Permalink
Creates boilerplate for LpcmDecoder tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 631813725
  • Loading branch information
trevorknight authored and jwcullen committed May 9, 2024
1 parent 291f447 commit 1e8f6e9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
14 changes: 14 additions & 0 deletions iamf/cli/codec/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ cc_test(
],
)

cc_test(
name = "lpcm_decoder_test",
size = "small",
srcs = ["lpcm_decoder_test.cc"],
deps = [
"//iamf/cli/codec:lpcm_decoder",
"//iamf/obu:codec_config",
"//iamf/obu:obu_header",
"//iamf/obu/decoder_config:lpcm_decoder_config",
"@com_google_absl//absl/status",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "lpcm_encoder_test",
size = "small",
Expand Down
39 changes: 39 additions & 0 deletions iamf/cli/codec/tests/lpcm_decoder_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "iamf/cli/codec/lpcm_decoder.h"

#include <cstdint>

#include "gtest/gtest.h"
#include "iamf/obu/codec_config.h"
#include "iamf/obu/decoder_config/lpcm_decoder_config.h"
#include "iamf/obu/obu_header.h"

namespace iamf_tools {
namespace {

CodecConfigObu CreateCodecConfigObu(uint32_t num_samples_per_frame) {
LpcmDecoderConfig lpcm_decoder_config;
lpcm_decoder_config.sample_size_ = 16;
lpcm_decoder_config.sample_rate_ = 48000;

const CodecConfig codec_config = {
.codec_id = CodecConfig::kCodecIdLpcm,
.num_samples_per_frame = num_samples_per_frame,
.audio_roll_distance = 0,
.decoder_config = lpcm_decoder_config};

CodecConfigObu codec_config_obu(ObuHeader(), 0, codec_config);
return codec_config_obu;
};

TEST(LpcmDecoderTest, Construct) {
uint32_t num_samples_per_frame = 1024;
CodecConfigObu codec_config_obu = CreateCodecConfigObu(num_samples_per_frame);
ASSERT_TRUE(codec_config_obu.Initialize().ok());

int number_of_channels = 11;

LpcmDecoder lpcm_decoder(codec_config_obu, number_of_channels);
}

} // namespace
} // namespace iamf_tools

0 comments on commit 1e8f6e9

Please sign in to comment.