Skip to content

Commit e2bb0f6

Browse files
committed
[BasicTypesTests] Reuse mapper instance
1 parent e5facf4 commit e2bb0f6

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

ObjectMapperTests/BasicTypesTests.swift

+17-15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import ObjectMapper
1212

1313
class BasicTypesTests: XCTestCase {
1414

15+
let mapper = Mapper<BasicTypes>()
16+
1517
override func setUp() {
1618
super.setUp()
1719
// Put setup code here. This method is called before the invocation of each test method in the class.
@@ -32,7 +34,7 @@ class BasicTypesTests: XCTestCase {
3234
object.boolOptional = value
3335

3436
let JSON = Mapper().toJSONString(object, prettyPrint: true)
35-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
37+
var mappedObject = mapper.map(string: JSON)
3638

3739
if let mappedObject = mappedObject {
3840

@@ -50,7 +52,7 @@ class BasicTypesTests: XCTestCase {
5052
object.intOptional = value
5153

5254
let JSON = Mapper().toJSONString(object, prettyPrint: true)
53-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
55+
var mappedObject = mapper.map(string: JSON)
5456

5557
if let mappedObject = mappedObject {
5658

@@ -68,7 +70,7 @@ class BasicTypesTests: XCTestCase {
6870
object.doubleOptional = value
6971

7072
let JSON = Mapper().toJSONString(object, prettyPrint: true)
71-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
73+
var mappedObject = mapper.map(string: JSON)
7274

7375
if let mappedObject = mappedObject {
7476

@@ -86,7 +88,7 @@ class BasicTypesTests: XCTestCase {
8688
object.floatOptional = value
8789

8890
let JSON = Mapper().toJSONString(object, prettyPrint: true)
89-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
91+
var mappedObject = mapper.map(string: JSON)
9092

9193
if let mappedObject = mappedObject {
9294

@@ -104,7 +106,7 @@ class BasicTypesTests: XCTestCase {
104106
object.stringOptional = value
105107

106108
let JSON = Mapper().toJSONString(object, prettyPrint: true)
107-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
109+
var mappedObject = mapper.map(string: JSON)
108110

109111
if let mappedObject = mappedObject {
110112

@@ -124,7 +126,7 @@ class BasicTypesTests: XCTestCase {
124126
object.arrayBoolOptional = [value]
125127

126128
let JSON = Mapper().toJSONString(object, prettyPrint: true)
127-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
129+
var mappedObject = mapper.map(string: JSON)
128130

129131
if let mappedObject = mappedObject {
130132
var firstObject = mappedObject.arrayBool[0]
@@ -142,7 +144,7 @@ class BasicTypesTests: XCTestCase {
142144
object.arrayIntOptional = [value]
143145

144146
let JSON = Mapper().toJSONString(object, prettyPrint: true)
145-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
147+
var mappedObject = mapper.map(string: JSON)
146148

147149
if let mappedObject = mappedObject {
148150
var firstObject = mappedObject.arrayInt[0]
@@ -160,7 +162,7 @@ class BasicTypesTests: XCTestCase {
160162
object.arrayDoubleOptional = [value]
161163

162164
let JSON = Mapper().toJSONString(object, prettyPrint: true)
163-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
165+
var mappedObject = mapper.map(string: JSON)
164166

165167
if let mappedObject = mappedObject {
166168
var firstObject = mappedObject.arrayDouble[0]
@@ -178,7 +180,7 @@ class BasicTypesTests: XCTestCase {
178180
object.arrayFloatOptional = [value]
179181

180182
let JSON = Mapper().toJSONString(object, prettyPrint: true)
181-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
183+
var mappedObject = mapper.map(string: JSON)
182184

183185
if let mappedObject = mappedObject {
184186
var firstObject = mappedObject.arrayFloat[0]
@@ -196,7 +198,7 @@ class BasicTypesTests: XCTestCase {
196198
object.arrayStringOptional = [value]
197199

198200
let JSON = Mapper().toJSONString(object, prettyPrint: true)
199-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
201+
var mappedObject = mapper.map(string: JSON)
200202

201203
if let mappedObject = mappedObject {
202204
var firstObject = mappedObject.arrayString[0]
@@ -217,7 +219,7 @@ class BasicTypesTests: XCTestCase {
217219
object.dictBoolOptional = [key:value]
218220

219221
let JSON = Mapper().toJSONString(object, prettyPrint: true)
220-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
222+
var mappedObject = mapper.map(string: JSON)
221223

222224
if let mappedObject = mappedObject {
223225
if let val = mappedObject.dictBoolOptional?[key] {
@@ -237,7 +239,7 @@ class BasicTypesTests: XCTestCase {
237239
object.dictIntOptional = [key:value]
238240

239241
let JSON = Mapper().toJSONString(object, prettyPrint: true)
240-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
242+
var mappedObject = mapper.map(string: JSON)
241243

242244
if let mappedObject = mappedObject {
243245
if let val = mappedObject.dictIntOptional?[key] {
@@ -257,7 +259,7 @@ class BasicTypesTests: XCTestCase {
257259
object.dictDoubleOptional = [key:value]
258260

259261
let JSON = Mapper().toJSONString(object, prettyPrint: true)
260-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
262+
var mappedObject = mapper.map(string: JSON)
261263

262264
if let mappedObject = mappedObject {
263265
if let val = mappedObject.dictDoubleOptional?[key] {
@@ -277,7 +279,7 @@ class BasicTypesTests: XCTestCase {
277279
object.dictFloatOptional = [key:value]
278280

279281
let JSON = Mapper().toJSONString(object, prettyPrint: true)
280-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
282+
var mappedObject = mapper.map(string: JSON)
281283

282284
if let mappedObject = mappedObject {
283285
if let val = mappedObject.dictFloatOptional?[key] {
@@ -297,7 +299,7 @@ class BasicTypesTests: XCTestCase {
297299
object.dictStringOptional = [key:value]
298300

299301
let JSON = Mapper().toJSONString(object, prettyPrint: true)
300-
var mappedObject = Mapper<BasicTypes>().map(string: JSON)
302+
var mappedObject = mapper.map(string: JSON)
301303

302304
if let mappedObject = mappedObject {
303305
if let val = mappedObject.dictStringOptional?[key] {

0 commit comments

Comments
 (0)