| 665 | } |
| 666 | |
| 667 | void expect_image_decode_encode_match(const Ref<Image> &img, const String &expected_str, int ver_major, bool is_pcfg) { |
| 668 | int len; |
| 669 | bool p_full_objects = false; |
| 670 | Error err = VariantDecoderCompat::encode_variant_compat(ver_major, img, nullptr, len, p_full_objects); |
| 671 | CHECK(err == OK); |
| 672 | |
| 673 | Vector<uint8_t> buff; |
| 674 | buff.resize(len); |
| 675 | |
| 676 | uint8_t *w = buff.ptrw(); |
| 677 | err = VariantDecoderCompat::encode_variant_compat(ver_major, img, &w[0], len, p_full_objects); |
| 678 | CHECK(err == OK); |
| 679 | |
| 680 | Variant decoded; |
| 681 | err = VariantDecoderCompat::decode_variant_compat(ver_major, decoded, buff.ptr(), len, nullptr, p_full_objects); |
| 682 | CHECK(err == OK); |
| 683 | Ref<Image> decoded_img = decoded; |
| 684 | REQUIRE(decoded_img.is_valid()); |
| 685 | |
| 686 | compare_images(img, decoded_img); |
| 687 | |
| 688 | expect_image_write_match(decoded_img, expected_str, ver_major, is_pcfg); |
| 689 | } |
| 690 | |
| 691 | void test_image_variant(const String &test_name, const Ref<Image> &img, const String &expected_v2_str, const String &expected_v2_pcfg_str, bool compress_lossless = true) { |
| 692 | SUBCASE(vformat("%s write v2", test_name).utf8().get_data()) { |
no test coverage detected