1 /*
2 * Copyright (c) 2024, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 3-Clause Clear License
5 * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
6 * License was not distributed with this source code in the LICENSE file, you
7 * can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the
8 * Alliance for Open Media Patent License 1.0 was not distributed with this
9 * source code in the PATENTS file, you can obtain it at
10 * www.aomedia.org/license/patent.
11 */
12 #include "iamf/obu/extension_parameter_data.h"
13
14 #include <cstdint>
15 #include <vector>
16
17 #include "absl/status/status_matchers.h"
18 #include "absl/types/span.h"
19 #include "gmock/gmock.h"
20 #include "gtest/gtest.h"
21 #include "iamf/common/read_bit_buffer.h"
22
23 namespace iamf_tools {
24 namespace {
25
26 using absl_testing::IsOk;
27
TEST(ExtensionParameterDataReadTest,NineBytes)28 TEST(ExtensionParameterDataReadTest, NineBytes) {
29 std::vector<uint8_t> source_data = {// `parameter_data_size`.
30 9,
31 // `parameter_data_bytes`.
32 'a', 'r', 'b', 'i', 't', 'r', 'a', 'r',
33 'y'};
34 auto buffer = MemoryBasedReadBitBuffer::CreateFromSpan(
35 1024, absl::MakeConstSpan(source_data));
36
37 ExtensionParameterData extension_parameter_data;
38 EXPECT_THAT(extension_parameter_data.ReadAndValidate(*buffer), IsOk());
39 EXPECT_EQ(extension_parameter_data.parameter_data_size, 9);
40 EXPECT_EQ(extension_parameter_data.parameter_data_bytes.size(), 9);
41 const std::vector<uint8_t> expected_parameter_data_bytes = {
42 'a', 'r', 'b', 'i', 't', 'r', 'a', 'r', 'y'};
43 EXPECT_EQ(extension_parameter_data.parameter_data_bytes,
44 expected_parameter_data_bytes);
45 }
46
47 } // namespace
48 } // namespace iamf_tools
49