From bd50fb34d9c14d8056184228ca1f59011a1ada2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Mon, 5 Nov 2018 19:03:21 -0500 Subject: [PATCH] t: recode a packet with padding (fails) --- t/unit.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/t/unit.cc b/t/unit.cc index e8e7acd..c405353 100644 --- a/t/unit.cc +++ b/t/unit.cc @@ -85,10 +85,33 @@ static bool recode_standard() return true; } +static bool recode_padding() +{ + ot::opus_tags tags; + std::string padded_OpusTags(standard_OpusTags, sizeof(standard_OpusTags)); + // ^ note: padded_OpusTags ends with a null byte here + padded_OpusTags += "hello"; + int rc = ot::parse_tags(padded_OpusTags.data(), padded_OpusTags.size(), &tags); + if (rc != 0) + throw failure("ot::parse_tags did not return 0"); + ogg_packet packet; + rc = ot::render_tags(&tags, &packet); + if (packet.bytes < padded_OpusTags.size()) + throw failure("the packet was truncated"); + if (packet.bytes > padded_OpusTags.size()) + throw failure("the packet got too big"); + if (memcmp(packet.packet, padded_OpusTags.data(), 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..2\n"; + std::cout << "1..3\n"; run(parse_standard, "parse a standard OpusTags packet"); run(recode_standard, "recode a standard OpusTags packet"); + run(recode_padding, "recode a OpusTags packet with padding"); return 0; }