Skip to content

Commit

Permalink
add codable test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu0118 committed Nov 12, 2023
1 parent 460bab8 commit 6869baf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Tests/TypedDateTests/TypedDateCodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,19 @@ struct TypedDateCodableTests {
let decoded8 = try JSONDecoder().decode(TypedDate<(Year)>.self, from: data)
testSupport.assertTypedDate(for: decoded8)
}

@Test
func testAnotherModelCodable() throws {
struct Model: Codable, Equatable {
let id: Int
let name: String
let date: TypedDate<(Year, Month, Day)>
}
let typedDate = TypedDate(Year(2023), Month(11), Day(10))
let model = Model(id: 1, name: "John", date: typedDate)

let data = try JSONEncoder().encode(model)
let decodedModel = try JSONDecoder().decode(Model.self, from: data)
#expect(model == decodedModel)
}
}

0 comments on commit 6869baf

Please sign in to comment.