⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metadata_object.c

📁 这是著名的TCPMP播放器在WINDWOWS,和WINCE下编译通过的源程序.笔者对其中的LIBMAD库做了针对ARM MPU的优化. 并增加了词幕功能.
💻 C
📖 第 1 页 / 共 5 页
字号:
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
	if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, j+1, "name2")) != -1) {
		printf("FAILED, expected -1, got %d\n", j);
		return false;
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()...");
	if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, "blah")) != -1) {
		printf("FAILED, expected -1, got %d\n", j);
		return false;
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(first, copy)...");
	vc_replace_new_(&entry, vorbiscomment, "name3=field3new1", /*all=*/false);
	if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/false, /*copy=*/true)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	if(block->data.vorbis_comment.num_comments != 6) {
		printf("FAILED, expected 6 comments, got %u\n", block->data.vorbis_comment.num_comments);
		return false;
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(all, copy)...");
	vc_replace_new_(&entry, vorbiscomment, "name3=field3new2", /*all=*/true);
	if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/true, /*copy=*/true)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	if(block->data.vorbis_comment.num_comments != 4) {
		printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments);
		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_vorbiscomment_delete_comment() on middle of array...");
	vc_delete_(vorbiscomment, 2);
	if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on end of array...");
	vc_delete_(vorbiscomment, 2);
	if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on beginning of array...");
	vc_delete_(vorbiscomment, 0);
	if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 0)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 1, "rem0=val0");
	if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 2, "rem0=val1");
	if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 3, "rem0=val2");
	if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_remove_entry_matching(\"blah\")...");
	if((j = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, "blah")) != 0) {
		printf("FAILED, expected 0, got %d\n", j);
		return false;
	}
	if(block->data.vorbis_comment.num_comments != 4) {
		printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments);
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_remove_entry_matching(\"rem0\")...");
	vc_delete_(vorbiscomment, 1);
	if((j = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, "rem0")) != 1) {
		printf("FAILED, expected 1, got %d\n", j);
		return false;
	}
	if(block->data.vorbis_comment.num_comments != 3) {
		printf("FAILED, expected 3 comments, got %u\n", block->data.vorbis_comment.num_comments);
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_remove_entries_matching(\"blah\")...");
	if((j = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, "blah")) != 0) {
		printf("FAILED, expected 0, got %d\n", j);
		return false;
	}
	if(block->data.vorbis_comment.num_comments != 3) {
		printf("FAILED, expected 3 comments, got %u\n", block->data.vorbis_comment.num_comments);
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_remove_entries_matching(\"rem0\")...");
	vc_delete_(vorbiscomment, 1);
	vc_delete_(vorbiscomment, 1);
	if((j = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, "rem0")) != 2) {
		printf("FAILED, expected 2, got %d\n", j);
		return false;
	}
	if(block->data.vorbis_comment.num_comments != 1) {
		printf("FAILED, expected 1 comments, got %u\n", block->data.vorbis_comment.num_comments);
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_set_comment(copy)...");
	vc_set_new_(&entry, vorbiscomment, 0, "name5=field5");
	FLAC__metadata_object_vorbiscomment_set_comment(block, 0, entry, /*copy=*/true);
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_set_vendor_string(copy)...");
	vc_set_vs_new_(&entry, vorbiscomment, "name6=field6");
	FLAC__metadata_object_vorbiscomment_set_vendor_string(block, entry, /*copy=*/true);
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_delete()... ");
	FLAC__metadata_object_delete(vorbiscomment);
	FLAC__metadata_object_delete(block);
	printf("OK\n");


	printf("testing FLAC__metadata_object_new()... ");
	block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
	if(0 == block) {
		printf("FAILED, returned NULL\n");
		return false;
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_clone()... ");
	vorbiscomment = FLAC__metadata_object_clone(block);
	if(0 == vorbiscomment) {
		printf("FAILED, returned NULL\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_append_comment(own) on empty array...");
	vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_append_comment(own) on non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 1, "name2=field2");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_delete()... ");
	FLAC__metadata_object_delete(vorbiscomment);
	FLAC__metadata_object_delete(block);
	printf("OK\n");

	printf("testing FLAC__metadata_object_new()... ");
	block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
	if(0 == block) {
		printf("FAILED, returned NULL\n");
		return false;
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_clone()... ");
	vorbiscomment = FLAC__metadata_object_clone(block);
	if(0 == vorbiscomment) {
		printf("FAILED, returned NULL\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on empty array...");
	vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on beginning of non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 0, "name2=field2");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on middle of non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 1, "name3=field3");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 1, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 3, "name4=field4");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 3, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 4, "name3=field3dup1");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 4, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array...");
	vc_insert_new_(&entry, vorbiscomment, 5, "name3=field3dup1");
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 5, entry, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(first, own)...");
	vc_replace_new_(&entry, vorbiscomment, "name3=field3new1", /*all=*/false);
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/false, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	if(block->data.vorbis_comment.num_comments != 6) {
		printf("FAILED, expected 6 comments, got %u\n", block->data.vorbis_comment.num_comments);
		return false;
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(all, own)...");
	vc_replace_new_(&entry, vorbiscomment, "name3=field3new2", /*all=*/true);
	entry_clone_(&entry);
	if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/true, /*copy=*/false)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	if(block->data.vorbis_comment.num_comments != 4) {
		printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments);
		return false;
	}
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on middle of array...");
	vc_delete_(vorbiscomment, 2);
	if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
		printf("FAILED, returned false\n");
		return false;
	}
	if(!mutils__compare_block(vorbiscomment, block))
		return false;
	printf("OK\n");

	printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on end of array...");
	vc_delete_(vorbiscomment, 2);
	if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) {
		printf("FAILED, returned false\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -