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 {
145145 public static let base64UrlAlphabet = DecodingOptions ( rawValue: UInt ( 1 << 0 ) )
146146 }
147147
148- public enum DecodingError : Error , Equatable {
149- case invalidLength
150- case invalidCharacter( UInt8 )
151- case unexpectedPaddingCharacter
152- case unexpectedEnd
153- }
154-
155148 @inlinable
156149 public static func decode< Buffer: Collection > ( encoded: Buffer , options: DecodingOptions = [ ] )
157150 throws -> [ UInt8 ] where Buffer. Element == UInt8 {
@@ -304,10 +297,10 @@ extension IteratorProtocol where Self.Element == UInt8 {
304297 }
305298
306299 if value == Base64 . paddingCharacter {
307- throw Base64 . DecodingError. unexpectedPaddingCharacter
300+ throw DecodingError . unexpectedPaddingCharacter
308301 }
309302
310- throw Base64 . DecodingError. invalidCharacter ( ascii)
303+ throw DecodingError . invalidCharacter ( ascii)
311304 }
312305
313306 @inlinable mutating func nextValueOrEmpty( alphabet: [ UInt8 ] ) throws -> UInt8 ? {
@@ -323,7 +316,7 @@ extension IteratorProtocol where Self.Element == UInt8 {
323316 return nil
324317 }
325318
326- throw Base64 . DecodingError. invalidCharacter ( ascii)
319+ throw DecodingError . invalidCharacter ( ascii)
327320 }
328321}
329322
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 {
3737
3838 func testBase64DecodingWithPoop( ) {
3939 XCTAssertThrowsError ( _ = try " 💩 " . base64decoded ( ) ) { error in
40- XCTAssertEqual ( error as? Base64 . DecodingError , . invalidCharacter( 240 ) )
40+ XCTAssertEqual ( error as? DecodingError , . invalidCharacter( 240 ) )
4141 }
4242 }
4343
4444 func testBase64DecodingWithInvalidLength( ) {
4545 XCTAssertThrowsError ( _ = try " AAAAA " . base64decoded ( ) ) { error in
46- XCTAssertEqual ( error as? Base64 . DecodingError , . invalidLength)
46+ XCTAssertEqual ( error as? DecodingError , . invalidLength)
4747 }
4848 }
4949
You can’t perform that action at this time.
0 commit comments