Skip to content

Commit

Permalink
clarify test loop
Browse files Browse the repository at this point in the history
  • Loading branch information
james-rms committed Jul 19, 2023
1 parent bd6ff3c commit 94844fb
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions cpp/test/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,22 +511,21 @@ TEST_CASE("Message index records", "[writer]") {
// read the records after the starting magic, stopping before the end magic.
mcap::RecordReader reader(buffer, sizeof(mcap::Magic), buffer.size() - sizeof(mcap::Magic));

std::optional<mcap::Record> curRecord = std::nullopt;
std::vector<uint16_t> messageIndexChannelIds;
uint32_t chunkCount = 0;
mcap::MessageIndex index;

do {
curRecord = reader.next();
if (curRecord->opcode == mcap::OpCode::MessageIndex) {
requireOk(mcap::McapReader::ParseMessageIndex(*curRecord, &index));
REQUIRE(index.records.size() > 0);
for (std::optional<mcap::Record> rec = reader.next(); rec != std::nullopt; rec = reader.next()) {
requireOk(reader.status());
if (rec->opcode == mcap::OpCode::MessageIndex) {
mcap::MessageIndex index;
requireOk(mcap::McapReader::ParseMessageIndex(*rec, &index));
REQUIRE(index.records.size() == 1);
messageIndexChannelIds.push_back(index.channelId);
}
if (curRecord->opcode == mcap::OpCode::Chunk) {
if (rec->opcode == mcap::OpCode::Chunk) {
chunkCount++;
}
} while (curRecord != std::nullopt && reader.status().ok());
}
requireOk(reader.status());

REQUIRE(chunkCount == 2);
Expand Down

0 comments on commit 94844fb

Please sign in to comment.