• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023, 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/common/utils/tests/test_utils.h"
13 
14 #include <cstdint>
15 #include <vector>
16 
17 #include "gtest/gtest.h"
18 #include "iamf/common/write_bit_buffer.h"
19 
20 namespace iamf_tools {
21 
ValidateWriteResults(const WriteBitBuffer & wb,const std::vector<uint8_t> & expected_data)22 void ValidateWriteResults(const WriteBitBuffer& wb,
23                           const std::vector<uint8_t>& expected_data) {
24   // Check that sizes and amount of data written are all consistent.
25   EXPECT_EQ(static_cast<int64_t>(expected_data.size()) * 8, wb.bit_offset());
26 
27   // Check the data matches expected.
28   EXPECT_EQ(wb.bit_buffer(), expected_data);
29 }
30 
ValidateObuWriteResults(const WriteBitBuffer & wb,const std::vector<uint8_t> & header,const std::vector<uint8_t> & payload)31 void ValidateObuWriteResults(const WriteBitBuffer& wb,
32                              const std::vector<uint8_t>& header,
33                              const std::vector<uint8_t>& payload) {
34   // Concatenate the header and payload the call `ValidateWriteResults()`.
35   std::vector<uint8_t> concatenated;
36   concatenated.reserve(header.size() + payload.size());
37   concatenated.insert(concatenated.end(), header.begin(), header.end());
38   concatenated.insert(concatenated.end(), payload.begin(), payload.end());
39   ValidateWriteResults(wb, concatenated);
40 }
41 
42 }  // namespace iamf_tools
43