[Shared] Fixes pattern matching non-ALTErrorEnum error codes

This commit is contained in:
Riley Testut
2022-12-20 14:01:54 -06:00
committed by Magesh K
parent d54b7aa3bf
commit 624c4086f1
2 changed files with 32 additions and 1 deletions

View File

@@ -427,6 +427,37 @@ extension AltTests
}
}
func testPatternMatchingErrorCode() async throws
{
do
{
// ALTLocalizedError
throw OperationError.serverNotFound
}
catch ~OperationError.Code.serverNotFound
{
// Success
}
catch
{
XCTFail("Failed to catch error as OperationError.Code.serverNotFound: \(error)")
}
do
{
// ALTErrorEnum
throw AuthenticationError(.noTeam)
}
catch ~AuthenticationErrorCode.noTeam
{
// Success
}
catch
{
XCTFail("Failed to catch error as AuthenticationErrorCode.noTeam: \(error)")
}
}
func testWithLocalizedTitle() async throws
{
let localizedTitle = "AltTest Failed"