@@ -227,4 +227,126 @@ contract UnitMockContractG is Test, SmockHelper {
227
227
(_value) = _contractTest.twoDimensionalStringArray (1 , 1 );
228
228
assertEq (_value, '40 ' );
229
229
}
230
+
231
+ function test_Set_NestedStruct () public {
232
+ ContractG.CommonStruct memory _commonStruct = ContractG.CommonStruct (20 );
233
+ ContractG.NestedStruct memory _nestedStruct = ContractG.NestedStruct (10 , _commonStruct);
234
+
235
+ _contractTest.set_nestedStruct (_nestedStruct);
236
+
237
+ (uint256 _counter , ContractG.CommonStruct memory _commonResult ) = _contractTest.nestedStruct ();
238
+
239
+ assertEq (_counter, 10 );
240
+ assertEq (_commonResult._value, 20 );
241
+ }
242
+
243
+ function test_Call_NestedStruct () public {
244
+ ContractG.CommonStruct memory _commonStruct = ContractG.CommonStruct (20 );
245
+ ContractG.NestedStruct memory _nestedStruct = ContractG.NestedStruct (10 , _commonStruct);
246
+
247
+ _contractTest.mock_call_nestedStruct (_nestedStruct);
248
+
249
+ (uint256 _counter , ContractG.CommonStruct memory _commonResult ) = _contractTest.nestedStruct ();
250
+
251
+ assertEq (_counter, 10 );
252
+ assertEq (_commonResult._value, 20 );
253
+ }
254
+
255
+ function test_Call_SetNestedStruct () public {
256
+ ContractG.CommonStruct memory _commonStruct = ContractG.CommonStruct (20 );
257
+ ContractG.NestedStruct memory _nestedStruct = ContractG.NestedStruct (10 , _commonStruct);
258
+
259
+ _contractTest.mock_call_setNestedStruct (_nestedStruct);
260
+ _contractTest.setNestedStruct (_nestedStruct);
261
+
262
+ (uint256 _counter , ContractG.CommonStruct memory _commonResult ) = _contractTest.nestedStruct ();
263
+
264
+ assertEq (_counter, 10 );
265
+ assertEq (_commonResult._value, 20 );
266
+ }
267
+
268
+ function test_Set_StructArray () public {
269
+ ContractG.CommonStruct[] memory _structArray = new ContractG.CommonStruct [](2 );
270
+ _structArray[0 ] = ContractG.CommonStruct (10 );
271
+ _structArray[1 ] = ContractG.CommonStruct (20 );
272
+
273
+ _contractTest.set_structArray (_structArray);
274
+ (uint256 _value ) = _contractTest.structArray (0 );
275
+ assertEq (_value, 10 );
276
+
277
+ (_value) = _contractTest.structArray (1 );
278
+ assertEq (_value, 20 );
279
+ }
280
+
281
+ function test_Call_StructArray () public {
282
+ ContractG.CommonStruct[] memory _structArray = new ContractG.CommonStruct [](2 );
283
+ _structArray[0 ] = ContractG.CommonStruct (10 );
284
+ _structArray[1 ] = ContractG.CommonStruct (20 );
285
+
286
+ _contractTest.mock_call_structArray (0 , _structArray[0 ]);
287
+ (uint256 _value ) = _contractTest.structArray (0 );
288
+ assertEq (_value, 10 );
289
+
290
+ _contractTest.mock_call_structArray (1 , _structArray[1 ]);
291
+ (_value) = _contractTest.structArray (1 );
292
+ assertEq (_value, 20 );
293
+ }
294
+
295
+ function test_Set_StructArrayInternal () public {
296
+ ContractG.CommonStruct[] memory _structArray = new ContractG.CommonStruct [](2 );
297
+ _structArray[0 ] = ContractG.CommonStruct (10 );
298
+ _structArray[1 ] = ContractG.CommonStruct (20 );
299
+
300
+ _contractTest.set__structArrayInternal (_structArray);
301
+
302
+ ContractG.CommonStruct[] memory _resultArray = _contractTest.call__structArrayInternal ();
303
+ assertEq (_resultArray[0 ]._value, 10 );
304
+ assertEq (_resultArray[1 ]._value, 20 );
305
+ }
306
+
307
+ function test_Set_Finished () public {
308
+ bytes32 _key = 'key ' ;
309
+
310
+ _contractTest.set_finished (_key, true );
311
+
312
+ bool _value = _contractTest.finished (_key);
313
+
314
+ assertTrue (_value);
315
+ }
316
+
317
+ function test_Call_Finished () public {
318
+ bytes32 _key = 'key ' ;
319
+ _contractTest.mock_call_finished (_key, true );
320
+
321
+ bool _value = _contractTest.finished (_key);
322
+ assertTrue (_value);
323
+ }
324
+
325
+ function test_Set_FinishedInternal () public {
326
+ bytes32 _key = 'key ' ;
327
+ _contractTest.set__finishedInternal (_key, true );
328
+
329
+ bool _value = _contractTest.call__finishedInternal (_key);
330
+ assertTrue (_value);
331
+ }
332
+
333
+ function test_Set_DoubleFinishedInternal () public {
334
+ bytes32 _key0 = 'key0 ' ;
335
+ bytes32 _key1 = 'key1 ' ;
336
+ _contractTest.set__doubleFinishedInternal (_key0, _key1, true );
337
+
338
+ bool _value = _contractTest.call__doubleFinishedInternal (_key0, _key1);
339
+ assertTrue (_value);
340
+ }
341
+
342
+ function test_Set_NestedStructsInternal () public {
343
+ bytes32 _key = 'key ' ;
344
+ ContractG.NestedStruct memory _nestedStruct = ContractG.NestedStruct (10 , ContractG.CommonStruct (20 ));
345
+
346
+ _contractTest.set__nestedStructsInternal (_key, _nestedStruct);
347
+
348
+ ContractG.NestedStruct memory _result = _contractTest.call__nestedStructsInternal (_key);
349
+ assertEq (_result._counter, 10 );
350
+ assertEq (_result._common._value, 20 );
351
+ }
230
352
}
0 commit comments