77//
88
99import XCTest
10+
1011@testable import CobsCodec
1112
1213final class GoldenTests : XCTestCase {
@@ -63,7 +64,7 @@ final class GoldenTests: XCTestCase {
6364
6465 func testCobsRoundTripBlockBoundaries( ) throws {
6566 for n in [ 253 , 254 , 255 , 256 , 510 ] {
66- let data = ( 0 ..< n) . map { UInt8 ( ( $0 % 255 ) + 1 ) } // no zeros
67+ let data = ( 0 ..< n) . map { UInt8 ( ( $0 % 255 ) + 1 ) } // no zeros
6768 let encoded = Cobs . encode ( data)
6869 XCTAssertFalse ( encoded. contains ( 0 ) , " n= \( n) output has zero " )
6970 XCTAssertEqual ( try Cobs . decode ( encoded) , data, " cobs round trip n= \( n) " )
@@ -78,7 +79,7 @@ final class GoldenTests: XCTestCase {
7879 // A pseudo-random spread of lengths and byte values.
7980 var state : UInt64 = 0x1234_5678_9abc_def0
8081 func next( ) -> UInt8 {
81- state = state &* 6364136223846793005 &+ 1442695040888963407
82+ state = state &* 6_364_136_223_846_793_005 &+ 1_442_695_040_888_963_407
8283 return UInt8 ( ( state >> 33 ) & 0xFF )
8384 }
8485 for len in 0 ..< 300 {
@@ -105,13 +106,15 @@ final class GoldenTests: XCTestCase {
105106 for p in payloads {
106107 let c = Cobs . encode ( p, sentinel: sentinel)
107108 if sentinel != 0 {
108- XCTAssertFalse ( c. contains ( sentinel) , " cobs output must avoid sentinel \( sentinel) " )
109+ XCTAssertFalse (
110+ c. contains ( sentinel) , " cobs output must avoid sentinel \( sentinel) " )
109111 }
110112 XCTAssertEqual ( try Cobs . decode ( c, sentinel: sentinel) , p)
111113
112114 let r = Cobsr . encode ( p, sentinel: sentinel)
113115 if sentinel != 0 {
114- XCTAssertFalse ( r. contains ( sentinel) , " cobsr output must avoid sentinel \( sentinel) " )
116+ XCTAssertFalse (
117+ r. contains ( sentinel) , " cobsr output must avoid sentinel \( sentinel) " )
115118 }
116119 XCTAssertEqual ( try Cobsr . decode ( r, sentinel: sentinel) , p)
117120 }
@@ -123,7 +126,7 @@ final class GoldenTests: XCTestCase {
123126 func testDecodeInPlaceMatchesNormal( ) throws {
124127 var state : UInt64 = 0xdead_beef_cafe_babe
125128 func next( ) -> UInt8 {
126- state = state &* 6364136223846793005 &+ 1442695040888963407
129+ state = state &* 6_364_136_223_846_793_005 &+ 1_442_695_040_888_963_407
127130 return UInt8 ( ( state >> 33 ) & 0xFF )
128131 }
129132 for sentinel : UInt8 in [ 0x00 , 0x7F , 0xFF ] {
@@ -190,7 +193,8 @@ final class GoldenTests: XCTestCase {
190193 wire += Framing . frame ( p, reduced: reduced, sentinel: sentinel)
191194 nonEmpty. append ( p)
192195 }
193- let out = try Framing . unframe ( wire, reduced: reduced, skipEmpty: false , sentinel: sentinel)
196+ let out = try Framing . unframe (
197+ wire, reduced: reduced, skipEmpty: false , sentinel: sentinel)
194198 XCTAssertEqual ( out, nonEmpty, " reduced= \( reduced) sentinel= \( sentinel) " )
195199 }
196200 }
@@ -246,7 +250,7 @@ final class GoldenTests: XCTestCase {
246250
247251 func testStreamDecoderReset( ) throws {
248252 let dec = CobsStreamDecoder ( )
249- _ = try dec. feed ( [ 0x02 , 0x11 ] ) // partial frame, no delimiter yet
253+ _ = try dec. feed ( [ 0x02 , 0x11 ] ) // partial frame, no delimiter yet
250254 dec. reset ( )
251255 // After reset the buffered partial frame is gone; a fresh frame decodes.
252256 let frames = try dec. feed ( Framing . frame ( [ 0x33 ] ) )
0 commit comments