Skip to content

Commit

Permalink
Clean up FEC tests
Browse files Browse the repository at this point in the history
- Use UNSIGNED_LONGS_EQUAL instead of CHECK for more clear test output
- Unify UNSIGNED_LONGS_EQUAL and LONGS_EQUAL usage
  • Loading branch information
dshil authored and gavv committed Dec 5, 2023
1 parent 548e36e commit 9fb7379
Showing 1 changed file with 66 additions and 66 deletions.
132 changes: 66 additions & 66 deletions src/tests/roc_fec/test_writer_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ TEST(writer_reader, 1_loss) {
}
dispatcher.push_stocks();

LONGS_EQUAL(NumSourcePackets - 1, dispatcher.source_size());
LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());
UNSIGNED_LONGS_EQUAL(NumSourcePackets - 1, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());

for (size_t i = 0; i < NumSourcePackets; ++i) {
packet::PacketPtr p;
Expand Down Expand Up @@ -376,7 +376,7 @@ TEST(writer_reader, lost_first_packet_in_first_block) {
check_audio_packet(p, i);
check_restored(p, false);
}
CHECK(dispatcher.source_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
}
}

Expand Down Expand Up @@ -447,7 +447,7 @@ TEST(writer_reader, lost_one_source_and_all_repair_packets) {
}
}

CHECK(dispatcher.source_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
}
}

Expand Down Expand Up @@ -496,14 +496,14 @@ TEST(writer_reader, multiple_blocks_1_loss) {
dispatcher.push_stocks();

if (lost_sq == size_t(-1)) {
CHECK(dispatcher.source_size() == NumSourcePackets);
CHECK(dispatcher.repair_size() == NumRepairPackets);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());
} else if (lost_sq < NumSourcePackets) {
CHECK(dispatcher.source_size() == NumSourcePackets - 1);
CHECK(dispatcher.repair_size() == NumRepairPackets);
UNSIGNED_LONGS_EQUAL(NumSourcePackets - 1, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());
} else {
CHECK(dispatcher.source_size() == NumSourcePackets);
CHECK(dispatcher.repair_size() == NumRepairPackets - 1);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets - 1, dispatcher.repair_size());
}

for (size_t i = 0; i < NumSourcePackets; ++i) {
Expand Down Expand Up @@ -565,8 +565,8 @@ TEST(writer_reader, multiple_blocks_in_queue) {
}
dispatcher.push_stocks();

CHECK(dispatcher.source_size() == NumSourcePackets * NumBlocks);
CHECK(dispatcher.repair_size() == NumRepairPackets * NumBlocks);
UNSIGNED_LONGS_EQUAL(NumSourcePackets * NumBlocks, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets * NumBlocks, dispatcher.repair_size());

for (size_t block_num = 0; block_num < NumBlocks; ++block_num) {
for (size_t i = 0; i < NumSourcePackets; ++i) {
Expand Down Expand Up @@ -758,7 +758,7 @@ TEST(writer_reader, late_out_of_order_packets) {

// Deliver packets 0-6 and 11-20
dispatcher.push_stocks();
CHECK(dispatcher.source_size() == NumSourcePackets - (10 - 7 + 1));
UNSIGNED_LONGS_EQUAL(NumSourcePackets - (10 - 7 + 1), dispatcher.source_size());

// Read packets 0-6
for (size_t i = 0; i < 7; ++i) {
Expand Down Expand Up @@ -790,7 +790,7 @@ TEST(writer_reader, late_out_of_order_packets) {
}
}

LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
}
}

Expand Down Expand Up @@ -875,8 +875,8 @@ TEST(writer_reader, repair_packets_before_source_packets) {
}
}

CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());

UNSIGNED_LONGS_EQUAL(wr_sn, rd_sn);
}
Expand Down Expand Up @@ -975,8 +975,8 @@ TEST(writer_reader, repair_packets_mixed_with_source_packets) {
}
}

CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());

UNSIGNED_LONGS_EQUAL(wr_sn, rd_sn);
}
Expand Down Expand Up @@ -1065,7 +1065,7 @@ TEST(writer_reader, multiple_repair_attempts) {
check_restored(p, false);
}

LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
}
}

Expand Down Expand Up @@ -1129,7 +1129,7 @@ TEST(writer_reader, drop_outdated_block) {
UNSIGNED_LONGS_EQUAL(status::StatusOK, reader.read(p));
CHECK(p);

CHECK(p->fec()->source_block_number == sbn);
UNSIGNED_LONGS_EQUAL(sbn, p->fec()->source_block_number);
}

// Read second block.
Expand All @@ -1138,7 +1138,7 @@ TEST(writer_reader, drop_outdated_block) {
UNSIGNED_LONGS_EQUAL(status::StatusOK, reader.read(p));
CHECK(p);

CHECK(p->fec()->source_block_number == sbn + 1);
UNSIGNED_LONGS_EQUAL(sbn + 1, p->fec()->source_block_number);
}
}
}
Expand Down Expand Up @@ -1209,7 +1209,7 @@ TEST(writer_reader, repaired_block_numbering) {

if (n != lost_packet_n) {
CHECK(p->fec());
CHECK(p->fec()->source_block_number == sbn);
UNSIGNED_LONGS_EQUAL(sbn, p->fec()->source_block_number);
} else {
CHECK(!p->fec());
}
Expand All @@ -1225,7 +1225,7 @@ TEST(writer_reader, repaired_block_numbering) {
check_restored(p, false);

CHECK(p->fec());
CHECK(p->fec()->source_block_number == sbn + 1);
UNSIGNED_LONGS_EQUAL(sbn + 1, p->fec()->source_block_number);
}
}
}
Expand Down Expand Up @@ -1307,8 +1307,8 @@ TEST(writer_reader, invalid_esi) {
}

CHECK(reader.is_alive());
CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());
}
}
}
Expand Down Expand Up @@ -1385,8 +1385,8 @@ TEST(writer_reader, invalid_sbl) {
}

CHECK(reader.is_alive());
CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());
}
}
}
Expand Down Expand Up @@ -1462,8 +1462,8 @@ TEST(writer_reader, invalid_nes) {
}

CHECK(reader.is_alive());
CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());
}
}
}
Expand Down Expand Up @@ -1549,8 +1549,8 @@ TEST(writer_reader, invalid_payload_size) {
}

CHECK(reader.is_alive());
CHECK(source_queue.size() == 0);
CHECK(repair_queue.size() == 0);
UNSIGNED_LONGS_EQUAL(0, source_queue.size());
UNSIGNED_LONGS_EQUAL(0, repair_queue.size());
}
}
}
Expand Down Expand Up @@ -1636,8 +1636,8 @@ TEST(writer_reader, zero_source_packets) {
}

CHECK(reader.is_alive());
CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());
}
}
}
Expand Down Expand Up @@ -1720,8 +1720,8 @@ TEST(writer_reader, zero_repair_packets) {
}

CHECK(reader.is_alive());
CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());
}
}
}
Expand Down Expand Up @@ -1807,8 +1807,8 @@ TEST(writer_reader, zero_payload_size) {
}

CHECK(reader.is_alive());
CHECK(source_queue.size() == 0);
CHECK(repair_queue.size() == 0);
UNSIGNED_LONGS_EQUAL(0, source_queue.size());
UNSIGNED_LONGS_EQUAL(0, repair_queue.size());
}
}
}
Expand Down Expand Up @@ -1928,8 +1928,8 @@ TEST(writer_reader, sbn_jump) {
CHECK(!pp);
CHECK(!reader.is_alive());

CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());

// TODO(gh-183): compare with StatusDead
UNSIGNED_LONGS_EQUAL(status::StatusNoData, reader.read(pp));
Expand Down Expand Up @@ -1994,13 +1994,13 @@ TEST(writer_reader, writer_encode_blocks) {
const packet::RTP* rtp = p->rtp();
CHECK(rtp);

LONGS_EQUAL(data_source, rtp->source);
UNSIGNED_LONGS_EQUAL(data_source, rtp->source);

const packet::FEC* fec = p->fec();
CHECK(fec);

LONGS_EQUAL(fec_sbn, fec->source_block_number);
CHECK(fec->source_block_length == NumSourcePackets);
UNSIGNED_LONGS_EQUAL(fec_sbn, fec->source_block_number);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, fec->source_block_length);
UNSIGNED_LONGS_EQUAL(encoding_symbol_id, fec->encoding_symbol_id);

encoding_symbol_id++;
Expand All @@ -2018,8 +2018,8 @@ TEST(writer_reader, writer_encode_blocks) {
const packet::FEC* fec = p->fec();
CHECK(fec);

LONGS_EQUAL(fec_sbn, fec->source_block_number);
CHECK(fec->source_block_length == NumSourcePackets);
UNSIGNED_LONGS_EQUAL(fec_sbn, fec->source_block_number);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, fec->source_block_length);
UNSIGNED_LONGS_EQUAL(encoding_symbol_id, fec->encoding_symbol_id);

encoding_symbol_id++;
Expand Down Expand Up @@ -2249,7 +2249,7 @@ TEST(writer_reader, resize_block_middle) {

CHECK(p);
CHECK(p->fec());
CHECK(p->fec()->source_block_length == prev_sblen);
UNSIGNED_LONGS_EQUAL(prev_sblen, p->fec()->source_block_length);

check_audio_packet(p, rd_sn, prev_psize);
check_restored(p, false);
Expand Down Expand Up @@ -2428,8 +2428,8 @@ TEST(writer_reader, resize_block_repair_first) {
rd_sn++;
}

CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());

UNSIGNED_LONGS_EQUAL(wr_sn, rd_sn);
}
Expand Down Expand Up @@ -2466,8 +2466,8 @@ TEST(writer_reader, error_writer_resize_block) {
}

CHECK(writer.is_alive());
CHECK(dispatcher.source_size() == NumSourcePackets);
CHECK(dispatcher.repair_size() == BlockSize1);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(BlockSize1, dispatcher.repair_size());

dispatcher.push_stocks();
dispatcher.reset();
Expand All @@ -2482,8 +2482,8 @@ TEST(writer_reader, error_writer_resize_block) {
CHECK(!writer.is_alive());
}

CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());
}
}

Expand Down Expand Up @@ -2519,8 +2519,8 @@ TEST(writer_reader, error_writer_encode_packet) {
}

CHECK(writer.is_alive());
CHECK(dispatcher.source_size() == BlockSize1);
CHECK(dispatcher.repair_size() == NumRepairPackets);
UNSIGNED_LONGS_EQUAL(BlockSize1, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());

mock_arena.set_fail(true);
CHECK(writer.resize(BlockSize2, NumRepairPackets));
Expand All @@ -2531,8 +2531,8 @@ TEST(writer_reader, error_writer_encode_packet) {
CHECK(!writer.is_alive());
}

CHECK(dispatcher.source_size() == BlockSize1);
CHECK(dispatcher.repair_size() == NumRepairPackets);
UNSIGNED_LONGS_EQUAL(BlockSize1, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());
}
}

Expand Down Expand Up @@ -2708,7 +2708,7 @@ TEST(writer_reader, writer_oversized_block) {
CHECK(encoder);
CHECK(decoder);

CHECK(decoder->max_block_length() == encoder->max_block_length());
UNSIGNED_LONGS_EQUAL(decoder->max_block_length(), encoder->max_block_length());
CHECK(NumSourcePackets + NumRepairPackets <= encoder->max_block_length());

test::PacketDispatcher dispatcher(source_parser(), repair_parser(),
Expand Down Expand Up @@ -2741,8 +2741,8 @@ TEST(writer_reader, writer_oversized_block) {
// deliver packets from dispatcher to reader
dispatcher.push_stocks();

CHECK(dispatcher.source_size() == NumSourcePackets);
CHECK(dispatcher.repair_size() == NumRepairPackets);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());

// read packets
for (size_t i = 0; i < NumSourcePackets; ++i) {
Expand All @@ -2757,8 +2757,8 @@ TEST(writer_reader, writer_oversized_block) {
}

CHECK(reader.is_alive());
CHECK(dispatcher.source_size() == 0);
CHECK(dispatcher.repair_size() == 0);
UNSIGNED_LONGS_EQUAL(0, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(0, dispatcher.repair_size());
}
}
}
Expand All @@ -2776,7 +2776,7 @@ TEST(writer_reader, reader_oversized_source_block) {
CHECK(encoder);
CHECK(decoder);

CHECK(decoder->max_block_length() == encoder->max_block_length());
UNSIGNED_LONGS_EQUAL(decoder->max_block_length(), encoder->max_block_length());
CHECK((NumSourcePackets + NumRepairPackets) < encoder->max_block_length());

packet::Queue queue;
Expand Down Expand Up @@ -2824,8 +2824,8 @@ TEST(writer_reader, reader_oversized_source_block) {
// deliver packets from dispatcher to reader
dispatcher.push_stocks();

CHECK(dispatcher.source_size() == NumSourcePackets);
CHECK(dispatcher.repair_size() == NumRepairPackets);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());

// reader should get an error because maximum block size was exceeded
packet::PacketPtr pp;
Expand All @@ -2848,7 +2848,7 @@ TEST(writer_reader, reader_oversized_repair_block) {
CHECK(encoder);
CHECK(decoder);

CHECK(decoder->max_block_length() == encoder->max_block_length());
UNSIGNED_LONGS_EQUAL(decoder->max_block_length(), encoder->max_block_length());
CHECK((NumSourcePackets + NumRepairPackets) < encoder->max_block_length());

packet::Queue queue;
Expand Down Expand Up @@ -2896,8 +2896,8 @@ TEST(writer_reader, reader_oversized_repair_block) {
// deliver packets from dispatcher to reader
dispatcher.push_stocks();

CHECK(dispatcher.source_size() == NumSourcePackets);
CHECK(dispatcher.repair_size() == NumRepairPackets);
UNSIGNED_LONGS_EQUAL(NumSourcePackets, dispatcher.source_size());
UNSIGNED_LONGS_EQUAL(NumRepairPackets, dispatcher.repair_size());

// reader should get an error because maximum block size was exceeded
packet::PacketPtr pp;
Expand Down

0 comments on commit 9fb7379

Please sign in to comment.