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

📄 metadata_object.cpp

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

	printf("testing Entry::get_field_name()... ");
	if(0 != memcmp(entry1.get_field_name(), "name2", strlen("name2")))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing Entry::get_field_value()... ");
	if(0 != memcmp(entry1.get_field_value(), "value2", strlen("value2")))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing Entry::set_field_name()... ");
	if(!entry1.set_field_name("name1"))
		return die_("returned false");
	if(0 != memcmp(entry1.get_field_name(), "name1", strlen("name1")))
		return die_("value mismatch");
	if(0 != memcmp(entry1.get_field(), "name1=value2", strlen("name1=value2")))
		return die_("entry mismatch");
	printf("OK\n");

	printf("testing Entry::set_field_value(const char *field_value, unsigned field_value_length)... ");
	if(!entry1.set_field_value("value1", strlen("value1")))
		return die_("returned false");
	if(0 != memcmp(entry1.get_field_value(), "value1", strlen("value1")))
		return die_("value mismatch");
	if(0 != memcmp(entry1.get_field(), "name1=value1", strlen("name1=value1")))
		return die_("entry mismatch");
	printf("OK\n");

	printf("testing Entry::set_field_value(const char *field_value)... ");
	if(!entry1.set_field_value("value1"))
		return die_("returned false");
	if(0 != memcmp(entry1.get_field_value(), "value1", strlen("value1")))
		return die_("value mismatch");
	if(0 != memcmp(entry1.get_field(), "name1=value1", strlen("name1=value1")))
		return die_("entry mismatch");
	printf("OK\n");

	printf("testing Entry::set_field(const char *field, unsigned field_length)... ");
	if(!entry1.set_field("name0=value0", strlen("name0=value0")))
		return die_("returned false");
	if(0 != memcmp(entry1.get_field_name(), "name0", strlen("name0")))
		return die_("value mismatch");
	if(0 != memcmp(entry1.get_field_value(), "value0", strlen("value0")))
		return die_("value mismatch");
	if(0 != memcmp(entry1.get_field(), "name0=value0", strlen("name0=value0")))
		return die_("entry mismatch");
	printf("OK\n");

	printf("testing Entry::set_field(const char *field)... ");
	if(!entry1.set_field("name0=value0"))
		return die_("returned false");
	if(0 != memcmp(entry1.get_field_name(), "name0", strlen("name0")))
		return die_("value mismatch");
	if(0 != memcmp(entry1.get_field_value(), "value0", strlen("value0")))
		return die_("value mismatch");
	if(0 != memcmp(entry1.get_field(), "name0=value0", strlen("name0=value0")))
		return die_("entry mismatch");
	printf("OK\n");

	printf("PASSED\n\n");


	printf("testing class FLAC::Metadata::VorbisComment\n");

	printf("testing VorbisComment::VorbisComment()... ");
	FLAC::Metadata::VorbisComment block;
	if(!block.is_valid())
		return die_("!block.is_valid()");
	expected_length = (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + strlen(::FLAC__VENDOR_STRING) + FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN/8);
	if(block.get_length() != expected_length) {
		printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length());
		return false;
	}
	printf("OK\n");

	printf("testing VorbisComment::VorbisComment(const VorbisComment &)... +\n");
	printf("        VorbisComment::operator!=(const VorbisComment &)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy(block);
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(blockcopy != block)
			return die_("copy is not identical to original");
		printf("OK\n");

		printf("testing VorbisComment::~VorbisComment()... ");
	}
	printf("OK\n");

	printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata &)... +\n");
	printf("        VorbisComment::operator!=(const ::FLAC__StreamMetadata &)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy(vorbiscomment_);
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(blockcopy != vorbiscomment_)
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata *)... +\n");
	printf("        VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy(&vorbiscomment_);
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(blockcopy != vorbiscomment_)
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata *, copy=true)... +\n");
	printf("        VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy(&vorbiscomment_, /*copy=*/true);
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(blockcopy != vorbiscomment_)
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata *, copy=false)... +\n");
	printf("        VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... ");
	{
		::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&vorbiscomment_);
		FLAC::Metadata::VorbisComment blockcopy(copy, /*copy=*/false);
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(blockcopy != vorbiscomment_)
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n");
	printf("        VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy;
		blockcopy.assign(&vorbiscomment_, /*copy=*/true);
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(blockcopy != vorbiscomment_)
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n");
	printf("        VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... ");
	{
		::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&vorbiscomment_);
		FLAC::Metadata::VorbisComment blockcopy;
		blockcopy.assign(copy, /*copy=*/false);
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(blockcopy != vorbiscomment_)
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::operator=(const VorbisComment &)... +\n");
	printf("        VorbisComment::operator==(const VorbisComment &)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy = block;
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(!(blockcopy == block))
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::operator=(const ::FLAC__StreamMetadata &)... +\n");
	printf("        VorbisComment::operator==(const ::FLAC__StreamMetadata &)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy = vorbiscomment_;
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(!(blockcopy == vorbiscomment_))
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::operator=(const ::FLAC__StreamMetadata *)... +\n");
	printf("        VorbisComment::operator==(const ::FLAC__StreamMetadata *)... ");
	{
		FLAC::Metadata::VorbisComment blockcopy = &vorbiscomment_;
		if(!blockcopy.is_valid())
			return die_("!block.is_valid()");
		if(!(blockcopy == vorbiscomment_))
			return die_("copy is not identical to original");
		printf("OK\n");
	}

	printf("testing VorbisComment::get_num_comments()... ");
	if(block.get_num_comments() != 0)
		return die_("value mismatch, expected 0");
	printf("OK\n");

	printf("testing VorbisComment::set_vendor_string()... ");
	if(!block.set_vendor_string((const FLAC__byte *)"mame0"))
		return die_("returned false");
	printf("OK\n");
	vorbiscomment_.data.vorbis_comment.vendor_string.entry[0] = 'm';

	printf("testing VorbisComment::get_vendor_string()... ");
	if(strlen((const char *)block.get_vendor_string()) != vorbiscomment_.data.vorbis_comment.vendor_string.length)
		return die_("length mismatch");
	if(0 != memcmp(block.get_vendor_string(), vorbiscomment_.data.vorbis_comment.vendor_string.entry, vorbiscomment_.data.vorbis_comment.vendor_string.length))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing VorbisComment::append_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.append_comment(entry3))
		return die_("returned false");
	if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length)
		return die_("length mismatch");
	if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing VorbisComment::append_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.append_comment(entry2))
		return die_("returned false");
	if(block.get_comment(1).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length)
		return die_("length mismatch");
	if(0 != memcmp(block.get_comment(1).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing VorbisComment::delete_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.delete_comment(0))
		return die_("returned false");
	if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length)
		return die_("length[0] mismatch");
	if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length))
		return die_("value[0] mismatch");
	printf("OK\n");

	printf("testing VorbisComment::delete_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.delete_comment(0))
		return die_("returned false");
	if(block.get_num_comments() != 0)
		return die_("block mismatch, expected num_comments = 0");
	printf("OK\n");

	printf("testing VorbisComment::insert_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.insert_comment(0, entry3))
		return die_("returned false");
	if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length)
		return die_("length mismatch");
	if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing VorbisComment::insert_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.insert_comment(0, entry3))
		return die_("returned false");
	if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length)
		return die_("length mismatch");
	if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing VorbisComment::insert_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.insert_comment(1, entry2))
		return die_("returned false");
	if(block.get_comment(1).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length)
		return die_("length mismatch");
	if(0 != memcmp(block.get_comment(1).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing VorbisComment::set_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.set_comment(0, entry2))
		return die_("returned false");
	if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length)
		return die_("length mismatch");
	if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length))
		return die_("value mismatch");
	printf("OK\n");

	printf("testing VorbisComment::delete_comment()... +\n");
	printf("        VorbisComment::get_comment()... ");
	if(!block.delete_comment(0))
		return die_("returned false");
	if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length)
		return die_("length[0] mismatch");
	if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length))
		return die_("value[0] mismatch");
	if(block.get_comment(1).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length)
		return die_("length[1] mismatch");
	if(0 != memcmp(block.get_comment(1).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length))
		return die_("value[0] mismatch");
	printf("OK\n");

	printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... ");
	FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block);
	if(0 == clone_)
		return die_("returned NULL");
	if(0 == dynamic_cast<FLAC::Metadata::VorbisComment *>(clone_))
		return die_("downcast is NULL");
	if(*dynamic_cast<FLAC::Metadata::VorbisComment *>(clone_) != block)
		return die_("clone is not identical");
	printf("OK\n");
	printf("testing VorbisComment::~VorbisComment()... ");
	delete clone_;
	printf("OK\n");


	printf("PASSED\n\n");
	return true;
}

bool test_metadata_object_cuesheet()
{
	unsigned expected_length;

	printf("testing class FLAC::Metadata::CueSheet::Track\n");

	printf("testing Track::Track()... ");
	FLAC::Metadata::CueSheet::Track track0;
	if(!track0.is_valid())
		return die_("!is_valid()");
	printf("OK\n");

	{
		printf("testing Track::get_track()... ");
		const ::FLAC__StreamMetadata_CueSheet_Track *trackp = track0.get_track();
		if(0 == trackp)
			return die_("returned pointer is NULL");
		printf("OK\n");

		printf("testing Track::Track(const ::FLAC__StreamMetadata_CueSheet_Track*)... ");
		FLAC::Metadata::CueSheet::Track track2(trackp);
		if(!track2.is_valid())
			return die_("!is_valid()");
		if(!track_is_equal_(track2.get_track(), trackp))
			return die_("copy is not equal");
		printf("OK\n");

		printf("testing Track::~Track()... ");
	}
	printf("OK\n");

⌨️ 快捷键说明

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