3333#include < cstdint>
3434#include < cstring>
3535#include < libheif/heif_items.h>
36+ #include < libheif/heif_library.h>
3637
3738
3839TEST_CASE (" no text" ) {
@@ -83,11 +84,17 @@ TEST_CASE("create text item") {
8384 std::string text_body1 (" first string" );
8485 err = heif_image_handle_add_text_item (handle, " text/plain" , text_body1.c_str (), &text_item1);
8586 REQUIRE (err.code == heif_error_Ok);
87+ err = heif_text_item_add_extended_language (text_item1, " en-AU" , NULL );
88+ REQUIRE (err.code == heif_error_Ok);
8689
8790 struct heif_text_item * text_item2;
8891 std::string text_body2 (" a second string" );
8992 err = heif_image_handle_add_text_item (handle, " text/plain" , text_body2.c_str (), &text_item2);
9093 REQUIRE (err.code == heif_error_Ok);
94+ heif_property_id elng_prop_id;
95+ err = heif_text_item_add_extended_language (text_item2, " en-UK" , &elng_prop_id);
96+ REQUIRE (err.code == heif_error_Ok);
97+ REQUIRE (elng_prop_id != 0 );
9198
9299 err = heif_context_write_to_file (ctx, " text.heif" );
93100 REQUIRE (err.code == heif_error_Ok);
@@ -128,6 +135,15 @@ TEST_CASE("create text item") {
128135 REQUIRE (std::string (content_type0) == " text/plain" );
129136 const char * body0 = heif_text_item_get_content (text0);
130137 REQUIRE (std::string (body0) == text_body1);
138+ heif_string_release (body0);
139+ char * elng0;
140+ heif_property_id properties[3 ];
141+ int num_props = heif_item_get_properties_of_type (readbackCtx, id0, heif_item_property_type_extended_language, properties, 3 );
142+ REQUIRE (num_props == 1 );
143+ err = heif_item_get_property_extended_language (readbackCtx, id0, properties[0 ], &elng0);
144+ REQUIRE (err.code == heif_error_Ok);
145+ REQUIRE (strcmp (elng0, " en-AU" ) == 0 );
146+ heif_string_release (elng0);
131147
132148 heif_text_item* text1;
133149 err = heif_context_get_text_item (readbackCtx, text_item_ids[1 ], &text1);
@@ -139,6 +155,14 @@ TEST_CASE("create text item") {
139155 REQUIRE (std::string (content_type1) == " text/plain" );
140156 const char * body1 = heif_text_item_get_content (text1);
141157 REQUIRE (std::string (body1) == text_body2);
158+ heif_string_release (body1);
159+ char * elng1;
160+ num_props = heif_item_get_properties_of_type (readbackCtx, id1, heif_item_property_type_extended_language, properties, 3 );
161+ REQUIRE (num_props == 1 );
162+ err = heif_item_get_property_extended_language (readbackCtx, id1, properties[0 ], &elng1);
163+ REQUIRE (err.code == heif_error_Ok);
164+ REQUIRE (strcmp (elng1, " en-UK" ) == 0 );
165+ heif_string_release (elng1);
142166
143167 heif_text_item_release (text0);
144168 heif_text_item_release (text1);
0 commit comments