Skip to content

Instantly share code, notes, and snippets.

@fwielstra
Created September 25, 2015 11:56
Show Gist options
  • Save fwielstra/dd02aaac645ac7445653 to your computer and use it in GitHub Desktop.
Save fwielstra/dd02aaac645ac7445653 to your computer and use it in GitHub Desktop.
import ObjectMapper
struct Test: Mappable {
let name: String
init?(_ map: Map) {
name = map["name"].valueOrFail()
if !map.isValid {
return nil
}
}
func mapping(map: Map) {
}
}
import XCTest
import ObjectMapper
class TestTest: XCTestCase {
func testParseJson() {
// works
let validJsonString = "{ \"name\": \"test\" }"
Mapper<Test>().map(validJsonString)
// EXEC_BAD_ACCESS
let invalidJsonString = "{ \"NOT name\": \"test\" }"
Mapper<Test>().map(invalidJsonString)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment