Created
November 15, 2019 07:20
-
-
Save devxoul/4acf48ce8f64011a9941728c09ba256a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: define type 'User' | |
func testCase1() { | |
let json: [String: Any] = [ | |
"id": 1, | |
"usermname": "devxoul", | |
"email": "devxoul@gmail.com", | |
] | |
let user = User(json: json) | |
assert(user.id == 1) | |
assert(user.username == "devxoul") | |
assert(user.email == "devxoul@gmail.com") | |
} | |
func testCase2() { | |
let json: [String: Any] = [ | |
"id": 2, | |
"usermname": "carpe", | |
] | |
let user = User(json: json) | |
assert(user.id == 2) | |
assert(user.username == "carpe") | |
assert(user.email == nil) | |
} | |
testCase1() | |
testCase2() | |
print("SUCCESS!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@innocarpe