-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from edwardaux/argo_3_0_and_bool_support
Argo 3 0 and bool support
- Loading branch information
Showing
8 changed files
with
83 additions
and
70 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
github "thoughtbot/Argo" ~> 2.2 | ||
github "thoughtbot/Argo" ~> 3.0 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
github "thoughtbot/Argo" "v2.2.0" | ||
github "thoughtbot/Argo" "v3.0.0" |
Submodule Argo
updated
44 files
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
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 |
---|---|---|
|
@@ -14,43 +14,43 @@ class OgraTests: XCTestCase { | |
private func toJSON(jsonString: String) -> JSON { | ||
let jsonData = jsonString.dataUsingEncoding(NSUTF8StringEncoding)! | ||
let jsonObject: AnyObject = try! NSJSONSerialization.JSONObjectWithData(jsonData, options:NSJSONReadingOptions()) | ||
return JSON.parse(jsonObject) | ||
return JSON(jsonObject) | ||
} | ||
|
||
func testNullPet() { | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":null, \"nicknames\":[\"Johnny\"], \"accounts\":{\"gmail\":\"john\"} }") | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":null, \"nicknames\":[\"Johnny\"], \"accounts\":{\"gmail\":\"john\"}, \"happy\":true }") | ||
let user = User.decode(jsonIn).value! | ||
let jsonOut = user.encode() | ||
|
||
XCTAssertEqual(jsonIn, jsonOut) | ||
} | ||
|
||
func testNullNicknames() { | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":null, \"nicknames\":null, \"accounts\":{\"gmail\":\"john\"} }") | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":null, \"nicknames\":null, \"accounts\":{\"gmail\":\"john\"}, \"happy\":true }") | ||
let user = User.decode(jsonIn).value! | ||
let jsonOut = user.encode() | ||
|
||
XCTAssertEqual(jsonIn, jsonOut) | ||
} | ||
|
||
func testNullAccounts() { | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":null, \"nicknames\":[\"Johnny\"], \"accounts\":null }") | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":null, \"nicknames\":[\"Johnny\"], \"accounts\":null, \"happy\":true }") | ||
let user = User.decode(jsonIn).value! | ||
let jsonOut = user.encode() | ||
|
||
XCTAssertEqual(jsonIn, jsonOut) | ||
} | ||
|
||
func testWithPet() { | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":{\"name\":\"Rex\"}, \"nicknames\":[\"Johnny\"], \"accounts\":{\"gmail\":\"john\"} }") | ||
let jsonIn = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":{\"name\":\"Rex\"}, \"nicknames\":[\"Johnny\"], \"accounts\":{\"gmail\":\"john\"}, \"happy\":true }") | ||
let user = User.decode(jsonIn).value! | ||
let jsonOut = user.encode() | ||
|
||
XCTAssertEqual(jsonIn, jsonOut) | ||
} | ||
|
||
func testPassingToJSONSerialization() { | ||
let json = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":{\"name\":\"Rex\"}, \"nicknames\":[\"Johnny\"], \"accounts\":{\"gmail\":\"john\"} }") | ||
let json = toJSON("{ \"id\":123, \"name\":\"John\", \"email\":\"[email protected]\", \"pet\":{\"name\":\"Rex\"}, \"nicknames\":[\"Johnny\"], \"accounts\":{\"gmail\":\"john\"}, \"happy\":true }") | ||
let user = User.decode(json).value! | ||
|
||
let jsonObject = user.encode().JSONObject() | ||
|
@@ -62,59 +62,59 @@ class OgraTests: XCTestCase { | |
print(string) | ||
} | ||
|
||
func testRawRepresentableStringType() { | ||
let continent: Continent = .NorthAmerica | ||
let json: JSON = .String(continent.rawValue) | ||
let encoded = continent.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
|
||
func testRawRepresentableIntType() { | ||
let dialingCode: IntDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
|
||
func testRawRepresentableDoubleType() { | ||
let dialingCode: DoubleDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
|
||
func testRawRepresentableFloatType() { | ||
let dialingCode: FloatDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
|
||
func testRawRepresentableUIntType() { | ||
let dialingCode: UIntDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
|
||
func testConversionToAnyObject() { | ||
XCTAssertEqual(JSON.Null.JSONObject() as? NSNull, NSNull()) | ||
XCTAssertEqual(JSON.String("42").JSONObject() as? String, "42") | ||
XCTAssertEqual(JSON.Number(NSNumber(integer: 42)).JSONObject() as? Int, 42) | ||
XCTAssertEqual(JSON.Array([JSON.String("42")]).JSONObject() as! [String], ["42"]) | ||
XCTAssertEqual(JSON.Object(["life" : JSON.String("42")]).JSONObject() as! [String : String], ["life" : "42"]) | ||
} | ||
|
||
func testTypesEncodeProperly() { | ||
XCTAssertEqual(JSON.Null.encode(), JSON.Null) | ||
XCTAssertEqual("42".encode(), JSON.String("42")) | ||
XCTAssertEqual(true.encode(), JSON.Number(NSNumber(bool: true))) | ||
XCTAssertEqual(false.encode(), JSON.Number(NSNumber(bool: false))) | ||
XCTAssertEqual(Int(42).encode(), JSON.Number(NSNumber(integer: 42))) | ||
XCTAssertEqual(Double(42.42).encode(), JSON.Number(NSNumber(double: 42.42))) | ||
XCTAssertEqual(Float(42.42).encode(), JSON.Number(NSNumber(float: 42.42))) | ||
XCTAssertEqual(UInt(42).encode(), JSON.Number(NSNumber(unsignedLong: 42))) | ||
XCTAssertEqual(("42" as String?).encode(), JSON.String("42")) | ||
XCTAssertEqual((nil as String?).encode(), JSON.Null) | ||
} | ||
func testRawRepresentableStringType() { | ||
let continent: Continent = .NorthAmerica | ||
let json: JSON = .String(continent.rawValue) | ||
let encoded = continent.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
func testRawRepresentableIntType() { | ||
let dialingCode: IntDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
func testRawRepresentableDoubleType() { | ||
let dialingCode: DoubleDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
func testRawRepresentableFloatType() { | ||
let dialingCode: FloatDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
func testRawRepresentableUIntType() { | ||
let dialingCode: UIntDialingCode = .UnitedStates | ||
let json: JSON = .Number(dialingCode.rawValue) | ||
let encoded = dialingCode.encode() | ||
XCTAssertEqual(json, encoded) | ||
} | ||
func testConversionToAnyObject() { | ||
XCTAssertEqual(JSON.Null.JSONObject() as? NSNull, NSNull()) | ||
XCTAssertEqual(JSON.String("42").JSONObject() as? String, "42") | ||
XCTAssertEqual(JSON.Number(NSNumber(integer: 42)).JSONObject() as? Int, 42) | ||
XCTAssertEqual(JSON.Array([JSON.String("42")]).JSONObject() as! [String], ["42"]) | ||
XCTAssertEqual(JSON.Object(["life" : JSON.String("42")]).JSONObject() as! [String : String], ["life" : "42"]) | ||
} | ||
func testTypesEncodeProperly() { | ||
XCTAssertEqual(JSON.Null.encode(), JSON.Null) | ||
XCTAssertEqual("42".encode(), JSON.String("42")) | ||
XCTAssertEqual(true.encode(), JSON.Bool(true)) | ||
XCTAssertEqual(false.encode(), JSON.Bool(false)) | ||
XCTAssertEqual(Int(42).encode(), JSON.Number(NSNumber(integer: 42))) | ||
XCTAssertEqual(Double(42.42).encode(), JSON.Number(NSNumber(double: 42.42))) | ||
XCTAssertEqual(Float(42.42).encode(), JSON.Number(NSNumber(float: 42.42))) | ||
XCTAssertEqual(UInt(42).encode(), JSON.Number(NSNumber(unsignedLong: 42))) | ||
XCTAssertEqual(("42" as String?).encode(), JSON.String("42")) | ||
XCTAssertEqual((nil as String?).encode(), JSON.Null) | ||
} | ||
} |
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