image_bundle_test.cc (1061B)
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 "lib/jxl/enc_aux_out.h" 9 #include "lib/jxl/enc_bit_writer.h" 10 #include "lib/jxl/testing.h" 11 12 namespace jxl { 13 namespace { 14 15 TEST(ImageBundleTest, ExtraChannelName) { 16 AuxOut aux_out; 17 BitWriter writer; 18 BitWriter::Allotment allotment(&writer, 99); 19 20 ImageMetadata metadata; 21 ExtraChannelInfo eci; 22 eci.type = ExtraChannel::kBlack; 23 eci.name = "testK"; 24 metadata.extra_channel_info.push_back(std::move(eci)); 25 ASSERT_TRUE(WriteImageMetadata(metadata, &writer, /*layer=*/0, &aux_out)); 26 writer.ZeroPadToByte(); 27 allotment.ReclaimAndCharge(&writer, /*layer=*/0, &aux_out); 28 29 BitReader reader(writer.GetSpan()); 30 ImageMetadata metadata_out; 31 ASSERT_TRUE(ReadImageMetadata(&reader, &metadata_out)); 32 EXPECT_TRUE(reader.Close()); 33 EXPECT_EQ("testK", metadata_out.Find(ExtraChannel::kBlack)->name); 34 } 35 36 } // namespace 37 } // namespace jxl