TEST_F(H4ParserTest, RequestedBytesDecreases) { // Make sure that the requested bytes is monotonically decreasing // for the requested types.
uint8_t typ = (uint8_t)PacketType::ACL;
ASSERT_TRUE(parser_.Consume(&typ, 1)); auto wanted = parser_.BytesRequested(); while (wanted > 0) {
ASSERT_EQ(wanted, parser_.BytesRequested());
ASSERT_TRUE(parser_.Consume(&typ, 1));
wanted--;
}
// A callback should have been invoked.
ASSERT_LT(0, (int)packet_.size());
}
TEST_F(H4ParserTest, RejectNoData) { // You need to give us something!
PacketData bad_bit;
ASSERT_FALSE(parser_.Consume(bad_bit.data(), bad_bit.size()));
}
TEST_F(H4ParserTest, CallsTheRightCallbacks) { // Make sure that the proper type of callback is invoked.
std::vector<PacketType> types({PacketType::ACL, PacketType::SCO, PacketType::COMMAND,
PacketType::EVENT, PacketType::ISO}); for (auto packetType : types) { // Configure the incoming packet.
uint8_t typ = (uint8_t)packetType;
ASSERT_TRUE(parser_.Consume(&typ, 1));
// Feed data as long as this packet is not complete. while (parser_.CurrentState() != H4Parser::State::HCI_TYPE) {
PacketData data; for (uint32_t i = 0; i < parser_.BytesRequested(); i++) {
data.push_back((uint8_t)i);
}
ASSERT_TRUE(parser_.Consume(data.data(), data.size()));
}
// The proper callbacks should have been invoked.
ASSERT_LT(0, (int)packet_.size());
ASSERT_EQ(packetType, type_);
}
}
TEST_F(H4ParserTest, Recovery) { // Validate that the recovery state is exited only after receiving the // HCI Reset command.
parser_.EnableRecovery();
// Enter recovery state after receiving an invalid packet type.
uint8_t invalid_packet_type = 0xfd;
ASSERT_TRUE(parser_.Consume(&invalid_packet_type, 1));
ASSERT_EQ(parser_.CurrentState(), H4Parser::State::HCI_RECOVERY);
// Send prefixes of the HCI Reset command, restarting over from the start. for (size_t n = 1; n < 4; n++) { for (size_t i = 0; i < n; i++) {
ASSERT_TRUE(parser_.Consume(&reset_command[i], 1));
ASSERT_EQ(parser_.CurrentState(), H4Parser::State::HCI_RECOVERY);
}
}
// Finally send the full HCI Reset command. for (size_t i = 0; i < 4; i++) {
ASSERT_EQ(parser_.CurrentState(), H4Parser::State::HCI_RECOVERY);
ASSERT_TRUE(parser_.Consume(&reset_command[i], 1));
}
// Validate that the HCI recovery state is exited, // and the HCI Reset command correctly received on the command callback.
ASSERT_EQ(parser_.CurrentState(), H4Parser::State::HCI_TYPE);
ASSERT_LT(0, (int)packet_.size());
// Validate that the HCI Reset command was correctly received.
ASSERT_EQ(type_, PacketType::COMMAND);
ASSERT_EQ(packet_.size(), reset_command.size() - 1); for (size_t i = 1; i < packet_.size(); i++) {
ASSERT_EQ(packet_[i - 1], reset_command[i]);
}
}
} // namespace rootcanal
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.