@@ -35,30 +35,48 @@ struct `Brutal` {
3535 func `exhaustive byte class ification`(byte: UInt8 ) {
3636 // Every byte must be either ASCII or not - no exceptions
3737 let isASCII = byte <= 0x7F
38- #expect( isAllASCII ( [ Byte ( byte) ] ) == isASCII, " Byte 0x \( String ( byte, radix: 16 ) ) classification inconsistent " )
38+ #expect(
39+ isAllASCII ( [ Byte ( byte) ] ) == isASCII,
40+ " Byte 0x \( String ( byte, radix: 16 ) ) classification inconsistent "
41+ )
3942
4043 // Predicates must be consistent for all bytes
4144 if byte. ascii. isControl {
4245 // Control characters are never letters/digits
43- #expect( !byte. ascii. isLetter, " Control byte 0x \( String ( byte, radix: 16 ) ) cannot be letter " )
44- #expect( !byte. ascii. isDigit, " Control byte 0x \( String ( byte, radix: 16 ) ) cannot be digit " )
46+ #expect(
47+ !byte. ascii. isLetter,
48+ " Control byte 0x \( String ( byte, radix: 16 ) ) cannot be letter "
49+ )
50+ #expect(
51+ !byte. ascii. isDigit,
52+ " Control byte 0x \( String ( byte, radix: 16 ) ) cannot be digit "
53+ )
4554 }
4655
4756 // Visible implies printable
4857 if byte. ascii. isVisible {
49- #expect( byte. ascii. isPrintable, " Visible byte 0x \( String ( byte, radix: 16 ) ) must be printable " )
58+ #expect(
59+ byte. ascii. isPrintable,
60+ " Visible byte 0x \( String ( byte, radix: 16 ) ) must be printable "
61+ )
5062 }
5163 }
5264
5365 @Test ( arguments: Array ( UInt8 ( 0 ) ... UInt8 ( 255 ) ) )
5466 func `case conversion idempotence for every byte`(byte: UInt8 ) {
5567 let upper = byte. ascii ( case: . upper)
5668 let upperAgain = upper. ascii ( case: . upper)
57- #expect( upper == upperAgain, " Uppercase idempotence failed for 0x \( String ( byte, radix: 16 ) ) " )
69+ #expect(
70+ upper == upperAgain,
71+ " Uppercase idempotence failed for 0x \( String ( byte, radix: 16 ) ) "
72+ )
5873
5974 let lower = byte. ascii ( case: . lower)
6075 let lowerAgain = lower. ascii ( case: . lower)
61- #expect( lower == lowerAgain, " Lowercase idempotence failed for 0x \( String ( byte, radix: 16 ) ) " )
76+ #expect(
77+ lower == lowerAgain,
78+ " Lowercase idempotence failed for 0x \( String ( byte, radix: 16 ) ) "
79+ )
6280 }
6381
6482 @Test ( arguments: Array ( UInt8 ( 0 ) ... UInt8 ( 255 ) ) )
@@ -88,9 +106,15 @@ struct `Brutal` {
88106 if byte == UInt8 . ascii. sp. underlying {
89107 #expect( !isControl && isPrintable)
90108 } else if byte <= 0x1F || byte == 0x7F {
91- #expect( isControl && !isPrintable, " 0x \( String ( byte, radix: 16 ) ) should be control, not printable " )
109+ #expect(
110+ isControl && !isPrintable,
111+ " 0x \( String ( byte, radix: 16 ) ) should be control, not printable "
112+ )
92113 } else {
93- #expect( !isControl && isPrintable, " 0x \( String ( byte, radix: 16 ) ) should be printable, not control " )
114+ #expect(
115+ !isControl && isPrintable,
116+ " 0x \( String ( byte, radix: 16 ) ) should be printable, not control "
117+ )
94118 }
95119 }
96120
@@ -109,14 +133,20 @@ struct `Brutal` {
109133 @Test ( arguments: Array ( UInt8 ( 0 ) ... UInt8 ( 127 ) ) )
110134 func `letter implies alphanumeric`(byte: UInt8 ) {
111135 if byte. ascii. isLetter {
112- #expect( byte. ascii. isAlphanumeric, " Letter 0x \( String ( byte, radix: 16 ) ) must be alphanumeric " )
136+ #expect(
137+ byte. ascii. isAlphanumeric,
138+ " Letter 0x \( String ( byte, radix: 16 ) ) must be alphanumeric "
139+ )
113140 }
114141 }
115142
116143 @Test ( arguments: Array ( UInt8 ( 0 ) ... UInt8 ( 127 ) ) )
117144 func `digit implies alphanumeric`(byte: UInt8 ) {
118145 if byte. ascii. isDigit {
119- #expect( byte. ascii. isAlphanumeric, " Digit 0x \( String ( byte, radix: 16 ) ) must be alphanumeric " )
146+ #expect(
147+ byte. ascii. isAlphanumeric,
148+ " Digit 0x \( String ( byte, radix: 16 ) ) must be alphanumeric "
149+ )
120150 }
121151 }
122152
@@ -126,13 +156,22 @@ struct `Brutal` {
126156 let isLower = byte. ascii. isLowercase
127157
128158 // Cannot be both
129- #expect( !( isUpper && isLower) , " Byte 0x \( String ( byte, radix: 16 ) ) cannot be both upper and lower " )
159+ #expect(
160+ !( isUpper && isLower) ,
161+ " Byte 0x \( String ( byte, radix: 16 ) ) cannot be both upper and lower "
162+ )
130163
131164 // If letter, must be exactly one
132165 if byte. ascii. isLetter {
133- #expect( isUpper != isLower, " Letter 0x \( String ( byte, radix: 16 ) ) must be exactly one of upper or lower " )
166+ #expect(
167+ isUpper != isLower,
168+ " Letter 0x \( String ( byte, radix: 16 ) ) must be exactly one of upper or lower "
169+ )
134170 } else {
135- #expect( !isUpper && !isLower, " Non-letter 0x \( String ( byte, radix: 16 ) ) cannot be upper or lower " )
171+ #expect(
172+ !isUpper && !isLower,
173+ " Non-letter 0x \( String ( byte, radix: 16 ) ) cannot be upper or lower "
174+ )
136175 }
137176 }
138177 }
@@ -151,7 +190,10 @@ struct `Brutal` {
151190 ]
152191
153192 for seq in multiByteSequences {
154- #expect( !isAllASCII( seq) , " Multi-byte UTF-8 \( seq. map { String ( $0. underlying, radix: 16 ) } ) should fail " )
193+ #expect(
194+ !isAllASCII( seq) ,
195+ " Multi-byte UTF-8 \( seq. map { String ( $0. underlying, radix: 16 ) } ) should fail "
196+ )
155197 }
156198 }
157199
@@ -174,7 +216,10 @@ struct `Brutal` {
174216 func `look-alike characters not confused with ASCII`() {
175217 // Cyrillic 'а' looks like Latin 'a' but is U+0430 (multi-byte UTF-8)
176218 let cyrillicA = " а " // U+0430
177- #expect( UInt8 ( ascii: Character ( cyrillicA) ) == nil , " Cyrillic 'а' should not convert to ASCII " )
219+ #expect(
220+ UInt8 ( ascii: Character ( cyrillicA) ) == nil ,
221+ " Cyrillic 'а' should not convert to ASCII "
222+ )
178223
179224 // Greek 'Α' looks like Latin 'A' but is U+0391
180225 let greekA = " Α " // U+0391
@@ -184,14 +229,20 @@ struct `Brutal` {
184229 @Test
185230 func `zero-width characters rejected`() {
186231 let zeroWidth = " \u{200B} " // Zero-width space
187- #expect( UInt8 ( ascii: Character ( zeroWidth) ) == nil , " Zero-width space should be rejected " )
232+ #expect(
233+ UInt8 ( ascii: Character ( zeroWidth) ) == nil ,
234+ " Zero-width space should be rejected "
235+ )
188236 }
189237
190238 @Test
191239 func `combining characters rejected`() {
192240 // Combining diacritical marks
193241 let combining = " \u{0301} " // Combining acute accent
194- #expect( UInt8 ( ascii: Character ( combining) ) == nil , " Combining character should be rejected " )
242+ #expect(
243+ UInt8 ( ascii: Character ( combining) ) == nil ,
244+ " Combining character should be rejected "
245+ )
195246 }
196247
197248 @Test
@@ -210,15 +261,20 @@ struct `Brutal` {
210261
211262 @Suite
212263 struct `Brutal - Buffer Boundaries` {
213- @Test ( arguments: [ 0 , 1 , 2 , 3 , 4 , 7 , 8 , 15 , 16 , 31 , 32 , 63 , 64 , 127 , 128 , 255 , 256 , 511 , 512 , 1023 , 1024 ] )
264+ @Test ( arguments: [
265+ 0 , 1 , 2 , 3 , 4 , 7 , 8 , 15 , 16 , 31 , 32 , 63 , 64 , 127 , 128 , 255 , 256 , 511 , 512 , 1023 , 1024 ,
266+ ] )
214267 func `validation at power- of- 2 boundaries`(size: Int) {
215268 let validASCII : [ Byte ] = Array ( repeating: Byte . ascii. A, count: size)
216269 #expect( isAllASCII ( validASCII) , " Valid ASCII array of size \( size) should pass " )
217270
218271 var invalidASCII = validASCII
219272 if size > 0 {
220273 invalidASCII [ size - 1 ] = 0x80
221- #expect( !isAllASCII( invalidASCII) , " Invalid ASCII array of size \( size) should fail " )
274+ #expect(
275+ !isAllASCII( invalidASCII) ,
276+ " Invalid ASCII array of size \( size) should fail "
277+ )
222278 }
223279 }
224280
0 commit comments