Skip to content

Commit

Permalink
Update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
WendellXY committed Aug 16, 2024
1 parent de768ed commit 173119e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions Tests/CodableKitTests/CodableMacroTests+Diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ final class CodableKitDiagnosticsTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decode(Int.self, forKey: .age)
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -123,14 +123,14 @@ final class CodableKitDiagnosticsTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decode(Int.self, forKey: .age)
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down
48 changes: 24 additions & 24 deletions Tests/CodableKitTests/CodableMacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ final class CodableKitTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decode(Int.self, forKey: .age)
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -85,14 +85,14 @@ final class CodableKitTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decodeIfPresent(Int.self, forKey: .age) ?? 24
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -134,14 +134,14 @@ final class CodableKitTests: XCTestCase {
case age = "currentAge"
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decodeIfPresent(Int.self, forKey: .age) ?? 24
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -182,14 +182,14 @@ final class CodableKitTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decodeIfPresent(Int?.self, forKey: .age) ?? 24
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -233,14 +233,14 @@ final class CodableKitTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decodeIfPresent(Int?.self, forKey: .age) ?? 24
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -285,15 +285,15 @@ final class CodableKitTests: XCTestCase {
case explicitNil
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decodeIfPresent(Int?.self, forKey: .age) ?? 24
explicitNil = try container.decodeIfPresent(String?.self, forKey: .explicitNil) ?? nil
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -340,14 +340,14 @@ final class CodableKitTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decode(Int.self, forKey: .age)
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -398,14 +398,14 @@ final class CodableKitTests: XCTestCase {
case age
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decode(Int.self, forKey: .age)
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -458,7 +458,7 @@ final class CodableKitTests: XCTestCase {
case room
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
Expand All @@ -477,7 +477,7 @@ final class CodableKitTests: XCTestCase {
}
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -542,7 +542,7 @@ final class CodableKitTests: XCTestCase {
case room
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
Expand All @@ -561,7 +561,7 @@ final class CodableKitTests: XCTestCase {
}
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -626,7 +626,7 @@ final class CodableKitTests: XCTestCase {
case room
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
Expand All @@ -645,7 +645,7 @@ final class CodableKitTests: XCTestCase {
}
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down Expand Up @@ -712,15 +712,15 @@ final class CodableKitTests: XCTestCase {
case role
}
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decode(UUID.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
age = try container.decode(Int.self, forKey: .age)
role = (try? container.decodeIfPresent(Role.self, forKey: .role)) ?? .unknown
}
public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
Expand Down

0 comments on commit 173119e

Please sign in to comment.