From c2cbced854b9b19685a802864d25af83ba6df37a Mon Sep 17 00:00:00 2001 From: Christian Holbrook Date: Wed, 8 Jan 2025 12:28:26 -0700 Subject: [PATCH] Add unit test for CaughtRuntimeError --- .../updates/AllThreadsStoppedUpdate.spec.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/debugProtocol/events/updates/AllThreadsStoppedUpdate.spec.ts b/src/debugProtocol/events/updates/AllThreadsStoppedUpdate.spec.ts index 26f8047e..9e483def 100644 --- a/src/debugProtocol/events/updates/AllThreadsStoppedUpdate.spec.ts +++ b/src/debugProtocol/events/updates/AllThreadsStoppedUpdate.spec.ts @@ -34,4 +34,36 @@ describe('AllThreadsStoppedUpdate', () => { stopReasonDetail: 'because' // 8 bytes }); }); + + it('serializes and deserializes properly StopReason.CaughtRuntimeError', () => { + const command = AllThreadsStoppedUpdate.fromJson({ + threadIndex: 1, + stopReason: StopReason.CaughtRuntimeError, + stopReasonDetail: 'because' + }); + + expect(command.data).to.eql({ + packetLength: undefined, + requestId: 0, + errorCode: ErrorCode.OK, + updateType: UpdateType.AllThreadsStopped, + + threadIndex: 1, + stopReason: StopReason.CaughtRuntimeError, + stopReasonDetail: 'because' + }); + + expect( + AllThreadsStoppedUpdate.fromBuffer(command.toBuffer()).data + ).to.eql({ + packetLength: 29, // 4 bytes + requestId: 0, // 4 bytes + errorCode: ErrorCode.OK, // 4 bytes + updateType: UpdateType.AllThreadsStopped, // 4 bytes + + threadIndex: 1, // 4 bytes + stopReason: StopReason.CaughtRuntimeError, // 1 bytes + stopReasonDetail: 'because' // 8 bytes + }); + }); });