@@ -23,7 +23,8 @@ func debugPrint(_ input: (base: UInt64, isBigEndian: Bool), expected: String)
23
23
async throws
24
24
{
25
25
let collection = EmbeddedIntegerCollection (
26
- embedding: UInt16 . self, within: input. base,
26
+ embedding: UInt16 . self,
27
+ within: input. base,
27
28
iteratingFrom: input. isBigEndian
28
29
? . mostSignificantFirst
29
30
: . leastSignificantFirst
@@ -36,19 +37,27 @@ func debugPrint(_ input: (base: UInt64, isBigEndian: Bool), expected: String)
36
37
@Test ( " Repeating-element initializer " )
37
38
func repeatingInitializer( ) async throws {
38
39
let collection1 = EmbeddedIntegerCollection . init (
39
- repeating: 0 as UInt16 , embeddedIn: UInt64 . self,
40
- iteratingFrom: . mostSignificantFirst)
40
+ repeating: 0 as UInt16 ,
41
+ embeddedIn: UInt64 . self,
42
+ iteratingFrom: . mostSignificantFirst
43
+ )
41
44
let collection2 = EmbeddedIntegerCollection (
42
- embedding: UInt16 . self, within: 0 as UInt64 ,
43
- iteratingFrom: . mostSignificantFirst)
45
+ embedding: UInt16 . self,
46
+ within: 0 as UInt64 ,
47
+ iteratingFrom: . mostSignificantFirst
48
+ )
44
49
#expect( collection1 == collection2)
45
50
46
51
let collection3 = EmbeddedIntegerCollection (
47
- embedding: UInt8 . self, within: 0x6F6F_6F6F as UInt32 ,
48
- iteratingFrom: . leastSignificantFirst)
52
+ embedding: UInt8 . self,
53
+ within: 0x6F6F_6F6F as UInt32 ,
54
+ iteratingFrom: . leastSignificantFirst
55
+ )
49
56
let collection4 = EmbeddedIntegerCollection (
50
- repeating: 0x6F as UInt8 , embeddedIn: UInt32 . self,
51
- iteratingFrom: . leastSignificantFirst)
57
+ repeating: 0x6F as UInt8 ,
58
+ embeddedIn: UInt32 . self,
59
+ iteratingFrom: . leastSignificantFirst
60
+ )
52
61
#expect( collection3 == collection4)
53
62
}
54
63
@@ -66,11 +75,13 @@ func repeatingInitializer() async throws {
66
75
)
67
76
)
68
77
func basicCollections(
69
- _ input: ( base: UInt32 , isBigEndian: Bool ) , expected: [ UInt8 ]
78
+ _ input: ( base: UInt32 , isBigEndian: Bool ) ,
79
+ expected: [ UInt8 ]
70
80
) async throws {
71
81
// Sequence (and indirectly Collection)
72
82
var collection = EmbeddedIntegerCollection (
73
- embedding: UInt8 . self, within: input. base,
83
+ embedding: UInt8 . self,
84
+ within: input. base,
74
85
iteratingFrom: input. isBigEndian
75
86
? . mostSignificantFirst
76
87
: . leastSignificantFirst
@@ -143,7 +154,9 @@ func basicCollections(
143
154
func moreIndexChecks( _ startingBitRange: EmbeddedIteratorDirection ) async throws
144
155
{
145
156
let collection = EmbeddedIntegerCollection (
146
- embedding: UInt8 . self, within: 0 as UInt64 , iteratingFrom: startingBitRange
157
+ embedding: UInt8 . self,
158
+ within: 0 as UInt64 ,
159
+ iteratingFrom: startingBitRange
147
160
)
148
161
let collectionIndices = collection. indices
149
162
@@ -177,7 +190,9 @@ func moreIndexChecks(_ startingBitRange: EmbeddedIteratorDirection) async throws
177
190
// Over-sized distances
178
191
#expect(
179
192
collection. index (
180
- goodIndex, offsetBy: . max, limitedBy: collection. endIndex
193
+ goodIndex,
194
+ offsetBy: . max,
195
+ limitedBy: collection. endIndex
181
196
) == nil
182
197
)
183
198
@@ -317,7 +332,8 @@ func normalPrint(_ input: (base: UInt32, isBigEndian: Bool), expected: String)
317
332
func mutateContiguousStorage( ) async throws {
318
333
// No usage with elements aren't raw octets.
319
334
var nonOctets = EmbeddedIntegerCollection (
320
- embedding: UInt16 . self, within: 0x1234_5678_9ABC_DEF0 as UInt64 ,
335
+ embedding: UInt16 . self,
336
+ within: 0x1234_5678_9ABC_DEF0 as UInt64 ,
321
337
iteratingFrom: . mostSignificantFirst
322
338
)
323
339
let nonOctetCount = nonOctets. withContiguousMutableStorageIfAvailable (
@@ -327,7 +343,8 @@ func mutateContiguousStorage() async throws {
327
343
328
344
// Octet elements
329
345
var bigOctets = EmbeddedIntegerCollection (
330
- embedding: UInt8 . self, within: 0x0123_4567 as UInt32 ,
346
+ embedding: UInt8 . self,
347
+ within: 0x0123_4567 as UInt32 ,
331
348
iteratingFrom: . mostSignificantFirst
332
349
)
333
350
#expect( bigOctets. word == 0x0123_4567 )
@@ -341,7 +358,8 @@ func mutateContiguousStorage() async throws {
341
358
#expect( bigOctets. elementsEqual ( [ 0xFE , 0xDC , 0xBA , 0x98 ] ) )
342
359
343
360
var littleOctets = EmbeddedIntegerCollection (
344
- embedding: UInt8 . self, within: 0x0123_4567 as UInt32 ,
361
+ embedding: UInt8 . self,
362
+ within: 0x0123_4567 as UInt32 ,
345
363
iteratingFrom: . leastSignificantFirst
346
364
)
347
365
#expect( littleOctets. word == 0x0123_4567 )
@@ -366,7 +384,8 @@ where T.Element: BinaryInteger {
366
384
367
385
@Test (
368
386
" Inspect contiguous storage " ,
369
- arguments: [ 0 , 0x0123_4567 , 0x89AB_CDEF ] , [ false , true ]
387
+ arguments: [ 0 , 0x0123_4567 , 0x89AB_CDEF ] ,
388
+ [ false , true ]
370
389
)
371
390
func inspectContiguousStorage( wrapped: UInt32 , isBigEndian: Bool ) async throws {
372
391
let collection = EmbeddedIntegerCollection (
0 commit comments