@@ -1372,7 +1372,46 @@ int test_notecard_begin_serial_sets_serial_receive_function_pointer_to_nullptr_w
1372
1372
return result;
1373
1373
}
1374
1374
1375
- int test_notecard_end_clears_all_i2c_interface_function_pointers ()
1375
+ int test_notecard_end_does_not_call_wire_end_when_the_i2c_interface_has_not_been_instantiated ()
1376
+ {
1377
+ int result;
1378
+
1379
+ // Arrange
1380
+ // //////////
1381
+
1382
+ Notecard notecard;
1383
+ NoteSerial_Mock mockSerial;
1384
+ noteSetFnSerial_Parameters.reset ();
1385
+ twoWireEnd_Parameters.reset ();
1386
+ notecard.begin (&mockSerial);
1387
+ noteGetFnI2C_Parameters.reset ();
1388
+ noteGetFnSerial_Parameters.reset ();
1389
+ make_note_i2c_Parameters.reset ();
1390
+
1391
+ // Action
1392
+ // /////////
1393
+
1394
+ notecard.end ();
1395
+
1396
+ // Assert
1397
+ // /////////
1398
+
1399
+ if (!make_note_i2c_Parameters.invoked )
1400
+ {
1401
+ result = 0 ;
1402
+ }
1403
+ else
1404
+ {
1405
+ result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
1406
+ std::cout << " \33 [31mFAILED\33 [0m] " << __FILE__ << " :" << __LINE__ << std::endl;
1407
+ std::cout << " \t twoWireEnd_Parameters.invoked == " << !!twoWireEnd_Parameters.invoked << " , 0 (false)" << std::endl;
1408
+ std::cout << " [" ;
1409
+ }
1410
+
1411
+ return result;
1412
+ }
1413
+
1414
+ int test_notecard_end_clears_all_i2c_interface_function_pointers_when_the_i2c_interface_has_been_instantiated ()
1376
1415
{
1377
1416
int result;
1378
1417
@@ -1383,6 +1422,9 @@ int test_notecard_end_clears_all_i2c_interface_function_pointers()
1383
1422
NoteI2c_Mock mockI2c;
1384
1423
noteSetFnI2C_Parameters.reset ();
1385
1424
notecard.begin (&mockI2c);
1425
+ noteGetFnSerial_Parameters.reset ();
1426
+ noteGetFnI2C_Parameters.reset ();
1427
+ noteGetFnI2C_Parameters.transmitFn_result = reinterpret_cast <i2cTransmitFn>(0x1 );
1386
1428
1387
1429
// Action
1388
1430
// /////////
@@ -1411,7 +1453,46 @@ int test_notecard_end_clears_all_i2c_interface_function_pointers()
1411
1453
return result;
1412
1454
}
1413
1455
1414
- int test_notecard_end_clears_all_serial_interface_function_pointers ()
1456
+ int test_notecard_end_does_not_call_serial_end_when_the_serial_interface_has_not_been_instantiated ()
1457
+ {
1458
+ int result;
1459
+
1460
+ // Arrange
1461
+ // //////////
1462
+
1463
+ Notecard notecard;
1464
+ NoteSerial_Mock mockI2c;
1465
+ noteSetFnDefault_Parameters.reset ();
1466
+ notecard.begin (&mockI2c);
1467
+ hardwareSerialEnd_Parameters.reset ();
1468
+ noteGetFnI2C_Parameters.reset ();
1469
+ noteGetFnSerial_Parameters.reset ();
1470
+ make_note_serial_Parameters.reset ();
1471
+
1472
+ // Action
1473
+ // /////////
1474
+
1475
+ notecard.end ();
1476
+
1477
+ // Assert
1478
+ // /////////
1479
+
1480
+ if (!make_note_serial_Parameters.invoked )
1481
+ {
1482
+ result = 0 ;
1483
+ }
1484
+ else
1485
+ {
1486
+ result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
1487
+ std::cout << " \33 [31mFAILED\33 [0m] " << __FILE__ << " :" << __LINE__ << std::endl;
1488
+ std::cout << " \t hardwareSerialEnd_Parameters.invoked == " << !!hardwareSerialEnd_Parameters.invoked << " , EXPECTED: 0 (false)" << std::endl;
1489
+ std::cout << " [" ;
1490
+ }
1491
+
1492
+ return result;
1493
+ }
1494
+
1495
+ int test_notecard_end_clears_all_serial_interface_function_pointers_when_the_serial_interface_has_been_instantiated ()
1415
1496
{
1416
1497
int result;
1417
1498
@@ -1422,6 +1503,9 @@ int test_notecard_end_clears_all_serial_interface_function_pointers()
1422
1503
NoteSerial_Mock mockSerial; // Instantiate NoteSerial (mocked)
1423
1504
noteSetFnDefault_Parameters.reset ();
1424
1505
notecard.begin (&mockSerial);
1506
+ noteGetFnI2C_Parameters.reset ();
1507
+ noteGetFnSerial_Parameters.reset ();
1508
+ noteGetFnSerial_Parameters.transmitFn_result = reinterpret_cast <serialTransmitFn>(0x1 );
1425
1509
1426
1510
// Action
1427
1511
// /////////
@@ -1493,7 +1577,7 @@ int test_notecard_end_clears_all_platform_interface_function_pointers()
1493
1577
return result;
1494
1578
}
1495
1579
1496
- int test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memory ()
1580
+ int test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memory_when_the_i2c_interface_has_been_instantiated ()
1497
1581
{
1498
1582
int result;
1499
1583
@@ -1505,6 +1589,9 @@ int test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memor
1505
1589
make_note_i2c_Parameters.reset ();
1506
1590
make_note_i2c_Parameters.i2c_parameters = &Wire;
1507
1591
notecard.begin (&mockI2c);
1592
+ noteGetFnSerial_Parameters.reset ();
1593
+ noteGetFnI2C_Parameters.reset ();
1594
+ noteGetFnI2C_Parameters.transmitFn_result = reinterpret_cast <i2cTransmitFn>(0x1 );
1508
1595
1509
1596
// Action
1510
1597
// //////////
@@ -1529,7 +1616,7 @@ int test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memor
1529
1616
return result;
1530
1617
}
1531
1618
1532
- int test_notecard_end_invokes_make_note_serial_nullptr_method_to_free_associated_memory ()
1619
+ int test_notecard_end_invokes_make_note_serial_nullptr_method_to_free_associated_memory_when_the_serial_interface_has_been_instantiated ()
1533
1620
{
1534
1621
int result;
1535
1622
@@ -1541,6 +1628,9 @@ int test_notecard_end_invokes_make_note_serial_nullptr_method_to_free_associated
1541
1628
make_note_serial_Parameters.reset ();
1542
1629
make_note_serial_Parameters.serial_parameters = &Serial;
1543
1630
notecard.begin (&mockSerial);
1631
+ noteGetFnI2C_Parameters.reset ();
1632
+ noteGetFnSerial_Parameters.reset ();
1633
+ noteGetFnSerial_Parameters.transmitFn_result = reinterpret_cast <serialTransmitFn>(0x1 );
1544
1634
1545
1635
// Action
1546
1636
// //////////
@@ -4828,11 +4918,13 @@ int main(void)
4828
4918
{test_notecard_begin_serial_sets_serial_available_function_pointer_to_nullptr_when_interface_has_not_been_instantiated, " test_notecard_begin_serial_sets_serial_available_function_pointer_to_nullptr_when_interface_has_not_been_instantiated" },
4829
4919
{test_notecard_begin_serial_shares_a_serial_receive_function_pointer, " test_notecard_begin_serial_shares_a_serial_receive_function_pointer" },
4830
4920
{test_notecard_begin_serial_sets_serial_receive_function_pointer_to_nullptr_when_interface_has_not_been_instantiated, " test_notecard_begin_serial_sets_serial_receive_function_pointer_to_nullptr_when_interface_has_not_been_instantiated" },
4831
- {test_notecard_end_clears_all_i2c_interface_function_pointers, " test_notecard_end_clears_all_i2c_interface_function_pointers" },
4832
- {test_notecard_end_clears_all_serial_interface_function_pointers, " test_notecard_end_clears_all_serial_interface_function_pointers" },
4921
+ {test_notecard_end_clears_all_i2c_interface_function_pointers_when_the_i2c_interface_has_been_instantiated, " test_notecard_end_clears_all_i2c_interface_function_pointers_when_the_i2c_interface_has_been_instantiated" },
4922
+ {test_notecard_end_does_not_call_wire_end_when_the_i2c_interface_has_not_been_instantiated, " test_notecard_end_does_not_call_wire_end_when_the_i2c_interface_has_not_been_instantiated" },
4923
+ {test_notecard_end_does_not_call_serial_end_when_the_serial_interface_has_not_been_instantiated, " test_notecard_end_does_not_call_serial_end_when_the_serial_interface_has_not_been_instantiated" },
4924
+ {test_notecard_end_clears_all_serial_interface_function_pointers_when_the_serial_interface_has_been_instantiated, " test_notecard_end_clears_all_serial_interface_function_pointers_when_the_serial_interface_has_been_instantiated" },
4833
4925
{test_notecard_end_clears_all_platform_interface_function_pointers, " test_notecard_end_clears_all_platform_interface_function_pointers" },
4834
- {test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memory , " test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memory " },
4835
- {test_notecard_end_invokes_make_note_serial_nullptr_method_to_free_associated_memory , " test_notecard_end_invokes_make_note_serial_nullptr_method_to_free_associated_memory " },
4926
+ {test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memory_when_the_i2c_interface_has_been_instantiated , " test_notecard_end_provides_nullptr_to_make_note_i2c_to_free_associated_memory_when_the_i2c_interface_has_been_instantiated " },
4927
+ {test_notecard_end_invokes_make_note_serial_nullptr_method_to_free_associated_memory_when_the_serial_interface_has_been_instantiated , " test_notecard_end_invokes_make_note_serial_nullptr_method_to_free_associated_memory_when_the_serial_interface_has_been_instantiated " },
4836
4928
{test_notecard_setDebugOutputStream_shares_a_debug_log_function_pointer, " test_notecard_setDebugOutputStream_shares_a_debug_log_function_pointer" },
4837
4929
{test_notecard_setDebugOutputStream_clears_the_debug_log_function_pointer_when_nullptr_is_provided, " test_notecard_setDebugOutputStream_clears_the_debug_log_function_pointer_when_nullptr_is_provided" },
4838
4930
{test_notecard_clearDebugOutputStream_clears_the_debug_log_function_pointer, " test_notecard_clearDebugOutputStream_clears_the_debug_log_function_pointer" },
0 commit comments