|
7 | 7 |
|
8 | 8 | import CodableWrappers |
9 | 9 | import Foundation |
10 | | -import Quick |
11 | | -import Nimble |
| 10 | +//import Quick |
| 11 | +//import Nimble |
12 | 12 |
|
13 | | -class CompositionTests: QuickSpec, DecodingTestSpec, EncodingTestSpec { |
14 | | - override class func spec() { |
15 | | - describe("StaticCoder") { |
16 | | - context("OnlyCustomDecoding") { |
17 | | - it("EncodesWithDefault") { |
18 | | - let currentDate = Date() |
19 | | - let encodingModel = DecodingModel(time: currentDate) |
20 | | - let encoded = try! self.jsonEncoder.encode(encodingModel) |
21 | | - expect {_ = try self.jsonDecoder.decode(DecodingModel.self, from: encoded)}.toNot(throwError()) |
22 | | - let decoded = try? self.jsonDecoder.decode(DecodingModel.self, from: encoded) |
23 | | - expect(decoded).toNot(beNil()) |
24 | | - // This means it was decoded using the SecondsSince1970DateDecoding, but encoded using the default |
25 | | - expect(decoded?.time.timeIntervalSince1970) == currentDate.timeIntervalSinceReferenceDate |
26 | | - } |
27 | | - } |
28 | | - context("OnlyCustomEncoding") { |
29 | | - it("DecodesWithDefault") { |
30 | | - let currentDate = Date() |
31 | | - let encodingModel = EncodingModel(time: currentDate) |
32 | | - let encoded = try! self.jsonEncoder.encode(encodingModel) |
33 | | - expect {_ = try self.jsonDecoder.decode(EncodingModel.self, from: encoded)}.toNot(throwError()) |
34 | | - let decoded = try? self.jsonDecoder.decode(EncodingModel.self, from: encoded) |
35 | | - expect(decoded).toNot(beNil()) |
36 | | - // This means it was decoded using the SecondsSince1970DateDecoding, but encoded using the default |
37 | | - expect(decoded?.time.timeIntervalSinceReferenceDate) == currentDate.timeIntervalSince1970 |
38 | | - } |
39 | | - } |
| 13 | +import Testing |
| 14 | + |
| 15 | +struct CompositionTest { |
| 16 | + struct StaticCoder: CodingTests { |
| 17 | + @Test func customDecodingEncodesWithDefaults() async throws { |
| 18 | + let currentDate = Date() |
| 19 | + let encodingModel = DecodingModel(time: currentDate) |
| 20 | + let encoded = try Self.jsonEncoder.encode(encodingModel) |
| 21 | + let decoded = try Self.jsonDecoder.decode(DecodingModel.self, from: encoded) |
| 22 | + #expect(decoded.time.timeIntervalSince1970 == currentDate.timeIntervalSinceReferenceDate) |
| 23 | + } |
| 24 | + |
| 25 | + @Test func customEncodingDecodesWithDefaults() async throws { |
| 26 | + let currentDate = Date() |
| 27 | + let encodingModel = EncodingModel(time: currentDate) |
| 28 | + let encoded = try Self.jsonEncoder.encode(encodingModel) |
| 29 | + let decoded = try Self.jsonDecoder.decode(EncodingModel.self, from: encoded) |
| 30 | + #expect(decoded.time.timeIntervalSinceReferenceDate == currentDate.timeIntervalSince1970) |
40 | 31 | } |
41 | 32 | } |
42 | 33 | } |
|
0 commit comments