@@ -231,12 +231,18 @@ struct WSFrameEncoderTests {
231231
232232 @Test
233233 func decodeLength( ) async throws {
234+ #expect(
235+ try await WSFrameEncoder . decodeLength ( 0x00 ) == 0
236+ )
234237 #expect(
235238 try await WSFrameEncoder . decodeLength ( 0x01 ) == 1
236239 )
237240 #expect(
238241 try await WSFrameEncoder . decodeLength ( 0x7D ) == 125
239242 )
243+ #expect(
244+ try await WSFrameEncoder . decodeLength ( 0x7E , 0x00 , 0x7E ) == 126
245+ )
240246 #expect(
241247 try await WSFrameEncoder . decodeLength ( 0x7E , 0x00 , 0xFF ) == 0x00FF
242248 )
@@ -247,7 +253,22 @@ struct WSFrameEncoderTests {
247253 try await WSFrameEncoder . decodeLength ( 0x7E , 0xFF , 0xFF ) == 0xFFFF
248254 )
249255 #expect(
250- try await WSFrameEncoder . decodeLength ( 0x7F , 0xFF , 0xEE , 0xDD , 0xCC , 0xBB , 0xAA , 0x99 , 0x00 ) == 0x0099AABBCCDDEEFF
256+ try await WSFrameEncoder . decodeLength ( 0x7F , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 ) == 0x00010000
257+ )
258+ #expect(
259+ try await WSFrameEncoder . decodeLength ( 0x7F , 0x00 , 0x99 , 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ) == 0x0099AABBCCDDEEFF
260+ )
261+ #expect(
262+ try await WSFrameEncoder . decodeLength ( 0x7F , 0x7F , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF ) == Int . max
263+ )
264+ #expect(
265+ try await WSFrameEncoder . decodeLength ( 0x80 , 0x00 , 0x00 , 0x00 , 0x00 ) == 0x00
266+ )
267+ #expect(
268+ try await WSFrameEncoder . decodeLength ( 0xFE , 0x00 , 0x7E , 0x00 , 0x00 , 0x00 , 0x00 ) == 0x7E
269+ )
270+ #expect(
271+ try await WSFrameEncoder . decodeLength ( 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x7F , 0x00 , 0x00 , 0x00 , 0x00 ) == 0x7F
251272 )
252273 }
253274
@@ -256,9 +277,18 @@ struct WSFrameEncoderTests {
256277 await #expect( throws: SocketError . disconnected) {
257278 try await WSFrameEncoder . decodeLength ( 0x7E )
258279 }
280+ await #expect( throws: SocketError . disconnected) {
281+ try await WSFrameEncoder . decodeLength ( 0x7E , 0x00 )
282+ }
259283 await #expect( throws: SocketError . disconnected) {
260284 try await WSFrameEncoder . decodeLength ( 0x7F , 0xFF , 0xFF , 0xFF )
261285 }
286+ await #expect( throws: SocketError . disconnected) {
287+ try await WSFrameEncoder . decodeLength ( 0x7F , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 )
288+ }
289+ await #expect( throws: WSFrameEncoder . Error. self) {
290+ try await WSFrameEncoder . decodeLength ( 0x7F , 0x80 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 )
291+ }
262292 await #expect( throws: WSFrameEncoder . Error. self) {
263293 try await WSFrameEncoder . decodeLength ( 0x7F , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF )
264294 }
0 commit comments