From 3e77092f85cbf1ff6a60b975097acd64f1fb523e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Mon, 5 Nov 2018 18:52:10 -0500 Subject: [PATCH] t: check that render_tags is faithful --- t/unit.cc | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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; }