Add error handling tests for USB connection and listing ports

This commit is contained in:
just-stuff-tm committed 2026-03-05 02:26:37 -05:00
1 parent 524558c511
commit 25fc9454a8
3 files changed
+97 -1

No files matched your search

@@ -138,4 +138,25 @@ void main() {
expect(packets, hasLength(1));
expect(packets.single.payload, orderedEquals(<int>[0x55]));
});
test('recovers from invalid frame header', () {
final decoder = UsbSerialFrameDecoder();
final packets = decoder.ingest(
Uint8List.fromList(<int>[
// First, a malformed frame (e.g. from a partial TX echo)
usbSerialRxFrameStart,
usbSerialTxFrameStart,
// Then, a valid frame
usbSerialRxFrameStart,
0x01,
0x00,
0x88,
]),
);
expect(packets, hasLength(1));
expect(packets.single.isRxFrame, isTrue);
expect(packets.single.payload, orderedEquals(<int>[0x88]));
});
}