1 // Copyright (c) the JPEG XL Project Authors. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
5 
6 #include "lib/jxl/image_bundle.h"
7 
8 #include "gtest/gtest.h"
9 #include "lib/jxl/aux_out.h"
10 
11 namespace jxl {
12 namespace {
13 
TEST(ImageBundleTest,ExtraChannelName)14 TEST(ImageBundleTest, ExtraChannelName) {
15   AuxOut aux_out;
16   BitWriter writer;
17   BitWriter::Allotment allotment(&writer, 99);
18 
19   ImageMetadata metadata;
20   ExtraChannelInfo eci;
21   eci.type = ExtraChannel::kBlack;
22   eci.name = "testK";
23   metadata.extra_channel_info.push_back(std::move(eci));
24   ASSERT_TRUE(WriteImageMetadata(metadata, &writer, /*layer=*/0, &aux_out));
25   writer.ZeroPadToByte();
26   ReclaimAndCharge(&writer, &allotment, /*layer=*/0, &aux_out);
27 
28   BitReader reader(writer.GetSpan());
29   ImageMetadata metadata_out;
30   ASSERT_TRUE(ReadImageMetadata(&reader, &metadata_out));
31   EXPECT_TRUE(reader.Close());
32   EXPECT_EQ("testK", metadata_out.Find(ExtraChannel::kBlack)->name);
33 }
34 
35 }  // namespace
36 }  // namespace jxl
37