forked from iAmMccc/SmartCodable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultilineStringTest.swift
More file actions
54 lines (47 loc) · 1.4 KB
/
MultilineStringTest.swift
File metadata and controls
54 lines (47 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// MultilineStringTest.swift
// SmartCodable
//
// Created by Zero.D.Saber on 2025/10/11.
// Copyright © 2025 CocoaPods. All rights reserved.
//
import SmartCodable
import Testing
private struct User: SmartCodable {
var name: String = ""
var age: Int = 0
}
struct MultilineStringTest {
@Test(.bug("https://github.com/iAmMccc/SmartCodable/issues/116"))
func decodeMultilingDictStr() {
let jsonString1 = """
{
"name": "Sam",
"age": 22
}
"""
let user1 = User.deserialize(from: jsonString1)
#expect(user1?.name == "Sam")
#expect(user1?.age == 22)
let jsonString2 = """
"name": "Zero",
"age": 100
"""
let user2 = User.deserialize(from: jsonString2)
#expect(user2 == nil)
}
@Test("array case")
func decodeMultilingArrayStr() {
let jsonString = """
[
{
"name": "Zero",
"age": "99"
}
]
"""
let users = [User].deserialize(from: jsonString)
#expect(users?.first?.name == "Zero")
#expect(users?.first?.age == 99)
}
}