-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for decoding Argo JSON to swift objects
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// ArgoExtensionsTests.swift | ||
// Tentacle | ||
// | ||
// Created by Romain Pouclet on 2017-01-25. | ||
// Copyright © 2017 Matt Diephouse. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import Argo | ||
@testable import Tentacle | ||
|
||
class ArgoExtensionsTests: XCTestCase { | ||
|
||
func testNullDecoding() { | ||
let null: JSON = .null | ||
XCTAssertTrue(null.JSONObject() is NSNull) | ||
} | ||
|
||
func testStringDecoding() { | ||
let name: JSON = .string("Romain") | ||
XCTAssertEqual(name.JSONObject() as! String, "Romain") | ||
} | ||
|
||
func testNumberDecoding() { | ||
let answer: JSON = .number(42) | ||
XCTAssertEqual(answer.JSONObject() as! NSNumber, 42) | ||
} | ||
|
||
func testDecodingArray() { | ||
let array: JSON = .array([.string("Romain")]) | ||
XCTAssertEqual(array.JSONObject() as! [String], ["Romain"]) | ||
} | ||
|
||
func testDecodingBool() { | ||
let yes: JSON = .bool(true) | ||
XCTAssertTrue(yes.JSONObject() as! Bool) | ||
} | ||
|
||
func testDecodingObject() { | ||
let object: JSON = .object(["fullname": .string("Romain Pouclet"), "email": .string("[email protected]")]) | ||
XCTAssertEqual(object.JSONObject() as! [String: String], ["fullname": "Romain Pouclet", "email": "[email protected]"]) | ||
} | ||
} |
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