changelog.html : Added entries about RICE2 residue coding method.
[platform/upstream/flac.git] / src / test_libFLAC / metadata_object.c
index 2805d41..050c482 100644 (file)
@@ -1,5 +1,5 @@
 /* test_libFLAC - Unit tester for libFLAC
- * Copyright (C) 2002,2003,2004,2005,2006  Josh Coalson
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -11,9 +11,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #if HAVE_CONFIG_H
@@ -22,7 +22,9 @@
 
 #include "FLAC/assert.h"
 #include "FLAC/metadata.h"
-#include "metadata_utils.h"
+#include "test_libs_common/metadata_utils.h"
+#include "share/compat.h"
+#include "metadata.h"
 #include <stdio.h>
 #include <stdlib.h> /* for malloc() */
 #include <string.h> /* for memcmp() */
@@ -31,7 +33,7 @@ static FLAC__byte *make_dummydata_(FLAC__byte *dummydata, unsigned len)
 {
        FLAC__byte *ret;
 
-       if(0 == (ret = (FLAC__byte*)malloc(len))) {
+       if(0 == (ret = malloc(len))) {
                printf("FAILED, malloc error\n");
                exit(1);
        }
@@ -46,7 +48,7 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from
        unsigned i;
 
        if(from->offset != to->offset) {
-               printf("FAILED, track offset mismatch, expected %llu, got %llu\n", to->offset, from->offset);
+               printf("FAILED, track offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", to->offset, from->offset);
                return false;
        }
        if(from->number != to->number) {
@@ -78,7 +80,7 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from
        else {
                for(i = 0; i < to->num_indices; i++) {
                        if(from->indices[i].offset != to->indices[i].offset) {
-                               printf("FAILED, track indices[%u].offset mismatch, expected %llu, got %llu\n", i, to->indices[i].offset, from->indices[i].offset);
+                               printf("FAILED, track indices[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to->indices[i].offset, from->indices[i].offset);
                                return false;
                        }
                        if(from->indices[i].number != to->indices[i].number) {
@@ -100,11 +102,11 @@ static FLAC__bool compare_seekpoint_array_(const FLAC__StreamMetadata_SeekPoint
 
        for(i = 0; i < n; i++) {
                if(from[i].sample_number != to[i].sample_number) {
-                       printf("FAILED, point[%u].sample_number mismatch, expected %llu, got %llu\n", i, to[i].sample_number, from[i].sample_number);
+                       printf("FAILED, point[%u].sample_number mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to[i].sample_number, from[i].sample_number);
                        return false;
                }
                if(from[i].stream_offset != to[i].stream_offset) {
-                       printf("FAILED, point[%u].stream_offset mismatch, expected %llu, got %llu\n", i, to[i].stream_offset, from[i].stream_offset);
+                       printf("FAILED, point[%u].stream_offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to[i].stream_offset, from[i].stream_offset);
                        return false;
                }
                if(from[i].frame_samples != to[i].frame_samples) {
@@ -146,7 +148,7 @@ static FLAC__bool check_seektable_(const FLAC__StreamMetadata *block, unsigned n
 static void entry_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field)
 {
        entry->length = strlen(field);
-       entry->entry = (FLAC__byte*)malloc(entry->length+1);
+       entry->entry = malloc(entry->length+1);
        FLAC__ASSERT(0 != entry->entry);
        memcpy(entry->entry, field, entry->length);
        entry->entry[entry->length] = '\0';
@@ -154,7 +156,7 @@ static void entry_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, const ch
 
 static void entry_clone_(FLAC__StreamMetadata_VorbisComment_Entry *entry)
 {
-       FLAC__byte *x = (FLAC__byte*)malloc(entry->length+1);
+       FLAC__byte *x = malloc(entry->length+1);
        FLAC__ASSERT(0 != x);
        memcpy(x, entry->entry, entry->length);
        x[entry->length] = '\0';
@@ -196,7 +198,7 @@ static void vc_resize_(FLAC__StreamMetadata *block, unsigned num)
                }
        }
        else {
-               vc->comments = (FLAC__StreamMetadata_VorbisComment_Entry*)realloc(vc->comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*num);
+               vc->comments = realloc(vc->comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*num);
                FLAC__ASSERT(0 != vc->comments);
                if(num > vc->num_comments)
                        memset(vc->comments+vc->num_comments, 0, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(num-vc->num_comments));
@@ -258,22 +260,22 @@ static void vc_delete_(FLAC__StreamMetadata *block, unsigned pos)
 
 static void vc_replace_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, const char *field, FLAC__bool all)
 {
-       int index;
+       int indx;
        char field_name[256];
        const char *eq = strchr(field, '=');
        FLAC__ASSERT(eq>field && (unsigned)(eq-field) < sizeof(field_name));
        memcpy(field_name, field, eq-field);
        field_name[eq-field]='\0';
 
-       index = vc_find_from_(block, field_name, 0);
-       if(index < 0)
+       indx = vc_find_from_(block, field_name, 0);
+       if(indx < 0)
                vc_insert_new_(entry, block, block->data.vorbis_comment.num_comments, field);
        else {
-               vc_set_new_(entry, block, (unsigned)index, field);
+               vc_set_new_(entry, block, (unsigned)indx, field);
                if(all) {
-                       for(index = index+1; index >= 0 && (unsigned)index < block->data.vorbis_comment.num_comments; )
-                               if((index = vc_find_from_(block, field_name, (unsigned)index)) >= 0)
-                                       vc_delete_(block, (unsigned)index);
+                       for(indx = indx+1; indx >= 0 && (unsigned)indx < block->data.vorbis_comment.num_comments; )
+                               if((indx = vc_find_from_(block, field_name, (unsigned)indx)) >= 0)
+                                       vc_delete_(block, (unsigned)indx);
                }
        }
 
@@ -295,7 +297,7 @@ static void track_clone_(FLAC__StreamMetadata_CueSheet_Track *track)
 {
        if(track->num_indices > 0) {
                size_t bytes = sizeof(FLAC__StreamMetadata_CueSheet_Index) * track->num_indices;
-               FLAC__StreamMetadata_CueSheet_Index *x = (FLAC__StreamMetadata_CueSheet_Index*)malloc(bytes);
+               FLAC__StreamMetadata_CueSheet_Index *x = malloc(bytes);
                FLAC__ASSERT(0 != x);
                memcpy(x, track->indices, bytes);
                track->indices = x;
@@ -350,7 +352,7 @@ static void tr_resize_(FLAC__StreamMetadata *block, unsigned track_num, unsigned
                }
        }
        else {
-               tr->indices = (FLAC__StreamMetadata_CueSheet_Index*)realloc(tr->indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)*num);
+               tr->indices = realloc(tr->indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)*num);
                FLAC__ASSERT(0 != tr->indices);
                if(num > tr->num_indices)
                        memset(tr->indices+tr->num_indices, 0, sizeof(FLAC__StreamMetadata_CueSheet_Index)*(num-tr->num_indices));
@@ -360,7 +362,7 @@ static void tr_resize_(FLAC__StreamMetadata *block, unsigned track_num, unsigned
        cs_calc_len_(block);
 }
 
-static void tr_set_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index index)
+static void tr_set_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index indx)
 {
        FLAC__StreamMetadata_CueSheet_Track *tr;
 
@@ -370,12 +372,12 @@ static void tr_set_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigne
 
        FLAC__ASSERT(pos < tr->num_indices);
 
-       tr->indices[pos] = index;
+       tr->indices[pos] = indx;
 
        cs_calc_len_(block);
 }
 
-static void tr_insert_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index index)
+static void tr_insert_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index indx)
 {
        FLAC__StreamMetadata_CueSheet_Track *tr;
 
@@ -387,7 +389,7 @@ static void tr_insert_new_(FLAC__StreamMetadata *block, unsigned track_num, unsi
 
        tr_resize_(block, track_num, tr->num_indices+1);
        memmove(&tr->indices[pos+1], &tr->indices[pos], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(tr->num_indices-1-pos));
-       tr_set_new_(block, track_num, pos, index);
+       tr_set_new_(block, track_num, pos, indx);
        cs_calc_len_(block);
 }
 
@@ -427,7 +429,7 @@ static void cs_resize_(FLAC__StreamMetadata *block, unsigned num)
                }
        }
        else {
-               cs->tracks = (FLAC__StreamMetadata_CueSheet_Track*)realloc(cs->tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)*num);
+               cs->tracks = realloc(cs->tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)*num);
                FLAC__ASSERT(0 != cs->tracks);
                if(num > cs->num_tracks)
                        memset(cs->tracks+cs->num_tracks, 0, sizeof(FLAC__StreamMetadata_CueSheet_Track)*(num-cs->num_tracks));
@@ -463,13 +465,46 @@ static void cs_delete_(FLAC__StreamMetadata *block, unsigned pos)
        cs_calc_len_(block);
 }
 
+static void pi_set_mime_type(FLAC__StreamMetadata *block, const char *s)
+{
+       if(block->data.picture.mime_type) {
+               block->length -= strlen(block->data.picture.mime_type);
+               free(block->data.picture.mime_type);
+       }
+       block->data.picture.mime_type = strdup(s);
+       FLAC__ASSERT(block->data.picture.mime_type);
+       block->length += strlen(block->data.picture.mime_type);
+}
+
+static void pi_set_description(FLAC__StreamMetadata *block, const FLAC__byte *s)
+{
+       if(block->data.picture.description) {
+               block->length -= strlen((const char *)block->data.picture.description);
+               free(block->data.picture.description);
+       }
+       block->data.picture.description = (FLAC__byte*)strdup((const char *)s);
+       FLAC__ASSERT(block->data.picture.description);
+       block->length += strlen((const char *)block->data.picture.description);
+}
 
-FLAC__bool test_metadata_object()
+static void pi_set_data(FLAC__StreamMetadata *block, const FLAC__byte *data, FLAC__uint32 len)
 {
-       FLAC__StreamMetadata *block, *blockcopy, *vorbiscomment, *cuesheet;
-       FLAC__StreamMetadata_SeekPoint seekpoint_array[8];
+       if(block->data.picture.data) {
+               block->length -= block->data.picture.data_length;
+               free(block->data.picture.data);
+       }
+       block->data.picture.data = (FLAC__byte*)strdup((const char *)data);
+       FLAC__ASSERT(block->data.picture.data);
+       block->data.picture.data_length = len;
+       block->length += len;
+}
+
+FLAC__bool test_metadata_object(void)
+{
+       FLAC__StreamMetadata *block, *blockcopy, *vorbiscomment, *cuesheet, *picture;
+       FLAC__StreamMetadata_SeekPoint seekpoint_array[14];
        FLAC__StreamMetadata_VorbisComment_Entry entry;
-       FLAC__StreamMetadata_CueSheet_Index index;
+       FLAC__StreamMetadata_CueSheet_Index indx;
        FLAC__StreamMetadata_CueSheet_Track track;
        unsigned i, expected_length, seekpoints;
        int j;
@@ -879,6 +914,28 @@ FLAC__bool test_metadata_object()
        if(!check_seektable_(block, seekpoints, seekpoint_array))
                return false;
 
+       seekpoint_array[seekpoints++].sample_number = 0;
+       seekpoint_array[seekpoints++].sample_number = 10;
+       seekpoint_array[seekpoints++].sample_number = 20;
+       printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points_by_samples()... ");
+       if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(block, 10, 30)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!check_seektable_(block, seekpoints, seekpoint_array))
+               return false;
+
+       seekpoint_array[seekpoints++].sample_number = 0;
+       seekpoint_array[seekpoints++].sample_number = 11;
+       seekpoint_array[seekpoints++].sample_number = 22;
+       printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points_by_samples()... ");
+       if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(block, 11, 30)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!check_seektable_(block, seekpoints, seekpoint_array))
+               return false;
+
        printf("testing FLAC__metadata_object_delete()... ");
        FLAC__metadata_object_delete(block);
        printf("OK\n");
@@ -1738,11 +1795,11 @@ FLAC__bool test_metadata_object()
                return false;
        printf("OK\n");
 
-       index.offset = 0;
-       index.number = 1;
+       indx.offset = 0;
+       indx.number = 1;
        printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on empty array...");
-       tr_insert_new_(cuesheet, 0, 0, index);
-       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, index)) {
+       tr_insert_new_(cuesheet, 0, 0, indx);
+       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, indx)) {
                printf("FAILED, returned false\n");
                return false;
        }
@@ -1750,11 +1807,11 @@ FLAC__bool test_metadata_object()
                return false;
        printf("OK\n");
 
-       index.offset = 10;
-       index.number = 2;
+       indx.offset = 10;
+       indx.number = 2;
        printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on beginning of non-empty array...");
-       tr_insert_new_(cuesheet, 0, 0, index);
-       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, index)) {
+       tr_insert_new_(cuesheet, 0, 0, indx);
+       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, indx)) {
                printf("FAILED, returned false\n");
                return false;
        }
@@ -1762,11 +1819,11 @@ FLAC__bool test_metadata_object()
                return false;
        printf("OK\n");
 
-       index.offset = 20;
-       index.number = 3;
+       indx.offset = 20;
+       indx.number = 3;
        printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on middle of non-empty array...");
-       tr_insert_new_(cuesheet, 0, 1, index);
-       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 1, index)) {
+       tr_insert_new_(cuesheet, 0, 1, indx);
+       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 1, indx)) {
                printf("FAILED, returned false\n");
                return false;
        }
@@ -1774,11 +1831,11 @@ FLAC__bool test_metadata_object()
                return false;
        printf("OK\n");
 
-       index.offset = 30;
-       index.number = 4;
+       indx.offset = 30;
+       indx.number = 4;
        printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on end of non-empty array...");
-       tr_insert_new_(cuesheet, 0, 3, index);
-       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 3, index)) {
+       tr_insert_new_(cuesheet, 0, 3, indx);
+       if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 3, indx)) {
                printf("FAILED, returned false\n");
                return false;
        }
@@ -1786,10 +1843,10 @@ FLAC__bool test_metadata_object()
                return false;
        printf("OK\n");
 
-       index.offset = 0;
-       index.number = 0;
+       indx.offset = 0;
+       indx.number = 0;
        printf("testing FLAC__metadata_object_cuesheet_track_insert_blank_index() on end of non-empty array...");
-       tr_insert_new_(cuesheet, 0, 4, index);
+       tr_insert_new_(cuesheet, 0, 4, indx);
        if(!FLAC__metadata_object_cuesheet_track_insert_blank_index(block, 0, 4)) {
                printf("FAILED, returned false\n");
                return false;
@@ -1974,5 +2031,254 @@ FLAC__bool test_metadata_object()
        printf("OK\n");
 
 
+       printf("testing PICTURE\n");
+
+       printf("testing FLAC__metadata_object_new()... ");
+       block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE);
+       if(0 == block) {
+               printf("FAILED, returned NULL\n");
+               return false;
+       }
+       expected_length = (
+               FLAC__STREAM_METADATA_PICTURE_TYPE_LEN +
+               FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN +
+               FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN +
+               FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN +
+               FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN +
+               FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN +
+               FLAC__STREAM_METADATA_PICTURE_COLORS_LEN +
+               FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN
+       ) / 8;
+       if(block->length != expected_length) {
+               printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
+               return false;
+       }
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_clone()... ");
+       picture = FLAC__metadata_object_clone(block);
+       if(0 == picture) {
+               printf("FAILED, returned NULL\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       pi_set_mime_type(picture, "image/png\t");
+       printf("testing FLAC__metadata_object_picture_set_mime_type(copy)...");
+       if(!FLAC__metadata_object_picture_set_mime_type(block, "image/png\t", /*copy=*/true)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned true when expecting false\n");
+                       return false;
+               }
+               printf("returned false as expected, violation=\"%s\" OK\n", violation);
+       }
+
+       pi_set_mime_type(picture, "image/png");
+       printf("testing FLAC__metadata_object_picture_set_mime_type(copy)...");
+       if(!FLAC__metadata_object_picture_set_mime_type(block, "image/png", /*copy=*/true)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned false, violation=\"%s\"\n", violation);
+                       return false;
+               }
+               printf("OK\n");
+       }
+
+       pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION\xff");
+       printf("testing FLAC__metadata_object_picture_set_description(copy)...");
+       if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)"DESCRIPTION\xff", /*copy=*/true)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned true when expecting false\n");
+                       return false;
+               }
+               printf("returned false as expected, violation=\"%s\" OK\n", violation);
+       }
+
+       pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION");
+       printf("testing FLAC__metadata_object_picture_set_description(copy)...");
+       if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)"DESCRIPTION", /*copy=*/true)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned false, violation=\"%s\"\n", violation);
+                       return false;
+               }
+               printf("OK\n");
+       }
+
+
+       pi_set_data(picture, (const FLAC__byte*)"PNGDATA", strlen("PNGDATA"));
+       printf("testing FLAC__metadata_object_picture_set_data(copy)...");
+       if(!FLAC__metadata_object_picture_set_data(block, (FLAC__byte*)"PNGDATA", strlen("PNGDATA"), /*copy=*/true)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_clone()... ");
+       blockcopy = FLAC__metadata_object_clone(block);
+       if(0 == blockcopy) {
+               printf("FAILED, returned NULL\n");
+               return false;
+       }
+       if(!mutils__compare_block(block, blockcopy))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_delete()... ");
+       FLAC__metadata_object_delete(blockcopy);
+       printf("OK\n");
+
+       pi_set_mime_type(picture, "image/png\t");
+       printf("testing FLAC__metadata_object_picture_set_mime_type(own)...");
+       if(!FLAC__metadata_object_picture_set_mime_type(block, strdup("image/png\t"), /*copy=*/false)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned true when expecting false\n");
+                       return false;
+               }
+               printf("returned false as expected, violation=\"%s\" OK\n", violation);
+       }
+
+       pi_set_mime_type(picture, "image/png");
+       printf("testing FLAC__metadata_object_picture_set_mime_type(own)...");
+       if(!FLAC__metadata_object_picture_set_mime_type(block, strdup("image/png"), /*copy=*/false)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned false, violation=\"%s\"\n", violation);
+                       return false;
+               }
+               printf("OK\n");
+       }
+
+       pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION\xff");
+       printf("testing FLAC__metadata_object_picture_set_description(own)...");
+       if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)strdup("DESCRIPTION\xff"), /*copy=*/false)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned true when expecting false\n");
+                       return false;
+               }
+               printf("returned false as expected, violation=\"%s\" OK\n", violation);
+       }
+
+       pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION");
+       printf("testing FLAC__metadata_object_picture_set_description(own)...");
+       if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)strdup("DESCRIPTION"), /*copy=*/false)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_picture_is_legal()...");
+       {
+               const char *violation;
+               if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
+                       printf("FAILED, returned false, violation=\"%s\"\n", violation);
+                       return false;
+               }
+               printf("OK\n");
+       }
+
+       pi_set_data(picture, (const FLAC__byte*)"PNGDATA", strlen("PNGDATA"));
+       printf("testing FLAC__metadata_object_picture_set_data(own)...");
+       if(!FLAC__metadata_object_picture_set_data(block, (FLAC__byte*)strdup("PNGDATA"), strlen("PNGDATA"), /*copy=*/false)) {
+               printf("FAILED, returned false\n");
+               return false;
+       }
+       if(!mutils__compare_block(picture, block))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_clone()... ");
+       blockcopy = FLAC__metadata_object_clone(block);
+       if(0 == blockcopy) {
+               printf("FAILED, returned NULL\n");
+               return false;
+       }
+       if(!mutils__compare_block(block, blockcopy))
+               return false;
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_delete()... ");
+       FLAC__metadata_object_delete(blockcopy);
+       printf("OK\n");
+
+       printf("testing FLAC__metadata_object_delete()... ");
+       FLAC__metadata_object_delete(picture);
+       FLAC__metadata_object_delete(block);
+       printf("OK\n");
+
+
        return true;
 }