File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -145,13 +145,6 @@ extension Base64 {
145
145
public static let base64UrlAlphabet = DecodingOptions ( rawValue: UInt ( 1 << 0 ) )
146
146
}
147
147
148
- public enum DecodingError : Error , Equatable {
149
- case invalidLength
150
- case invalidCharacter( UInt8 )
151
- case unexpectedPaddingCharacter
152
- case unexpectedEnd
153
- }
154
-
155
148
@inlinable
156
149
public static func decode< Buffer: Collection > ( encoded: Buffer , options: DecodingOptions = [ ] )
157
150
throws -> [ UInt8 ] where Buffer. Element == UInt8 {
@@ -304,10 +297,10 @@ extension IteratorProtocol where Self.Element == UInt8 {
304
297
}
305
298
306
299
if value == Base64 . paddingCharacter {
307
- throw Base64 . DecodingError. unexpectedPaddingCharacter
300
+ throw DecodingError . unexpectedPaddingCharacter
308
301
}
309
302
310
- throw Base64 . DecodingError. invalidCharacter ( ascii)
303
+ throw DecodingError . invalidCharacter ( ascii)
311
304
}
312
305
313
306
@inlinable mutating func nextValueOrEmpty( alphabet: [ UInt8 ] ) throws -> UInt8 ? {
@@ -323,7 +316,7 @@ extension IteratorProtocol where Self.Element == UInt8 {
323
316
return nil
324
317
}
325
318
326
- throw Base64 . DecodingError. invalidCharacter ( ascii)
319
+ throw DecodingError . invalidCharacter ( ascii)
327
320
}
328
321
}
329
322
Original file line number Diff line number Diff line change
1
+
2
+ public enum DecodingError : Error , Equatable {
3
+ case invalidLength
4
+ case invalidCharacter( UInt8 )
5
+ case unexpectedPaddingCharacter
6
+ case unexpectedEnd
7
+ }
Original file line number Diff line number Diff line change @@ -37,13 +37,13 @@ class DecodingTests: XCTestCase {
37
37
38
38
func testBase64DecodingWithPoop( ) {
39
39
XCTAssertThrowsError ( _ = try " 💩 " . base64decoded ( ) ) { error in
40
- XCTAssertEqual ( error as? Base64 . DecodingError , . invalidCharacter( 240 ) )
40
+ XCTAssertEqual ( error as? DecodingError , . invalidCharacter( 240 ) )
41
41
}
42
42
}
43
43
44
44
func testBase64DecodingWithInvalidLength( ) {
45
45
XCTAssertThrowsError ( _ = try " AAAAA " . base64decoded ( ) ) { error in
46
- XCTAssertEqual ( error as? Base64 . DecodingError , . invalidLength)
46
+ XCTAssertEqual ( error as? DecodingError , . invalidLength)
47
47
}
48
48
}
49
49
You can’t perform that action at this time.
0 commit comments