33
33
#include < cstdint>
34
34
#include < cstring>
35
35
#include < libheif/heif_items.h>
36
+ #include < libheif/heif_library.h>
36
37
37
38
38
39
TEST_CASE (" no text" ) {
@@ -83,11 +84,17 @@ TEST_CASE("create text item") {
83
84
std::string text_body1 (" first string" );
84
85
err = heif_image_handle_add_text_item (handle, " text/plain" , text_body1.c_str (), &text_item1);
85
86
REQUIRE (err.code == heif_error_Ok);
87
+ err = heif_text_item_set_extended_language (text_item1, " en-AU" , NULL );
88
+ REQUIRE (err.code == heif_error_Ok);
86
89
87
90
struct heif_text_item * text_item2;
88
91
std::string text_body2 (" a second string" );
89
92
err = heif_image_handle_add_text_item (handle, " text/plain" , text_body2.c_str (), &text_item2);
90
93
REQUIRE (err.code == heif_error_Ok);
94
+ heif_property_id elng_prop_id;
95
+ err = heif_text_item_set_extended_language (text_item2, " en-UK" , &elng_prop_id);
96
+ REQUIRE (err.code == heif_error_Ok);
97
+ REQUIRE (elng_prop_id != 0 );
91
98
92
99
err = heif_context_write_to_file (ctx, " text.heif" );
93
100
REQUIRE (err.code == heif_error_Ok);
@@ -128,6 +135,12 @@ TEST_CASE("create text item") {
128
135
REQUIRE (std::string (content_type0) == " text/plain" );
129
136
const char * body0 = heif_text_item_get_content (text0);
130
137
REQUIRE (std::string (body0) == text_body1);
138
+ heif_string_release (body0);
139
+ char * elng0;
140
+ err = heif_item_get_property_extended_language (readbackCtx, id0, &elng0);
141
+ REQUIRE (err.code == heif_error_Ok);
142
+ REQUIRE (strcmp (elng0, " en-AU" ) == 0 );
143
+ heif_string_release (elng0);
131
144
132
145
heif_text_item* text1;
133
146
err = heif_context_get_text_item (readbackCtx, text_item_ids[1 ], &text1);
@@ -139,6 +152,12 @@ TEST_CASE("create text item") {
139
152
REQUIRE (std::string (content_type1) == " text/plain" );
140
153
const char * body1 = heif_text_item_get_content (text1);
141
154
REQUIRE (std::string (body1) == text_body2);
155
+ heif_string_release (body1);
156
+ char * elng1;
157
+ err = heif_item_get_property_extended_language (readbackCtx, id1, &elng1);
158
+ REQUIRE (err.code == heif_error_Ok);
159
+ REQUIRE (strcmp (elng1, " en-UK" ) == 0 );
160
+ heif_string_release (elng1);
142
161
143
162
heif_text_item_release (text0);
144
163
heif_text_item_release (text1);
0 commit comments