t: check that render_tags is faithful

This commit is contained in:
Frédéric Mangano-Tarumi 2018-11-05 18:52:10 -05:00
parent a3a6cb4e36
commit 3e77092f85

View File

@ -58,9 +58,37 @@ static bool parse_standard()
return true;
}
static bool recode_standard()
{
ot::opus_tags tags;
int rc = ot::parse_tags(standard_OpusTags, sizeof(standard_OpusTags) - 1, &tags);
if (rc != 0)
throw failure("ot::parse_tags did not return 0");
ogg_packet packet;
rc = ot::render_tags(&tags, &packet);
if (rc != 0)
throw failure("ot::render_tags did not return 0");
if (packet.b_o_s != 0)
throw failure("b_o_s should not be set");
if (packet.e_o_s != 0)
throw failure("e_o_s should not be set");
if (packet.granulepos != 0)
throw failure("granule_post should be 0");
if (packet.packetno != 1)
throw failure("packetno should be 1");
if (packet.bytes != sizeof(standard_OpusTags) - 1)
throw failure("the packet is not the right size");
if (memcmp(packet.packet, standard_OpusTags, packet.bytes) != 0)
throw failure("the rendered packet is not what we expected");
ot::free_tags(&tags);
free(packet.packet);
return true;
}
int main()
{
std::cout << "1..1\n";
std::cout << "1..2\n";
run(parse_standard, "parse a standard OpusTags packet");
run(recode_standard, "recode a standard OpusTags packet");
return 0;
}