mirror of
https://github.com/fmang/opustags.git
synced 2025-01-16 05:03:13 +01:00
t: check that render_tags is faithful
This commit is contained in:
parent
a3a6cb4e36
commit
3e77092f85
30
t/unit.cc
30
t/unit.cc
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user