Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
gereons committed Jun 19, 2024
1 parent c6d808f commit 140428b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Tests/EnumTest2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,56 @@ final class EnumTest2: XCTestCase {
"""

private let expected = """
public struct Enum: Codable {
public let aEnum: AEnum?
public let bEnum: BEnum?
public init(aEnum: AEnum?, bEnum: BEnum?) {
self.aEnum = aEnum
self.bEnum = bEnum
}
enum CodingKeys: String, CodingKey {
case aEnum = "aEnum"
case bEnum = "bEnum"
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.aEnum = try container.decodeIfPresent(AEnum.self, forKey: .aEnum)
self.bEnum = try container.decodeIfPresent(BEnum.self, forKey: .bEnum)
}
public enum AEnum: String, Codable, CaseIterable, UnknownCaseRepresentable {
case plugh = "plugh"
case xyzzy = "xyzzy"
case _unknownCase
public static let unknownCase = Self._unknownCase
public static func make() -> Self {
.plugh
}
}
public enum BEnum: String, Codable, CaseIterable, UnknownCaseRepresentable {
case bar = "bar"
case baz = "baz"
case foo = "foo"
case _unknownCase
public static let unknownCase = Self._unknownCase
public static func make() -> Self {
.bar
}
}
public static func make(aEnum: AEnum? = nil, bEnum: BEnum? = nil) -> Self {
self.init(aEnum: aEnum, bEnum: bEnum)
}
}
"""

func testEnumOrder() throws {
Expand Down

0 comments on commit 140428b

Please sign in to comment.