@@ -29,14 +29,14 @@ class JSONSchemaTests: XCTestCase {
29
29
}
30
30
31
31
func testSuccessfulValidation( ) {
32
- XCTAssertTrue ( schema. validate ( [ String: Any] ( ) ) . valid)
32
+ try XCTAssertTrue ( schema. validate ( [ String: Any] ( ) ) . valid)
33
33
}
34
34
35
35
func testUnsuccessfulValidation( ) {
36
- XCTAssertFalse ( schema. validate ( [ String] ( ) ) . valid)
36
+ try XCTAssertFalse ( schema. validate ( [ String] ( ) ) . valid)
37
37
}
38
38
39
- func testReadme( ) {
39
+ func testReadme( ) throws {
40
40
let schema = Schema ( [
41
41
" type " : " object " ,
42
42
" properties " : [
@@ -46,11 +46,11 @@ class JSONSchemaTests: XCTestCase {
46
46
" required " : [ " name " ] ,
47
47
] )
48
48
49
- XCTAssertTrue ( schema. validate ( [ " name " : " Eggs " , " price " : 34.99 ] ) . valid)
50
- XCTAssertFalse ( schema. validate ( [ " price " : 34.99 ] ) . valid)
49
+ try XCTAssertTrue ( schema. validate ( [ " name " : " Eggs " , " price " : 34.99 ] ) . valid)
50
+ try XCTAssertFalse ( schema. validate ( [ " price " : 34.99 ] ) . valid)
51
51
}
52
52
53
- func testIterableInterface( ) {
53
+ func testIterableInterface( ) throws {
54
54
let schema = Schema ( [
55
55
" type " : " object " ,
56
56
" properties " : [
@@ -61,14 +61,14 @@ class JSONSchemaTests: XCTestCase {
61
61
] )
62
62
63
63
var counter = 0
64
- for error in schema. validate ( [ " price " : 34.99 ] ) {
64
+ for error in try schema. validate ( [ " price " : 34.99 ] ) {
65
65
XCTAssertEqual ( error. description, " Required property 'name' is missing " )
66
66
counter += 1
67
67
}
68
68
69
69
XCTAssertEqual ( counter, 1 )
70
70
71
- let result = Array ( schema. validate ( [ " price " : 34.99 ] ) )
71
+ let result = try Array ( schema. validate ( [ " price " : 34.99 ] ) )
72
72
73
73
XCTAssertEqual ( result. map ( \. description) , [
74
74
" Required property 'name' is missing "
@@ -89,8 +89,8 @@ class ValidateTests: XCTestCase {
89
89
" required " : [ " name " ] ,
90
90
]
91
91
92
- XCTAssertTrue ( validate ( [ " name " : " Eggs " , " price " : 34.99 ] , schema: schema) . valid)
93
- XCTAssertFalse ( validate ( [ " price " : 34.99 ] , schema: schema) . valid)
92
+ try XCTAssertTrue ( validate ( [ " name " : " Eggs " , " price " : 34.99 ] , schema: schema) . valid)
93
+ try XCTAssertFalse ( validate ( [ " price " : 34.99 ] , schema: schema) . valid)
94
94
}
95
95
96
96
func testValidateDraft6( ) {
@@ -104,16 +104,16 @@ class ValidateTests: XCTestCase {
104
104
" required " : [ " name " ] ,
105
105
]
106
106
107
- XCTAssertTrue ( validate ( [ " name " : " Eggs " , " price " : 34.99 ] , schema: schema) . valid)
108
- XCTAssertFalse ( validate ( [ " price " : 34.99 ] , schema: schema) . valid)
107
+ try XCTAssertTrue ( validate ( [ " name " : " Eggs " , " price " : 34.99 ] , schema: schema) . valid)
108
+ try XCTAssertFalse ( validate ( [ " price " : 34.99 ] , schema: schema) . valid)
109
109
}
110
110
111
111
func testDraft6ValidatorIsAvailable( ) {
112
112
let result = validator ( for: [ " $schema " : " http://json-schema.org/draft-06/schema# " ] )
113
113
XCTAssertTrue ( result is Draft6Validator , " Unexpected type of validator \( result) " )
114
114
}
115
115
116
- func testValidateDraft7( ) {
116
+ func testValidateDraft7( ) throws {
117
117
let schema : [ String : Any ] = [
118
118
" $schema " : " http://json-schema.org/draft-07/schema# " ,
119
119
" type " : " object " ,
@@ -124,17 +124,17 @@ class ValidateTests: XCTestCase {
124
124
" required " : [ " name " ] ,
125
125
]
126
126
127
- XCTAssertTrue ( validate ( [ " name " : " Eggs " , " price " : 34.99 ] , schema: schema) . valid)
128
- XCTAssertFalse ( validate ( [ " price " : 34.99 ] , schema: schema) . valid)
127
+ try XCTAssertTrue ( validate ( [ " name " : " Eggs " , " price " : 34.99 ] , schema: schema) . valid)
128
+ try XCTAssertFalse ( validate ( [ " price " : 34.99 ] , schema: schema) . valid)
129
129
}
130
130
131
- func testValidatesRequired( ) {
131
+ func testValidatesRequired( ) throws {
132
132
let schema : [ String : Any ] = [
133
133
" $schema " : " http://json-schema.org/draft-07/schema# " ,
134
134
" required " : [ " one " , " two " , " three " ] ,
135
135
]
136
136
137
- let result = validate ( [ " one " : true , " three " : true ] , schema: schema)
137
+ let result = try validate ( [ " one " : true , " three " : true ] , schema: schema)
138
138
139
139
switch result {
140
140
case . valid:
@@ -146,15 +146,15 @@ class ValidateTests: XCTestCase {
146
146
}
147
147
}
148
148
149
- func testRequiredValidationLocation( ) {
149
+ func testRequiredValidationLocation( ) throws {
150
150
let schema : [ String : Any ] = [
151
151
" $schema " : " http://json-schema.org/draft-07/schema# " ,
152
152
" items " : [
153
153
" required " : [ " test " ] ,
154
154
]
155
155
]
156
156
157
- let result = validate ( [ [ : ] ] , schema: schema)
157
+ let result = try validate ( [ [ : ] ] , schema: schema)
158
158
159
159
switch result {
160
160
case . valid:
0 commit comments