diff --git a/t/unit.cc b/t/unit.cc index f887efb..e8e7acd 100644 --- a/t/unit.cc +++ b/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; }