mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
### Motivation The `write(webSocketErrorCode:)`, `readWebSocketErrorCode()`, and `getWebSocketErrorCode(at:)` methods in ByteBuffer were not covered by unit tests https://github.com/apple/swift-nio/pull/3174#pullrequestreview-2743588010. Since a peekWebSocketErrorCode() method was recently added, I figured I should verify both the new peek API and the existing WebSocket error code APIs behave correctly. ### Modifications Added tests for: write(webSocketErrorCode:) getWebSocketErrorCode(at:) readWebSocketErrorCode() Tests verify: Correct encoding and decoding of WebSocket error codes Reader index behavior (no movement for get, movement for read) Handling of insufficient bytes Consistency between peek-before-read and post-read ### Result These tests ensure the WebSocket error code APIs in ByteBuffer are correct, and safe to use. Co-authored-by: Cory Benfield <lukasa@apple.com>