Skip to content

Commit

Permalink
新增测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
Mccc committed Nov 25, 2024
1 parent 27b655e commit fc12002
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,23 @@ class CaseFiveViewController : BaseViewController {
// 此时的data是一个字符串,不是字典类型。
guard let model = ApiConmon<StringModel>.deserialize(from: json) else { return }
print(model)
guard let model1 = ApiConmon<String>.deserialize(from: json) else { return }
print(model1)


let jsonNull = """
{
"data": null,
"message": "200"
}
"""
guard let model2 = ApiConmon<String>.deserialize(from: jsonNull) else { return }
print(model2)

// 此时的data是一个字符串,不是字典类型。
guard let model3 = ApiConmon<StringModel>.deserialize(from: json) else { return }
print(model3)


let json1 = """
{
Expand All @@ -42,8 +57,8 @@ class CaseFiveViewController : BaseViewController {
"message": "200"
}
"""
guard let model1 = ApiConmon<DataModel>.deserialize(from: json1) else { return }
print(model1)
guard let model4 = ApiConmon<DataModel>.deserialize(from: json1) else { return }
print(model4)


let json2 = """
Expand All @@ -61,8 +76,8 @@ class CaseFiveViewController : BaseViewController {
"message": "200"
}
"""
guard let model2 = ApiConmon<[DataModel]>.deserialize(from: json2) else { return }
print(model2)
guard let model5 = ApiConmon<[DataModel]>.deserialize(from: json2) else { return }
print(model5)

}
}
Expand All @@ -79,7 +94,7 @@ struct DataModel: SmartCodable {
var age: Int = 0
}

struct ApiConmon<Element: SmartCodable>: SmartCodable {
struct ApiConmon<Element: Codable>: SmartCodable {
init() { }

var data: Element?
Expand Down

0 comments on commit fc12002

Please sign in to comment.