-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f62d799
commit 5c38aba
Showing
9 changed files
with
117 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// ErrorContextTest.swift | ||
// XMLCoder | ||
// | ||
// Created by Matvii Hodovaniuk on 12/27/18. | ||
// | ||
|
||
import Foundation | ||
import XCTest | ||
@testable import XMLCoder | ||
|
||
final class ErrorContextTest: XCTestCase { | ||
struct Container: Codable { | ||
let value: [String: Int] | ||
} | ||
|
||
func testErrorContext() { | ||
let decoder = XMLDecoder() | ||
decoder.errorContextLength = 8 | ||
|
||
let xmlString = | ||
""" | ||
<container> | ||
test1 | ||
</blah> | ||
<container> | ||
test2 | ||
</container> | ||
""" | ||
let xmlData = xmlString.data(using: .utf8)! | ||
|
||
XCTAssertThrowsError(try decoder.decode(Container.self, | ||
from: xmlData)) { error in | ||
guard case let DecodingError.dataCorrupted(ctx) = error, | ||
let underlying = ctx.underlyingError else { | ||
XCTAssert(false, "wrong error type thrown") | ||
return | ||
} | ||
|
||
XCTAssertEqual(ctx.debugDescription, """ | ||
\(underlying.localizedDescription) \ | ||
at line 3, column 8: | ||
`blah> | ||
<c` | ||
""") | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testErrorContext", testErrorContext), | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters