Skip to content

Instantly share code, notes, and snippets.

@devxoul
Created November 15, 2019 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devxoul/4acf48ce8f64011a9941728c09ba256a to your computer and use it in GitHub Desktop.
Save devxoul/4acf48ce8f64011a9941728c09ba256a to your computer and use it in GitHub Desktop.
// 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!")
@devxoul
Copy link
Author

devxoul commented Nov 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment