1 /* test_libFLAC - Unit tester for libFLAC
2 * Copyright (C) 2002,2003,2004,2005,2006 Josh Coalson
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "FLAC/assert.h"
24 #include "FLAC/metadata.h"
25 #include "test_libs_common/metadata_utils.h"
27 #include <stdlib.h> /* for malloc() */
28 #include <string.h> /* for memcmp() */
30 static FLAC__byte *make_dummydata_(FLAC__byte *dummydata, unsigned len)
34 if(0 == (ret = (FLAC__byte*)malloc(len))) {
35 printf("FAILED, malloc error\n");
39 memcpy(ret, dummydata, len);
44 static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from, const FLAC__StreamMetadata_CueSheet_Track *to)
48 if(from->offset != to->offset) {
49 printf("FAILED, track offset mismatch, expected %llu, got %llu\n", to->offset, from->offset);
52 if(from->number != to->number) {
53 printf("FAILED, track number mismatch, expected %u, got %u\n", (unsigned)to->number, (unsigned)from->number);
56 if(0 != strcmp(from->isrc, to->isrc)) {
57 printf("FAILED, track number mismatch, expected %s, got %s\n", to->isrc, from->isrc);
60 if(from->type != to->type) {
61 printf("FAILED, track type mismatch, expected %u, got %u\n", (unsigned)to->type, (unsigned)from->type);
64 if(from->pre_emphasis != to->pre_emphasis) {
65 printf("FAILED, track pre_emphasis mismatch, expected %u, got %u\n", (unsigned)to->pre_emphasis, (unsigned)from->pre_emphasis);
68 if(from->num_indices != to->num_indices) {
69 printf("FAILED, track num_indices mismatch, expected %u, got %u\n", (unsigned)to->num_indices, (unsigned)from->num_indices);
72 if(0 == to->indices || 0 == from->indices) {
73 if(to->indices != from->indices) {
74 printf("FAILED, track indices mismatch\n");
79 for(i = 0; i < to->num_indices; i++) {
80 if(from->indices[i].offset != to->indices[i].offset) {
81 printf("FAILED, track indices[%u].offset mismatch, expected %llu, got %llu\n", i, to->indices[i].offset, from->indices[i].offset);
84 if(from->indices[i].number != to->indices[i].number) {
85 printf("FAILED, track indices[%u].number mismatch, expected %u, got %u\n", i, (unsigned)to->indices[i].number, (unsigned)from->indices[i].number);
94 static FLAC__bool compare_seekpoint_array_(const FLAC__StreamMetadata_SeekPoint *from, const FLAC__StreamMetadata_SeekPoint *to, unsigned n)
98 FLAC__ASSERT(0 != from);
99 FLAC__ASSERT(0 != to);
101 for(i = 0; i < n; i++) {
102 if(from[i].sample_number != to[i].sample_number) {
103 printf("FAILED, point[%u].sample_number mismatch, expected %llu, got %llu\n", i, to[i].sample_number, from[i].sample_number);
106 if(from[i].stream_offset != to[i].stream_offset) {
107 printf("FAILED, point[%u].stream_offset mismatch, expected %llu, got %llu\n", i, to[i].stream_offset, from[i].stream_offset);
110 if(from[i].frame_samples != to[i].frame_samples) {
111 printf("FAILED, point[%u].frame_samples mismatch, expected %u, got %u\n", i, to[i].frame_samples, from[i].frame_samples);
119 static FLAC__bool check_seektable_(const FLAC__StreamMetadata *block, unsigned num_points, const FLAC__StreamMetadata_SeekPoint *array)
121 const unsigned expected_length = num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH;
123 if(block->length != expected_length) {
124 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
127 if(block->data.seek_table.num_points != num_points) {
128 printf("FAILED, expected %u point, got %u\n", num_points, block->data.seek_table.num_points);
132 if(0 != block->data.seek_table.points) {
133 printf("FAILED, 'points' pointer is not null\n");
138 if(!compare_seekpoint_array_(block->data.seek_table.points, array, num_points))
146 static void entry_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field)
148 entry->length = strlen(field);
149 entry->entry = (FLAC__byte*)malloc(entry->length+1);
150 FLAC__ASSERT(0 != entry->entry);
151 memcpy(entry->entry, field, entry->length);
152 entry->entry[entry->length] = '\0';
155 static void entry_clone_(FLAC__StreamMetadata_VorbisComment_Entry *entry)
157 FLAC__byte *x = (FLAC__byte*)malloc(entry->length+1);
158 FLAC__ASSERT(0 != x);
159 memcpy(x, entry->entry, entry->length);
160 x[entry->length] = '\0';
164 static void vc_calc_len_(FLAC__StreamMetadata *block)
166 const FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment;
169 block->length = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
170 block->length += vc->vendor_string.length;
171 block->length += FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8;
172 for(i = 0; i < vc->num_comments; i++) {
173 block->length += FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
174 block->length += vc->comments[i].length;
178 static void vc_resize_(FLAC__StreamMetadata *block, unsigned num)
180 FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment;
182 if(vc->num_comments != 0) {
183 FLAC__ASSERT(0 != vc->comments);
184 if(num < vc->num_comments) {
186 for(i = num; i < vc->num_comments; i++) {
187 if(0 != vc->comments[i].entry)
188 free(vc->comments[i].entry);
193 if(0 != vc->comments) {
199 vc->comments = (FLAC__StreamMetadata_VorbisComment_Entry*)realloc(vc->comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*num);
200 FLAC__ASSERT(0 != vc->comments);
201 if(num > vc->num_comments)
202 memset(vc->comments+vc->num_comments, 0, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(num-vc->num_comments));
205 vc->num_comments = num;
209 static int vc_find_from_(FLAC__StreamMetadata *block, const char *name, unsigned start)
211 const unsigned n = strlen(name);
213 for(i = start; i < block->data.vorbis_comment.num_comments; i++) {
214 const FLAC__StreamMetadata_VorbisComment_Entry *entry = &block->data.vorbis_comment.comments[i];
215 if(entry->length > n && 0 == strncmp((const char *)entry->entry, name, n) && entry->entry[n] == '=')
221 static void vc_set_vs_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, const char *field)
223 if(0 != block->data.vorbis_comment.vendor_string.entry)
224 free(block->data.vorbis_comment.vendor_string.entry);
225 entry_new_(entry, field);
226 block->data.vorbis_comment.vendor_string = *entry;
230 static void vc_set_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, unsigned pos, const char *field)
232 if(0 != block->data.vorbis_comment.comments[pos].entry)
233 free(block->data.vorbis_comment.comments[pos].entry);
234 entry_new_(entry, field);
235 block->data.vorbis_comment.comments[pos] = *entry;
239 static void vc_insert_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, unsigned pos, const char *field)
241 vc_resize_(block, block->data.vorbis_comment.num_comments+1);
242 memmove(&block->data.vorbis_comment.comments[pos+1], &block->data.vorbis_comment.comments[pos], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(block->data.vorbis_comment.num_comments-1-pos));
243 memset(&block->data.vorbis_comment.comments[pos], 0, sizeof(FLAC__StreamMetadata_VorbisComment_Entry));
244 vc_set_new_(entry, block, pos, field);
248 static void vc_delete_(FLAC__StreamMetadata *block, unsigned pos)
250 if(0 != block->data.vorbis_comment.comments[pos].entry)
251 free(block->data.vorbis_comment.comments[pos].entry);
252 memmove(&block->data.vorbis_comment.comments[pos], &block->data.vorbis_comment.comments[pos+1], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(block->data.vorbis_comment.num_comments-pos-1));
253 block->data.vorbis_comment.comments[block->data.vorbis_comment.num_comments-1].entry = 0;
254 block->data.vorbis_comment.comments[block->data.vorbis_comment.num_comments-1].length = 0;
255 vc_resize_(block, block->data.vorbis_comment.num_comments-1);
259 static void vc_replace_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, const char *field, FLAC__bool all)
262 char field_name[256];
263 const char *eq = strchr(field, '=');
264 FLAC__ASSERT(eq>field && (unsigned)(eq-field) < sizeof(field_name));
265 memcpy(field_name, field, eq-field);
266 field_name[eq-field]='\0';
268 index = vc_find_from_(block, field_name, 0);
270 vc_insert_new_(entry, block, block->data.vorbis_comment.num_comments, field);
272 vc_set_new_(entry, block, (unsigned)index, field);
274 for(index = index+1; index >= 0 && (unsigned)index < block->data.vorbis_comment.num_comments; )
275 if((index = vc_find_from_(block, field_name, (unsigned)index)) >= 0)
276 vc_delete_(block, (unsigned)index);
283 static void track_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em)
285 track->offset = offset;
286 track->number = number;
287 memcpy(track->isrc, isrc, sizeof(track->isrc));
289 track->pre_emphasis = pre_em;
290 track->num_indices = 0;
294 static void track_clone_(FLAC__StreamMetadata_CueSheet_Track *track)
296 if(track->num_indices > 0) {
297 size_t bytes = sizeof(FLAC__StreamMetadata_CueSheet_Index) * track->num_indices;
298 FLAC__StreamMetadata_CueSheet_Index *x = (FLAC__StreamMetadata_CueSheet_Index*)malloc(bytes);
299 FLAC__ASSERT(0 != x);
300 memcpy(x, track->indices, bytes);
305 static void cs_calc_len_(FLAC__StreamMetadata *block)
307 const FLAC__StreamMetadata_CueSheet *cs = &block->data.cue_sheet;
311 FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
312 FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
313 FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
314 FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
315 FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
317 block->length += cs->num_tracks * (
318 FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN +
319 FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN +
320 FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN +
321 FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN +
322 FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN +
323 FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN +
324 FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN
326 for(i = 0; i < cs->num_tracks; i++) {
327 block->length += cs->tracks[i].num_indices * (
328 FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN +
329 FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN +
330 FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN
335 static void tr_resize_(FLAC__StreamMetadata *block, unsigned track_num, unsigned num)
337 FLAC__StreamMetadata_CueSheet_Track *tr;
339 FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks);
341 tr = &block->data.cue_sheet.tracks[track_num];
343 if(tr->num_indices != 0) {
344 FLAC__ASSERT(0 != tr->indices);
347 if(0 != tr->indices) {
353 tr->indices = (FLAC__StreamMetadata_CueSheet_Index*)realloc(tr->indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)*num);
354 FLAC__ASSERT(0 != tr->indices);
355 if(num > tr->num_indices)
356 memset(tr->indices+tr->num_indices, 0, sizeof(FLAC__StreamMetadata_CueSheet_Index)*(num-tr->num_indices));
359 tr->num_indices = num;
363 static void tr_set_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index index)
365 FLAC__StreamMetadata_CueSheet_Track *tr;
367 FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks);
369 tr = &block->data.cue_sheet.tracks[track_num];
371 FLAC__ASSERT(pos < tr->num_indices);
373 tr->indices[pos] = index;
378 static void tr_insert_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index index)
380 FLAC__StreamMetadata_CueSheet_Track *tr;
382 FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks);
384 tr = &block->data.cue_sheet.tracks[track_num];
386 FLAC__ASSERT(pos <= tr->num_indices);
388 tr_resize_(block, track_num, tr->num_indices+1);
389 memmove(&tr->indices[pos+1], &tr->indices[pos], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(tr->num_indices-1-pos));
390 tr_set_new_(block, track_num, pos, index);
394 static void tr_delete_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos)
396 FLAC__StreamMetadata_CueSheet_Track *tr;
398 FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks);
400 tr = &block->data.cue_sheet.tracks[track_num];
402 FLAC__ASSERT(pos <= tr->num_indices);
404 memmove(&tr->indices[pos], &tr->indices[pos+1], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(tr->num_indices-pos-1));
405 tr_resize_(block, track_num, tr->num_indices-1);
409 static void cs_resize_(FLAC__StreamMetadata *block, unsigned num)
411 FLAC__StreamMetadata_CueSheet *cs = &block->data.cue_sheet;
413 if(cs->num_tracks != 0) {
414 FLAC__ASSERT(0 != cs->tracks);
415 if(num < cs->num_tracks) {
417 for(i = num; i < cs->num_tracks; i++) {
418 if(0 != cs->tracks[i].indices)
419 free(cs->tracks[i].indices);
424 if(0 != cs->tracks) {
430 cs->tracks = (FLAC__StreamMetadata_CueSheet_Track*)realloc(cs->tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)*num);
431 FLAC__ASSERT(0 != cs->tracks);
432 if(num > cs->num_tracks)
433 memset(cs->tracks+cs->num_tracks, 0, sizeof(FLAC__StreamMetadata_CueSheet_Track)*(num-cs->num_tracks));
436 cs->num_tracks = num;
440 static void cs_set_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, unsigned pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em)
442 track_new_(track, offset, number, isrc, data, pre_em);
443 block->data.cue_sheet.tracks[pos] = *track;
447 static void cs_insert_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, unsigned pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em)
449 cs_resize_(block, block->data.cue_sheet.num_tracks+1);
450 memmove(&block->data.cue_sheet.tracks[pos+1], &block->data.cue_sheet.tracks[pos], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(block->data.cue_sheet.num_tracks-1-pos));
451 cs_set_new_(track, block, pos, offset, number, isrc, data, pre_em);
455 static void cs_delete_(FLAC__StreamMetadata *block, unsigned pos)
457 if(0 != block->data.cue_sheet.tracks[pos].indices)
458 free(block->data.cue_sheet.tracks[pos].indices);
459 memmove(&block->data.cue_sheet.tracks[pos], &block->data.cue_sheet.tracks[pos+1], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(block->data.cue_sheet.num_tracks-pos-1));
460 block->data.cue_sheet.tracks[block->data.cue_sheet.num_tracks-1].indices = 0;
461 block->data.cue_sheet.tracks[block->data.cue_sheet.num_tracks-1].num_indices = 0;
462 cs_resize_(block, block->data.cue_sheet.num_tracks-1);
466 static void pi_set_mime_type(FLAC__StreamMetadata *block, const char *s)
468 if(block->data.picture.mime_type) {
469 block->length -= strlen(block->data.picture.mime_type);
470 free(block->data.picture.mime_type);
472 block->data.picture.mime_type = strdup(s);
473 FLAC__ASSERT(block->data.picture.mime_type);
474 block->length += strlen(block->data.picture.mime_type);
477 static void pi_set_description(FLAC__StreamMetadata *block, const FLAC__byte *s)
479 if(block->data.picture.description) {
480 block->length -= strlen((const char *)block->data.picture.description);
481 free(block->data.picture.description);
483 block->data.picture.description = (FLAC__byte*)strdup((const char *)s);
484 FLAC__ASSERT(block->data.picture.description);
485 block->length += strlen((const char *)block->data.picture.description);
488 static void pi_set_data(FLAC__StreamMetadata *block, const FLAC__byte *data, FLAC__uint32 len)
490 if(block->data.picture.data) {
491 block->length -= block->data.picture.data_length;
492 free(block->data.picture.data);
494 block->data.picture.data = (FLAC__byte*)strdup((const char *)data);
495 FLAC__ASSERT(block->data.picture.data);
496 block->data.picture.data_length = len;
497 block->length += len;
500 FLAC__bool test_metadata_object()
502 FLAC__StreamMetadata *block, *blockcopy, *vorbiscomment, *cuesheet, *picture;
503 FLAC__StreamMetadata_SeekPoint seekpoint_array[14];
504 FLAC__StreamMetadata_VorbisComment_Entry entry;
505 FLAC__StreamMetadata_CueSheet_Index index;
506 FLAC__StreamMetadata_CueSheet_Track track;
507 unsigned i, expected_length, seekpoints;
509 static FLAC__byte dummydata[4] = { 'a', 'b', 'c', 'd' };
511 printf("\n+++ libFLAC unit test: metadata objects\n\n");
514 printf("testing STREAMINFO\n");
516 printf("testing FLAC__metadata_object_new()... ");
517 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO);
519 printf("FAILED, returned NULL\n");
522 expected_length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH;
523 if(block->length != expected_length) {
524 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
529 printf("testing FLAC__metadata_object_clone()... ");
530 blockcopy = FLAC__metadata_object_clone(block);
532 printf("FAILED, returned NULL\n");
535 if(!mutils__compare_block(block, blockcopy))
539 printf("testing FLAC__metadata_object_delete()... ");
540 FLAC__metadata_object_delete(blockcopy);
541 FLAC__metadata_object_delete(block);
545 printf("testing PADDING\n");
547 printf("testing FLAC__metadata_object_new()... ");
548 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING);
550 printf("FAILED, returned NULL\n");
554 if(block->length != expected_length) {
555 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
560 printf("testing FLAC__metadata_object_clone()... ");
561 blockcopy = FLAC__metadata_object_clone(block);
563 printf("FAILED, returned NULL\n");
566 if(!mutils__compare_block(block, blockcopy))
570 printf("testing FLAC__metadata_object_delete()... ");
571 FLAC__metadata_object_delete(blockcopy);
572 FLAC__metadata_object_delete(block);
576 printf("testing APPLICATION\n");
578 printf("testing FLAC__metadata_object_new()... ");
579 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION);
581 printf("FAILED, returned NULL\n");
584 expected_length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
585 if(block->length != expected_length) {
586 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
591 printf("testing FLAC__metadata_object_clone()... ");
592 blockcopy = FLAC__metadata_object_clone(block);
594 printf("FAILED, returned NULL\n");
597 if(!mutils__compare_block(block, blockcopy))
601 printf("testing FLAC__metadata_object_delete()... ");
602 FLAC__metadata_object_delete(blockcopy);
605 printf("testing FLAC__metadata_object_application_set_data(copy)... ");
606 if(!FLAC__metadata_object_application_set_data(block, dummydata, sizeof(dummydata), true/*copy*/)) {
607 printf("FAILED, returned false\n");
610 expected_length = (FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8) + sizeof(dummydata);
611 if(block->length != expected_length) {
612 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
615 if(0 != memcmp(block->data.application.data, dummydata, sizeof(dummydata))) {
616 printf("FAILED, data mismatch\n");
621 printf("testing FLAC__metadata_object_clone()... ");
622 blockcopy = FLAC__metadata_object_clone(block);
624 printf("FAILED, returned NULL\n");
627 if(!mutils__compare_block(block, blockcopy))
631 printf("testing FLAC__metadata_object_delete()... ");
632 FLAC__metadata_object_delete(blockcopy);
635 printf("testing FLAC__metadata_object_application_set_data(own)... ");
636 if(!FLAC__metadata_object_application_set_data(block, make_dummydata_(dummydata, sizeof(dummydata)), sizeof(dummydata), false/*own*/)) {
637 printf("FAILED, returned false\n");
640 expected_length = (FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8) + sizeof(dummydata);
641 if(block->length != expected_length) {
642 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
645 if(0 != memcmp(block->data.application.data, dummydata, sizeof(dummydata))) {
646 printf("FAILED, data mismatch\n");
651 printf("testing FLAC__metadata_object_clone()... ");
652 blockcopy = FLAC__metadata_object_clone(block);
654 printf("FAILED, returned NULL\n");
657 if(!mutils__compare_block(block, blockcopy))
661 printf("testing FLAC__metadata_object_delete()... ");
662 FLAC__metadata_object_delete(blockcopy);
663 FLAC__metadata_object_delete(block);
667 printf("testing SEEKTABLE\n");
669 for(i = 0; i < sizeof(seekpoint_array) / sizeof(FLAC__StreamMetadata_SeekPoint); i++) {
670 seekpoint_array[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
671 seekpoint_array[i].stream_offset = 0;
672 seekpoint_array[i].frame_samples = 0;
676 printf("testing FLAC__metadata_object_new()... ");
677 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE);
679 printf("FAILED, returned NULL\n");
682 if(!check_seektable_(block, seekpoints, 0))
685 printf("testing FLAC__metadata_object_clone()... ");
686 blockcopy = FLAC__metadata_object_clone(block);
688 printf("FAILED, returned NULL\n");
691 if(!mutils__compare_block(block, blockcopy))
695 printf("testing FLAC__metadata_object_delete()... ");
696 FLAC__metadata_object_delete(blockcopy);
700 printf("testing FLAC__metadata_object_seektable_resize_points(grow to %u)...", seekpoints);
701 if(!FLAC__metadata_object_seektable_resize_points(block, seekpoints)) {
702 printf("FAILED, returned false\n");
705 if(!check_seektable_(block, seekpoints, seekpoint_array))
709 printf("testing FLAC__metadata_object_seektable_resize_points(shrink to %u)...", seekpoints);
710 if(!FLAC__metadata_object_seektable_resize_points(block, seekpoints)) {
711 printf("FAILED, returned false\n");
714 if(!check_seektable_(block, seekpoints, seekpoint_array))
717 printf("testing FLAC__metadata_object_seektable_is_legal()...");
718 if(!FLAC__metadata_object_seektable_is_legal(block)) {
719 printf("FAILED, returned false\n");
725 printf("testing FLAC__metadata_object_seektable_resize_points(shrink to %u)...", seekpoints);
726 if(!FLAC__metadata_object_seektable_resize_points(block, seekpoints)) {
727 printf("FAILED, returned false\n");
730 if(!check_seektable_(block, seekpoints, 0))
734 printf("testing FLAC__metadata_object_seektable_insert_point() on empty array...");
735 if(!FLAC__metadata_object_seektable_insert_point(block, 0, seekpoint_array[0])) {
736 printf("FAILED, returned false\n");
739 if(!check_seektable_(block, seekpoints, seekpoint_array))
742 seekpoint_array[0].sample_number = 1;
744 printf("testing FLAC__metadata_object_seektable_insert_point() on beginning of non-empty array...");
745 if(!FLAC__metadata_object_seektable_insert_point(block, 0, seekpoint_array[0])) {
746 printf("FAILED, returned false\n");
749 if(!check_seektable_(block, seekpoints, seekpoint_array))
752 seekpoint_array[1].sample_number = 2;
754 printf("testing FLAC__metadata_object_seektable_insert_point() on middle of non-empty array...");
755 if(!FLAC__metadata_object_seektable_insert_point(block, 1, seekpoint_array[1])) {
756 printf("FAILED, returned false\n");
759 if(!check_seektable_(block, seekpoints, seekpoint_array))
762 seekpoint_array[3].sample_number = 3;
764 printf("testing FLAC__metadata_object_seektable_insert_point() on end of non-empty array...");
765 if(!FLAC__metadata_object_seektable_insert_point(block, 3, seekpoint_array[3])) {
766 printf("FAILED, returned false\n");
769 if(!check_seektable_(block, seekpoints, seekpoint_array))
772 printf("testing FLAC__metadata_object_clone()... ");
773 blockcopy = FLAC__metadata_object_clone(block);
775 printf("FAILED, returned NULL\n");
778 if(!mutils__compare_block(block, blockcopy))
782 printf("testing FLAC__metadata_object_delete()... ");
783 FLAC__metadata_object_delete(blockcopy);
786 seekpoint_array[2].sample_number = seekpoint_array[3].sample_number;
788 printf("testing FLAC__metadata_object_seektable_delete_point() on middle of array...");
789 if(!FLAC__metadata_object_seektable_delete_point(block, 2)) {
790 printf("FAILED, returned false\n");
793 if(!check_seektable_(block, seekpoints, seekpoint_array))
797 printf("testing FLAC__metadata_object_seektable_delete_point() on end of array...");
798 if(!FLAC__metadata_object_seektable_delete_point(block, 2)) {
799 printf("FAILED, returned false\n");
802 if(!check_seektable_(block, seekpoints, seekpoint_array))
806 printf("testing FLAC__metadata_object_seektable_delete_point() on beginning of array...");
807 if(!FLAC__metadata_object_seektable_delete_point(block, 0)) {
808 printf("FAILED, returned false\n");
811 if(!check_seektable_(block, seekpoints, seekpoint_array+1))
814 printf("testing FLAC__metadata_object_seektable_set_point()...");
815 FLAC__metadata_object_seektable_set_point(block, 0, seekpoint_array[0]);
816 if(!check_seektable_(block, seekpoints, seekpoint_array))
819 printf("testing FLAC__metadata_object_delete()... ");
820 FLAC__metadata_object_delete(block);
823 /* seektable template functions */
825 for(i = 0; i < sizeof(seekpoint_array) / sizeof(FLAC__StreamMetadata_SeekPoint); i++) {
826 seekpoint_array[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
827 seekpoint_array[i].stream_offset = 0;
828 seekpoint_array[i].frame_samples = 0;
832 printf("testing FLAC__metadata_object_new()... ");
833 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE);
835 printf("FAILED, returned NULL\n");
838 if(!check_seektable_(block, seekpoints, 0))
842 printf("testing FLAC__metadata_object_seekpoint_template_append_placeholders()... ");
843 if(!FLAC__metadata_object_seektable_template_append_placeholders(block, 2)) {
844 printf("FAILED, returned false\n");
847 if(!check_seektable_(block, seekpoints, seekpoint_array))
850 seekpoint_array[seekpoints++].sample_number = 7;
851 printf("testing FLAC__metadata_object_seekpoint_template_append_point()... ");
852 if(!FLAC__metadata_object_seektable_template_append_point(block, 7)) {
853 printf("FAILED, returned false\n");
856 if(!check_seektable_(block, seekpoints, seekpoint_array))
860 FLAC__uint64 nums[2] = { 3, 7 };
861 seekpoint_array[seekpoints++].sample_number = nums[0];
862 seekpoint_array[seekpoints++].sample_number = nums[1];
863 printf("testing FLAC__metadata_object_seekpoint_template_append_points()... ");
864 if(!FLAC__metadata_object_seektable_template_append_points(block, nums, sizeof(nums)/sizeof(FLAC__uint64))) {
865 printf("FAILED, returned false\n");
868 if(!check_seektable_(block, seekpoints, seekpoint_array))
872 seekpoint_array[seekpoints++].sample_number = 0;
873 seekpoint_array[seekpoints++].sample_number = 10;
874 seekpoint_array[seekpoints++].sample_number = 20;
875 printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points()... ");
876 if(!FLAC__metadata_object_seektable_template_append_spaced_points(block, 3, 30)) {
877 printf("FAILED, returned false\n");
880 if(!check_seektable_(block, seekpoints, seekpoint_array))
884 seekpoint_array[0].sample_number = 0;
885 seekpoint_array[1].sample_number = 3;
886 seekpoint_array[2].sample_number = 7;
887 seekpoint_array[3].sample_number = 10;
888 seekpoint_array[4].sample_number = 20;
889 seekpoint_array[5].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
890 seekpoint_array[6].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
891 printf("testing FLAC__metadata_object_seekpoint_template_sort(compact=true)... ");
892 if(!FLAC__metadata_object_seektable_template_sort(block, /*compact=*/true)) {
893 printf("FAILED, returned false\n");
896 if(!FLAC__metadata_object_seektable_is_legal(block)) {
897 printf("FAILED, seek table is illegal\n");
900 if(!check_seektable_(block, seekpoints, seekpoint_array))
903 printf("testing FLAC__metadata_object_seekpoint_template_sort(compact=false)... ");
904 if(!FLAC__metadata_object_seektable_template_sort(block, /*compact=*/false)) {
905 printf("FAILED, returned false\n");
908 if(!FLAC__metadata_object_seektable_is_legal(block)) {
909 printf("FAILED, seek table is illegal\n");
912 if(!check_seektable_(block, seekpoints, seekpoint_array))
915 seekpoint_array[seekpoints++].sample_number = 0;
916 seekpoint_array[seekpoints++].sample_number = 10;
917 seekpoint_array[seekpoints++].sample_number = 20;
918 printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points_by_samples()... ");
919 if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(block, 10, 30)) {
920 printf("FAILED, returned false\n");
923 if(!check_seektable_(block, seekpoints, seekpoint_array))
926 seekpoint_array[seekpoints++].sample_number = 0;
927 seekpoint_array[seekpoints++].sample_number = 11;
928 seekpoint_array[seekpoints++].sample_number = 22;
929 printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points_by_samples()... ");
930 if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(block, 11, 30)) {
931 printf("FAILED, returned false\n");
934 if(!check_seektable_(block, seekpoints, seekpoint_array))
937 printf("testing FLAC__metadata_object_delete()... ");
938 FLAC__metadata_object_delete(block);
942 printf("testing VORBIS_COMMENT\n");
945 FLAC__StreamMetadata_VorbisComment_Entry entry_;
946 char *field_name, *field_value;
948 printf("testing FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair()... ");
949 if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry_, "name", "value")) {
950 printf("FAILED, returned false\n");
953 if(strcmp((const char *)entry_.entry, "name=value")) {
954 printf("FAILED, field mismatch\n");
959 printf("testing FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair()... ");
960 if(!FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(entry_, &field_name, &field_value)) {
961 printf("FAILED, returned false\n");
964 if(strcmp(field_name, "name")) {
965 printf("FAILED, field name mismatch\n");
968 if(strcmp(field_value, "value")) {
969 printf("FAILED, field value mismatch\n");
974 printf("testing FLAC__metadata_object_vorbiscomment_entry_matches()... ");
975 if(!FLAC__metadata_object_vorbiscomment_entry_matches(entry_, field_name, strlen(field_name))) {
976 printf("FAILED, expected true, returned false\n");
981 printf("testing FLAC__metadata_object_vorbiscomment_entry_matches()... ");
982 if(FLAC__metadata_object_vorbiscomment_entry_matches(entry_, "blah", strlen("blah"))) {
983 printf("FAILED, expected false, returned true\n");
993 printf("testing FLAC__metadata_object_new()... ");
994 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
996 printf("FAILED, returned NULL\n");
999 expected_length = (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + strlen(FLAC__VENDOR_STRING) + FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN/8);
1000 if(block->length != expected_length) {
1001 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
1006 printf("testing FLAC__metadata_object_clone()... ");
1007 vorbiscomment = FLAC__metadata_object_clone(block);
1008 if(0 == vorbiscomment) {
1009 printf("FAILED, returned NULL\n");
1012 if(!mutils__compare_block(vorbiscomment, block))
1016 vc_resize_(vorbiscomment, 2);
1017 printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(grow to %u)...", vorbiscomment->data.vorbis_comment.num_comments);
1018 if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) {
1019 printf("FAILED, returned false\n");
1022 if(!mutils__compare_block(vorbiscomment, block))
1026 vc_resize_(vorbiscomment, 1);
1027 printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(shrink to %u)...", vorbiscomment->data.vorbis_comment.num_comments);
1028 if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) {
1029 printf("FAILED, returned false\n");
1032 if(!mutils__compare_block(vorbiscomment, block))
1036 vc_resize_(vorbiscomment, 0);
1037 printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(shrink to %u)...", vorbiscomment->data.vorbis_comment.num_comments);
1038 if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) {
1039 printf("FAILED, returned false\n");
1042 if(!mutils__compare_block(vorbiscomment, block))
1046 printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on empty array...");
1047 vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1");
1048 if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
1049 printf("FAILED, returned false\n");
1052 if(!mutils__compare_block(vorbiscomment, block))
1056 printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array...");
1057 vc_insert_new_(&entry, vorbiscomment, 1, "name2=field2");
1058 if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
1059 printf("FAILED, returned false\n");
1062 if(!mutils__compare_block(vorbiscomment, block))
1066 vc_resize_(vorbiscomment, 0);
1067 printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(shrink to %u)...", vorbiscomment->data.vorbis_comment.num_comments);
1068 if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) {
1069 printf("FAILED, returned false\n");
1072 if(!mutils__compare_block(vorbiscomment, block))
1076 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on empty array...");
1077 vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1");
1078 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/true)) {
1079 printf("FAILED, returned false\n");
1082 if(!mutils__compare_block(vorbiscomment, block))
1086 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on beginning of non-empty array...");
1087 vc_insert_new_(&entry, vorbiscomment, 0, "name2=field2");
1088 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/true)) {
1089 printf("FAILED, returned false\n");
1092 if(!mutils__compare_block(vorbiscomment, block))
1096 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on middle of non-empty array...");
1097 vc_insert_new_(&entry, vorbiscomment, 1, "name3=field3");
1098 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 1, entry, /*copy=*/true)) {
1099 printf("FAILED, returned false\n");
1102 if(!mutils__compare_block(vorbiscomment, block))
1106 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on end of non-empty array...");
1107 vc_insert_new_(&entry, vorbiscomment, 3, "name4=field4");
1108 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 3, entry, /*copy=*/true)) {
1109 printf("FAILED, returned false\n");
1112 if(!mutils__compare_block(vorbiscomment, block))
1116 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on end of non-empty array...");
1117 vc_insert_new_(&entry, vorbiscomment, 4, "name3=field3dup1");
1118 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 4, entry, /*copy=*/true)) {
1119 printf("FAILED, returned false\n");
1122 if(!mutils__compare_block(vorbiscomment, block))
1126 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on end of non-empty array...");
1127 vc_insert_new_(&entry, vorbiscomment, 5, "name3=field3dup1");
1128 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 5, entry, /*copy=*/true)) {
1129 printf("FAILED, returned false\n");
1132 if(!mutils__compare_block(vorbiscomment, block))
1136 printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
1137 if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, "name3")) != 1) {
1138 printf("FAILED, expected 1, got %d\n", j);
1143 printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
1144 if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, j+1, "name3")) != 4) {
1145 printf("FAILED, expected 4, got %d\n", j);
1150 printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
1151 if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, j+1, "name3")) != 5) {
1152 printf("FAILED, expected 5, got %d\n", j);
1157 printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
1158 if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, "name2")) != 0) {
1159 printf("FAILED, expected 0, got %d\n", j);
1164 printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
1165 if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, j+1, "name2")) != -1) {
1166 printf("FAILED, expected -1, got %d\n", j);
1171 printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
1172 if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, "blah")) != -1) {
1173 printf("FAILED, expected -1, got %d\n", j);
1178 printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(first, copy)...");
1179 vc_replace_new_(&entry, vorbiscomment, "name3=field3new1", /*all=*/false);
1180 if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/false, /*copy=*/true)) {
1181 printf("FAILED, returned false\n");
1184 if(!mutils__compare_block(vorbiscomment, block))
1186 if(block->data.vorbis_comment.num_comments != 6) {
1187 printf("FAILED, expected 6 comments, got %u\n", block->data.vorbis_comment.num_comments);
1192 printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(all, copy)...");
1193 vc_replace_new_(&entry, vorbiscomment, "name3=field3new2", /*all=*/true);
1194 if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/true, /*copy=*/true)) {
1195 printf("FAILED, returned false\n");
1198 if(!mutils__compare_block(vorbiscomment, block))
1200 if(block->data.vorbis_comment.num_comments != 4) {
1201 printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments);
1206 printf("testing FLAC__metadata_object_clone()... ");
1207 blockcopy = FLAC__metadata_object_clone(block);
1208 if(0 == blockcopy) {
1209 printf("FAILED, returned NULL\n");
1212 if(!mutils__compare_block(block, blockcopy))
1216 printf("testing FLAC__metadata_object_delete()... ");
1217 FLAC__metadata_object_delete(blockcopy);
1220 printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on middle of array...");
1221 vc_delete_(vorbiscomment, 2);
1222 if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
1223 printf("FAILED, returned false\n");
1226 if(!mutils__compare_block(vorbiscomment, block))
1230 printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on end of array...");
1231 vc_delete_(vorbiscomment, 2);
1232 if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
1233 printf("FAILED, returned false\n");
1236 if(!mutils__compare_block(vorbiscomment, block))
1240 printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on beginning of array...");
1241 vc_delete_(vorbiscomment, 0);
1242 if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 0)) {
1243 printf("FAILED, returned false\n");
1246 if(!mutils__compare_block(vorbiscomment, block))
1250 printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array...");
1251 vc_insert_new_(&entry, vorbiscomment, 1, "rem0=val0");
1252 if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
1253 printf("FAILED, returned false\n");
1256 if(!mutils__compare_block(vorbiscomment, block))
1260 printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array...");
1261 vc_insert_new_(&entry, vorbiscomment, 2, "rem0=val1");
1262 if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
1263 printf("FAILED, returned false\n");
1266 if(!mutils__compare_block(vorbiscomment, block))
1270 printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array...");
1271 vc_insert_new_(&entry, vorbiscomment, 3, "rem0=val2");
1272 if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
1273 printf("FAILED, returned false\n");
1276 if(!mutils__compare_block(vorbiscomment, block))
1280 printf("testing FLAC__metadata_object_vorbiscomment_remove_entry_matching(\"blah\")...");
1281 if((j = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, "blah")) != 0) {
1282 printf("FAILED, expected 0, got %d\n", j);
1285 if(block->data.vorbis_comment.num_comments != 4) {
1286 printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments);
1289 if(!mutils__compare_block(vorbiscomment, block))
1293 printf("testing FLAC__metadata_object_vorbiscomment_remove_entry_matching(\"rem0\")...");
1294 vc_delete_(vorbiscomment, 1);
1295 if((j = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, "rem0")) != 1) {
1296 printf("FAILED, expected 1, got %d\n", j);
1299 if(block->data.vorbis_comment.num_comments != 3) {
1300 printf("FAILED, expected 3 comments, got %u\n", block->data.vorbis_comment.num_comments);
1303 if(!mutils__compare_block(vorbiscomment, block))
1307 printf("testing FLAC__metadata_object_vorbiscomment_remove_entries_matching(\"blah\")...");
1308 if((j = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, "blah")) != 0) {
1309 printf("FAILED, expected 0, got %d\n", j);
1312 if(block->data.vorbis_comment.num_comments != 3) {
1313 printf("FAILED, expected 3 comments, got %u\n", block->data.vorbis_comment.num_comments);
1316 if(!mutils__compare_block(vorbiscomment, block))
1320 printf("testing FLAC__metadata_object_vorbiscomment_remove_entries_matching(\"rem0\")...");
1321 vc_delete_(vorbiscomment, 1);
1322 vc_delete_(vorbiscomment, 1);
1323 if((j = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, "rem0")) != 2) {
1324 printf("FAILED, expected 2, got %d\n", j);
1327 if(block->data.vorbis_comment.num_comments != 1) {
1328 printf("FAILED, expected 1 comments, got %u\n", block->data.vorbis_comment.num_comments);
1331 if(!mutils__compare_block(vorbiscomment, block))
1335 printf("testing FLAC__metadata_object_vorbiscomment_set_comment(copy)...");
1336 vc_set_new_(&entry, vorbiscomment, 0, "name5=field5");
1337 FLAC__metadata_object_vorbiscomment_set_comment(block, 0, entry, /*copy=*/true);
1338 if(!mutils__compare_block(vorbiscomment, block))
1342 printf("testing FLAC__metadata_object_vorbiscomment_set_vendor_string(copy)...");
1343 vc_set_vs_new_(&entry, vorbiscomment, "name6=field6");
1344 FLAC__metadata_object_vorbiscomment_set_vendor_string(block, entry, /*copy=*/true);
1345 if(!mutils__compare_block(vorbiscomment, block))
1349 printf("testing FLAC__metadata_object_delete()... ");
1350 FLAC__metadata_object_delete(vorbiscomment);
1351 FLAC__metadata_object_delete(block);
1355 printf("testing FLAC__metadata_object_new()... ");
1356 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
1358 printf("FAILED, returned NULL\n");
1363 printf("testing FLAC__metadata_object_clone()... ");
1364 vorbiscomment = FLAC__metadata_object_clone(block);
1365 if(0 == vorbiscomment) {
1366 printf("FAILED, returned NULL\n");
1369 if(!mutils__compare_block(vorbiscomment, block))
1373 printf("testing FLAC__metadata_object_vorbiscomment_append_comment(own) on empty array...");
1374 vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1");
1375 entry_clone_(&entry);
1376 if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) {
1377 printf("FAILED, returned false\n");
1380 if(!mutils__compare_block(vorbiscomment, block))
1384 printf("testing FLAC__metadata_object_vorbiscomment_append_comment(own) on non-empty array...");
1385 vc_insert_new_(&entry, vorbiscomment, 1, "name2=field2");
1386 entry_clone_(&entry);
1387 if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) {
1388 printf("FAILED, returned false\n");
1391 if(!mutils__compare_block(vorbiscomment, block))
1395 printf("testing FLAC__metadata_object_delete()... ");
1396 FLAC__metadata_object_delete(vorbiscomment);
1397 FLAC__metadata_object_delete(block);
1400 printf("testing FLAC__metadata_object_new()... ");
1401 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
1403 printf("FAILED, returned NULL\n");
1408 printf("testing FLAC__metadata_object_clone()... ");
1409 vorbiscomment = FLAC__metadata_object_clone(block);
1410 if(0 == vorbiscomment) {
1411 printf("FAILED, returned NULL\n");
1414 if(!mutils__compare_block(vorbiscomment, block))
1418 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on empty array...");
1419 vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1");
1420 entry_clone_(&entry);
1421 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/false)) {
1422 printf("FAILED, returned false\n");
1425 if(!mutils__compare_block(vorbiscomment, block))
1429 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on beginning of non-empty array...");
1430 vc_insert_new_(&entry, vorbiscomment, 0, "name2=field2");
1431 entry_clone_(&entry);
1432 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/false)) {
1433 printf("FAILED, returned false\n");
1436 if(!mutils__compare_block(vorbiscomment, block))
1440 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on middle of non-empty array...");
1441 vc_insert_new_(&entry, vorbiscomment, 1, "name3=field3");
1442 entry_clone_(&entry);
1443 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 1, entry, /*copy=*/false)) {
1444 printf("FAILED, returned false\n");
1447 if(!mutils__compare_block(vorbiscomment, block))
1451 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array...");
1452 vc_insert_new_(&entry, vorbiscomment, 3, "name4=field4");
1453 entry_clone_(&entry);
1454 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 3, entry, /*copy=*/false)) {
1455 printf("FAILED, returned false\n");
1458 if(!mutils__compare_block(vorbiscomment, block))
1462 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array...");
1463 vc_insert_new_(&entry, vorbiscomment, 4, "name3=field3dup1");
1464 entry_clone_(&entry);
1465 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 4, entry, /*copy=*/false)) {
1466 printf("FAILED, returned false\n");
1469 if(!mutils__compare_block(vorbiscomment, block))
1473 printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array...");
1474 vc_insert_new_(&entry, vorbiscomment, 5, "name3=field3dup1");
1475 entry_clone_(&entry);
1476 if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 5, entry, /*copy=*/false)) {
1477 printf("FAILED, returned false\n");
1480 if(!mutils__compare_block(vorbiscomment, block))
1484 printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(first, own)...");
1485 vc_replace_new_(&entry, vorbiscomment, "name3=field3new1", /*all=*/false);
1486 entry_clone_(&entry);
1487 if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/false, /*copy=*/false)) {
1488 printf("FAILED, returned false\n");
1491 if(!mutils__compare_block(vorbiscomment, block))
1493 if(block->data.vorbis_comment.num_comments != 6) {
1494 printf("FAILED, expected 6 comments, got %u\n", block->data.vorbis_comment.num_comments);
1499 printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(all, own)...");
1500 vc_replace_new_(&entry, vorbiscomment, "name3=field3new2", /*all=*/true);
1501 entry_clone_(&entry);
1502 if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/true, /*copy=*/false)) {
1503 printf("FAILED, returned false\n");
1506 if(!mutils__compare_block(vorbiscomment, block))
1508 if(block->data.vorbis_comment.num_comments != 4) {
1509 printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments);
1514 printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on middle of array...");
1515 vc_delete_(vorbiscomment, 2);
1516 if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
1517 printf("FAILED, returned false\n");
1520 if(!mutils__compare_block(vorbiscomment, block))
1524 printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on end of array...");
1525 vc_delete_(vorbiscomment, 2);
1526 if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
1527 printf("FAILED, returned false\n");
1530 if(!mutils__compare_block(vorbiscomment, block))
1534 printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on beginning of array...");
1535 vc_delete_(vorbiscomment, 0);
1536 if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 0)) {
1537 printf("FAILED, returned false\n");
1540 if(!mutils__compare_block(vorbiscomment, block))
1544 printf("testing FLAC__metadata_object_vorbiscomment_set_comment(own)...");
1545 vc_set_new_(&entry, vorbiscomment, 0, "name5=field5");
1546 entry_clone_(&entry);
1547 FLAC__metadata_object_vorbiscomment_set_comment(block, 0, entry, /*copy=*/false);
1548 if(!mutils__compare_block(vorbiscomment, block))
1552 printf("testing FLAC__metadata_object_vorbiscomment_set_vendor_string(own)...");
1553 vc_set_vs_new_(&entry, vorbiscomment, "name6=field6");
1554 entry_clone_(&entry);
1555 FLAC__metadata_object_vorbiscomment_set_vendor_string(block, entry, /*copy=*/false);
1556 if(!mutils__compare_block(vorbiscomment, block))
1560 printf("testing FLAC__metadata_object_delete()... ");
1561 FLAC__metadata_object_delete(vorbiscomment);
1562 FLAC__metadata_object_delete(block);
1566 printf("testing CUESHEET\n");
1569 FLAC__StreamMetadata_CueSheet_Track *track_, *trackcopy_;
1571 printf("testing FLAC__metadata_object_cuesheet_track_new()... ");
1572 track_ = FLAC__metadata_object_cuesheet_track_new();
1574 printf("FAILED, returned NULL\n");
1579 printf("testing FLAC__metadata_object_cuesheet_track_clone()... ");
1580 trackcopy_ = FLAC__metadata_object_cuesheet_track_clone(track_);
1581 if(0 == trackcopy_) {
1582 printf("FAILED, returned NULL\n");
1585 if(!compare_track_(trackcopy_, track_))
1589 printf("testing FLAC__metadata_object_cuesheet_track_delete()... ");
1590 FLAC__metadata_object_cuesheet_track_delete(trackcopy_);
1591 FLAC__metadata_object_cuesheet_track_delete(track_);
1596 printf("testing FLAC__metadata_object_new()... ");
1597 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET);
1599 printf("FAILED, returned NULL\n");
1603 FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
1604 FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
1605 FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
1606 FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
1607 FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
1609 if(block->length != expected_length) {
1610 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
1615 printf("testing FLAC__metadata_object_clone()... ");
1616 cuesheet = FLAC__metadata_object_clone(block);
1618 printf("FAILED, returned NULL\n");
1621 if(!mutils__compare_block(cuesheet, block))
1625 cs_resize_(cuesheet, 2);
1626 printf("testing FLAC__metadata_object_cuesheet_resize_tracks(grow to %u)...", cuesheet->data.cue_sheet.num_tracks);
1627 if(!FLAC__metadata_object_cuesheet_resize_tracks(block, cuesheet->data.cue_sheet.num_tracks)) {
1628 printf("FAILED, returned false\n");
1631 if(!mutils__compare_block(cuesheet, block))
1635 cs_resize_(cuesheet, 1);
1636 printf("testing FLAC__metadata_object_cuesheet_resize_tracks(shrink to %u)...", cuesheet->data.cue_sheet.num_tracks);
1637 if(!FLAC__metadata_object_cuesheet_resize_tracks(block, cuesheet->data.cue_sheet.num_tracks)) {
1638 printf("FAILED, returned false\n");
1641 if(!mutils__compare_block(cuesheet, block))
1645 cs_resize_(cuesheet, 0);
1646 printf("testing FLAC__metadata_object_cuesheet_resize_tracks(shrink to %u)...", cuesheet->data.cue_sheet.num_tracks);
1647 if(!FLAC__metadata_object_cuesheet_resize_tracks(block, cuesheet->data.cue_sheet.num_tracks)) {
1648 printf("FAILED, returned false\n");
1651 if(!mutils__compare_block(cuesheet, block))
1655 printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on empty array...");
1656 cs_insert_new_(&track, cuesheet, 0, 0, 1, "ABCDE1234567", false, false);
1657 if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/true)) {
1658 printf("FAILED, returned false\n");
1661 if(!mutils__compare_block(cuesheet, block))
1665 printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on beginning of non-empty array...");
1666 cs_insert_new_(&track, cuesheet, 0, 10, 2, "BBCDE1234567", false, false);
1667 if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/true)) {
1668 printf("FAILED, returned false\n");
1671 if(!mutils__compare_block(cuesheet, block))
1675 printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on middle of non-empty array...");
1676 cs_insert_new_(&track, cuesheet, 1, 20, 3, "CBCDE1234567", false, false);
1677 if(!FLAC__metadata_object_cuesheet_insert_track(block, 1, &track, /*copy=*/true)) {
1678 printf("FAILED, returned false\n");
1681 if(!mutils__compare_block(cuesheet, block))
1685 printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on end of non-empty array...");
1686 cs_insert_new_(&track, cuesheet, 3, 30, 4, "DBCDE1234567", false, false);
1687 if(!FLAC__metadata_object_cuesheet_insert_track(block, 3, &track, /*copy=*/true)) {
1688 printf("FAILED, returned false\n");
1691 if(!mutils__compare_block(cuesheet, block))
1695 printf("testing FLAC__metadata_object_cuesheet_insert_blank_track() on end of non-empty array...");
1696 cs_insert_new_(&track, cuesheet, 4, 0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0", false, false);
1697 if(!FLAC__metadata_object_cuesheet_insert_blank_track(block, 4)) {
1698 printf("FAILED, returned false\n");
1701 if(!mutils__compare_block(cuesheet, block))
1705 printf("testing FLAC__metadata_object_clone()... ");
1706 blockcopy = FLAC__metadata_object_clone(block);
1707 if(0 == blockcopy) {
1708 printf("FAILED, returned NULL\n");
1711 if(!mutils__compare_block(block, blockcopy))
1715 printf("testing FLAC__metadata_object_delete()... ");
1716 FLAC__metadata_object_delete(blockcopy);
1719 printf("testing FLAC__metadata_object_cuesheet_delete_track() on end of array...");
1720 cs_delete_(cuesheet, 4);
1721 if(!FLAC__metadata_object_cuesheet_delete_track(block, 4)) {
1722 printf("FAILED, returned false\n");
1725 if(!mutils__compare_block(cuesheet, block))
1729 printf("testing FLAC__metadata_object_cuesheet_delete_track() on middle of array...");
1730 cs_delete_(cuesheet, 2);
1731 if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) {
1732 printf("FAILED, returned false\n");
1735 if(!mutils__compare_block(cuesheet, block))
1739 printf("testing FLAC__metadata_object_cuesheet_delete_track() on end of array...");
1740 cs_delete_(cuesheet, 2);
1741 if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) {
1742 printf("FAILED, returned false\n");
1745 if(!mutils__compare_block(cuesheet, block))
1749 printf("testing FLAC__metadata_object_cuesheet_delete_track() on beginning of array...");
1750 cs_delete_(cuesheet, 0);
1751 if(!FLAC__metadata_object_cuesheet_delete_track(block, 0)) {
1752 printf("FAILED, returned false\n");
1755 if(!mutils__compare_block(cuesheet, block))
1759 printf("testing FLAC__metadata_object_cuesheet_set_track(copy)...");
1760 cs_set_new_(&track, cuesheet, 0, 40, 5, "EBCDE1234567", false, false);
1761 FLAC__metadata_object_cuesheet_set_track(block, 0, &track, /*copy=*/true);
1762 if(!mutils__compare_block(cuesheet, block))
1766 tr_resize_(cuesheet, 0, 2);
1767 printf("testing FLAC__metadata_object_cuesheet_track_resize_indices(grow to %u)...", cuesheet->data.cue_sheet.tracks[0].num_indices);
1768 if(!FLAC__metadata_object_cuesheet_track_resize_indices(block, 0, cuesheet->data.cue_sheet.tracks[0].num_indices)) {
1769 printf("FAILED, returned false\n");
1772 if(!mutils__compare_block(cuesheet, block))
1776 tr_resize_(cuesheet, 0, 1);
1777 printf("testing FLAC__metadata_object_cuesheet_track_resize_indices(shrink to %u)...", cuesheet->data.cue_sheet.tracks[0].num_indices);
1778 if(!FLAC__metadata_object_cuesheet_track_resize_indices(block, 0, cuesheet->data.cue_sheet.tracks[0].num_indices)) {
1779 printf("FAILED, returned false\n");
1782 if(!mutils__compare_block(cuesheet, block))
1786 tr_resize_(cuesheet, 0, 0);
1787 printf("testing FLAC__metadata_object_cuesheet_track_resize_indices(shrink to %u)...", cuesheet->data.cue_sheet.tracks[0].num_indices);
1788 if(!FLAC__metadata_object_cuesheet_track_resize_indices(block, 0, cuesheet->data.cue_sheet.tracks[0].num_indices)) {
1789 printf("FAILED, returned false\n");
1792 if(!mutils__compare_block(cuesheet, block))
1798 printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on empty array...");
1799 tr_insert_new_(cuesheet, 0, 0, index);
1800 if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, index)) {
1801 printf("FAILED, returned false\n");
1804 if(!mutils__compare_block(cuesheet, block))
1810 printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on beginning of non-empty array...");
1811 tr_insert_new_(cuesheet, 0, 0, index);
1812 if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, index)) {
1813 printf("FAILED, returned false\n");
1816 if(!mutils__compare_block(cuesheet, block))
1822 printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on middle of non-empty array...");
1823 tr_insert_new_(cuesheet, 0, 1, index);
1824 if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 1, index)) {
1825 printf("FAILED, returned false\n");
1828 if(!mutils__compare_block(cuesheet, block))
1834 printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on end of non-empty array...");
1835 tr_insert_new_(cuesheet, 0, 3, index);
1836 if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 3, index)) {
1837 printf("FAILED, returned false\n");
1840 if(!mutils__compare_block(cuesheet, block))
1846 printf("testing FLAC__metadata_object_cuesheet_track_insert_blank_index() on end of non-empty array...");
1847 tr_insert_new_(cuesheet, 0, 4, index);
1848 if(!FLAC__metadata_object_cuesheet_track_insert_blank_index(block, 0, 4)) {
1849 printf("FAILED, returned false\n");
1852 if(!mutils__compare_block(cuesheet, block))
1856 printf("testing FLAC__metadata_object_clone()... ");
1857 blockcopy = FLAC__metadata_object_clone(block);
1858 if(0 == blockcopy) {
1859 printf("FAILED, returned NULL\n");
1862 if(!mutils__compare_block(block, blockcopy))
1866 printf("testing FLAC__metadata_object_delete()... ");
1867 FLAC__metadata_object_delete(blockcopy);
1870 printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on end of array...");
1871 tr_delete_(cuesheet, 0, 4);
1872 if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 4)) {
1873 printf("FAILED, returned false\n");
1876 if(!mutils__compare_block(cuesheet, block))
1880 printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on middle of array...");
1881 tr_delete_(cuesheet, 0, 2);
1882 if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 2)) {
1883 printf("FAILED, returned false\n");
1886 if(!mutils__compare_block(cuesheet, block))
1890 printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on end of array...");
1891 tr_delete_(cuesheet, 0, 2);
1892 if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 2)) {
1893 printf("FAILED, returned false\n");
1896 if(!mutils__compare_block(cuesheet, block))
1900 printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on beginning of array...");
1901 tr_delete_(cuesheet, 0, 0);
1902 if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 0)) {
1903 printf("FAILED, returned false\n");
1906 if(!mutils__compare_block(cuesheet, block))
1910 printf("testing FLAC__metadata_object_delete()... ");
1911 FLAC__metadata_object_delete(cuesheet);
1912 FLAC__metadata_object_delete(block);
1916 printf("testing FLAC__metadata_object_new()... ");
1917 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET);
1919 printf("FAILED, returned NULL\n");
1924 printf("testing FLAC__metadata_object_clone()... ");
1925 cuesheet = FLAC__metadata_object_clone(block);
1927 printf("FAILED, returned NULL\n");
1930 if(!mutils__compare_block(cuesheet, block))
1934 printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on empty array...");
1935 cs_insert_new_(&track, cuesheet, 0, 60, 7, "GBCDE1234567", false, false);
1936 track_clone_(&track);
1937 if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/false)) {
1938 printf("FAILED, returned false\n");
1941 if(!mutils__compare_block(cuesheet, block))
1945 printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on beginning of non-empty array...");
1946 cs_insert_new_(&track, cuesheet, 0, 70, 8, "HBCDE1234567", false, false);
1947 track_clone_(&track);
1948 if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/false)) {
1949 printf("FAILED, returned false\n");
1952 if(!mutils__compare_block(cuesheet, block))
1956 printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on middle of non-empty array...");
1957 cs_insert_new_(&track, cuesheet, 1, 80, 9, "IBCDE1234567", false, false);
1958 track_clone_(&track);
1959 if(!FLAC__metadata_object_cuesheet_insert_track(block, 1, &track, /*copy=*/false)) {
1960 printf("FAILED, returned false\n");
1963 if(!mutils__compare_block(cuesheet, block))
1967 printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on end of non-empty array...");
1968 cs_insert_new_(&track, cuesheet, 3, 90, 10, "JBCDE1234567", false, false);
1969 track_clone_(&track);
1970 if(!FLAC__metadata_object_cuesheet_insert_track(block, 3, &track, /*copy=*/false)) {
1971 printf("FAILED, returned false\n");
1974 if(!mutils__compare_block(cuesheet, block))
1978 printf("testing FLAC__metadata_object_cuesheet_delete_track() on middle of array...");
1979 cs_delete_(cuesheet, 2);
1980 if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) {
1981 printf("FAILED, returned false\n");
1984 if(!mutils__compare_block(cuesheet, block))
1988 printf("testing FLAC__metadata_object_cuesheet_delete_track() on end of array...");
1989 cs_delete_(cuesheet, 2);
1990 if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) {
1991 printf("FAILED, returned false\n");
1994 if(!mutils__compare_block(cuesheet, block))
1998 printf("testing FLAC__metadata_object_cuesheet_delete_track() on beginning of array...");
1999 cs_delete_(cuesheet, 0);
2000 if(!FLAC__metadata_object_cuesheet_delete_track(block, 0)) {
2001 printf("FAILED, returned false\n");
2004 if(!mutils__compare_block(cuesheet, block))
2008 printf("testing FLAC__metadata_object_cuesheet_set_track(own)...");
2009 cs_set_new_(&track, cuesheet, 0, 100, 11, "KBCDE1234567", false, false);
2010 track_clone_(&track);
2011 FLAC__metadata_object_cuesheet_set_track(block, 0, &track, /*copy=*/false);
2012 if(!mutils__compare_block(cuesheet, block))
2016 printf("testing FLAC__metadata_object_cuesheet_is_legal()...");
2018 const char *violation;
2019 if(FLAC__metadata_object_cuesheet_is_legal(block, /*check_cd_da_subset=*/true, &violation)) {
2020 printf("FAILED, returned true when expecting false\n");
2023 printf("returned false as expected, violation=\"%s\" OK\n", violation);
2026 printf("testing FLAC__metadata_object_delete()... ");
2027 FLAC__metadata_object_delete(cuesheet);
2028 FLAC__metadata_object_delete(block);
2032 printf("testing PICTURE\n");
2034 printf("testing FLAC__metadata_object_new()... ");
2035 block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE);
2037 printf("FAILED, returned NULL\n");
2041 FLAC__STREAM_METADATA_PICTURE_TYPE_LEN +
2042 FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN +
2043 FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN +
2044 FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN +
2045 FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN +
2046 FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN +
2047 FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN
2049 if(block->length != expected_length) {
2050 printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length);
2055 printf("testing FLAC__metadata_object_clone()... ");
2056 picture = FLAC__metadata_object_clone(block);
2058 printf("FAILED, returned NULL\n");
2061 if(!mutils__compare_block(picture, block))
2065 pi_set_mime_type(picture, "image/png\t");
2066 printf("testing FLAC__metadata_object_picture_set_mime_type(copy)...");
2067 if(!FLAC__metadata_object_picture_set_mime_type(block, "image/png\t", /*copy=*/true)) {
2068 printf("FAILED, returned false\n");
2071 if(!mutils__compare_block(picture, block))
2075 printf("testing FLAC__metadata_object_picture_is_legal()...");
2077 const char *violation;
2078 if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
2079 printf("FAILED, returned true when expecting false\n");
2082 printf("returned false as expected, violation=\"%s\" OK\n", violation);
2085 pi_set_mime_type(picture, "image/png");
2086 printf("testing FLAC__metadata_object_picture_set_mime_type(copy)...");
2087 if(!FLAC__metadata_object_picture_set_mime_type(block, "image/png", /*copy=*/true)) {
2088 printf("FAILED, returned false\n");
2091 if(!mutils__compare_block(picture, block))
2095 printf("testing FLAC__metadata_object_picture_is_legal()...");
2097 const char *violation;
2098 if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
2099 printf("FAILED, returned false, violation=\"%s\"\n", violation);
2105 pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION\xff");
2106 printf("testing FLAC__metadata_object_picture_set_description(copy)...");
2107 if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)"DESCRIPTION\xff", /*copy=*/true)) {
2108 printf("FAILED, returned false\n");
2111 if(!mutils__compare_block(picture, block))
2115 printf("testing FLAC__metadata_object_picture_is_legal()...");
2117 const char *violation;
2118 if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
2119 printf("FAILED, returned true when expecting false\n");
2122 printf("returned false as expected, violation=\"%s\" OK\n", violation);
2125 pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION");
2126 printf("testing FLAC__metadata_object_picture_set_description(copy)...");
2127 if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)"DESCRIPTION", /*copy=*/true)) {
2128 printf("FAILED, returned false\n");
2131 if(!mutils__compare_block(picture, block))
2135 printf("testing FLAC__metadata_object_picture_is_legal()...");
2137 const char *violation;
2138 if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
2139 printf("FAILED, returned false, violation=\"%s\"\n", violation);
2146 pi_set_data(picture, (const FLAC__byte*)"PNGDATA", strlen("PNGDATA"));
2147 printf("testing FLAC__metadata_object_picture_set_data(copy)...");
2148 if(!FLAC__metadata_object_picture_set_data(block, (FLAC__byte*)"PNGDATA", strlen("PNGDATA"), /*copy=*/true)) {
2149 printf("FAILED, returned false\n");
2152 if(!mutils__compare_block(picture, block))
2156 printf("testing FLAC__metadata_object_clone()... ");
2157 blockcopy = FLAC__metadata_object_clone(block);
2158 if(0 == blockcopy) {
2159 printf("FAILED, returned NULL\n");
2162 if(!mutils__compare_block(block, blockcopy))
2166 printf("testing FLAC__metadata_object_delete()... ");
2167 FLAC__metadata_object_delete(blockcopy);
2170 pi_set_mime_type(picture, "image/png\t");
2171 printf("testing FLAC__metadata_object_picture_set_mime_type(own)...");
2172 if(!FLAC__metadata_object_picture_set_mime_type(block, strdup("image/png\t"), /*copy=*/false)) {
2173 printf("FAILED, returned false\n");
2176 if(!mutils__compare_block(picture, block))
2180 printf("testing FLAC__metadata_object_picture_is_legal()...");
2182 const char *violation;
2183 if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
2184 printf("FAILED, returned true when expecting false\n");
2187 printf("returned false as expected, violation=\"%s\" OK\n", violation);
2190 pi_set_mime_type(picture, "image/png");
2191 printf("testing FLAC__metadata_object_picture_set_mime_type(own)...");
2192 if(!FLAC__metadata_object_picture_set_mime_type(block, strdup("image/png"), /*copy=*/false)) {
2193 printf("FAILED, returned false\n");
2196 if(!mutils__compare_block(picture, block))
2200 printf("testing FLAC__metadata_object_picture_is_legal()...");
2202 const char *violation;
2203 if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
2204 printf("FAILED, returned false, violation=\"%s\"\n", violation);
2210 pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION\xff");
2211 printf("testing FLAC__metadata_object_picture_set_description(own)...");
2212 if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)strdup("DESCRIPTION\xff"), /*copy=*/false)) {
2213 printf("FAILED, returned false\n");
2216 if(!mutils__compare_block(picture, block))
2220 printf("testing FLAC__metadata_object_picture_is_legal()...");
2222 const char *violation;
2223 if(FLAC__metadata_object_picture_is_legal(block, &violation)) {
2224 printf("FAILED, returned true when expecting false\n");
2227 printf("returned false as expected, violation=\"%s\" OK\n", violation);
2230 pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION");
2231 printf("testing FLAC__metadata_object_picture_set_description(own)...");
2232 if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)strdup("DESCRIPTION"), /*copy=*/false)) {
2233 printf("FAILED, returned false\n");
2236 if(!mutils__compare_block(picture, block))
2240 printf("testing FLAC__metadata_object_picture_is_legal()...");
2242 const char *violation;
2243 if(!FLAC__metadata_object_picture_is_legal(block, &violation)) {
2244 printf("FAILED, returned false, violation=\"%s\"\n", violation);
2250 pi_set_data(picture, (const FLAC__byte*)"PNGDATA", strlen("PNGDATA"));
2251 printf("testing FLAC__metadata_object_picture_set_data(own)...");
2252 if(!FLAC__metadata_object_picture_set_data(block, (FLAC__byte*)strdup("PNGDATA"), strlen("PNGDATA"), /*copy=*/false)) {
2253 printf("FAILED, returned false\n");
2256 if(!mutils__compare_block(picture, block))
2260 printf("testing FLAC__metadata_object_clone()... ");
2261 blockcopy = FLAC__metadata_object_clone(block);
2262 if(0 == blockcopy) {
2263 printf("FAILED, returned NULL\n");
2266 if(!mutils__compare_block(block, blockcopy))
2270 printf("testing FLAC__metadata_object_delete()... ");
2271 FLAC__metadata_object_delete(blockcopy);
2274 printf("testing FLAC__metadata_object_delete()... ");
2275 FLAC__metadata_object_delete(picture);
2276 FLAC__metadata_object_delete(block);