7
7
#include " TestFunction.hpp"
8
8
#include " mock/mock-arduino.hpp"
9
9
#include " mock/mock-parameters.hpp"
10
+ #include " mock/NoteI2c_Mock.hpp"
11
+ #include " mock/NoteLog_Mock.hpp"
12
+ #include " mock/NoteSerial_Mock.hpp"
10
13
11
- // Compile command: g++ -Wall -Wextra -Wpedantic mock/mock-arduino.cpp mock/mock-note-c-note.c ../src/Notecard .cpp ../src/NoteI2c_Arduino .cpp ../src/NoteLog_Arduino .cpp ../src/NoteSerial_Arduino .cpp Notecard.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK && ./a.out || echo "Tests Result: $?"
14
+ // Compile command: g++ -Wall -Wextra -Wpedantic mock/mock-arduino.cpp mock/mock-note-c-note.c mock/NoteI2c_Mock .cpp mock/NoteLog_Mock .cpp mock/NoteSerial_Mock .cpp ../src/Notecard .cpp Notecard.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK && ./a.out || echo "Tests Result: $?"
12
15
13
16
int test_notecard_begin_i2c_shares_a_memory_allocation_functon_pointer ()
14
17
{
@@ -323,57 +326,57 @@ int test_notecard_begin_i2c_default_parameter_for_i2c_address_is_passed_to_note_
323
326
return result;
324
327
}
325
328
326
- int test_notecard_begin_i2c_default_parameter_for_wirePort_has_begin_method_called ()
329
+ int test_notecard_begin_i2c_default_parameter_for_wirePort_instantiates_the_note_i2c_interface_with_wire ()
327
330
{
328
331
int result;
329
332
330
333
// Arrange
331
334
Notecard notecard;
332
335
333
- twoWireBegin_Parameters .reset ();
336
+ make_note_i2c_Parameters .reset ();
334
337
335
338
// Action
336
339
notecard.begin ();
337
340
338
341
// Assert
339
- if (twoWireBegin_Parameters. invoked )
342
+ if (&Wire == make_note_i2c_Parameters. i2c_bus )
340
343
{
341
344
result = 0 ;
342
345
}
343
346
else
344
347
{
345
348
result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
346
349
std::cout << " FAILED] " << __FILE__ << " :" << __LINE__ << std::endl;
347
- std::cout << " \t twoWireBegin_Parameters.invoked == " << !!twoWireBegin_Parameters. invoked << " , EXPECTED: " << true << std::endl;
350
+ std::cout << " \t make_note_i2c_Parameters.i2c_bus == " << !!make_note_i2c_Parameters. i2c_bus << " , EXPECTED: " << &Wire << std::endl;
348
351
std::cout << " [" ;
349
352
}
350
353
351
354
return result;
352
355
}
353
356
354
- int test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called ()
357
+ int test_notecard_begin_i2c_parameter_for_wirePort_instantiates_the_note_i2c_interface_with_wirePort ()
355
358
{
356
359
int result;
357
360
358
361
// Arrange
359
362
Notecard notecard;
360
363
TwoWire mockWire;
361
364
362
- twoWireBegin_Parameters .reset ();
365
+ make_note_i2c_Parameters .reset ();
363
366
364
367
// Action
365
368
notecard.begin (NOTE_I2C_ADDR_DEFAULT, NOTE_I2C_MAX_DEFAULT, mockWire);
366
369
367
370
// Assert
368
- if (twoWireBegin_Parameters. invoked )
371
+ if (&mockWire == make_note_i2c_Parameters. i2c_bus )
369
372
{
370
373
result = 0 ;
371
374
}
372
375
else
373
376
{
374
377
result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
375
378
std::cout << " FAILED] " << __FILE__ << " :" << __LINE__ << std::endl;
376
- std::cout << " \t twoWireBegin_Parameters.invoked == " << !!twoWireBegin_Parameters. invoked << " , EXPECTED: " << true << std::endl;
379
+ std::cout << " \t make_note_i2c_Parameters.i2c_bus == " << make_note_i2c_Parameters. i2c_bus << " , EXPECTED: " << &mockWire << std::endl;
377
380
std::cout << " [" ;
378
381
}
379
382
@@ -641,50 +644,50 @@ int test_notecard_begin_serial_initializes_the_provided_serial_interface_with_pr
641
644
Notecard notecard;
642
645
const unsigned int EXPECTED_BAUD_RATE = 9600 ;
643
646
644
- hardwareSerialBegin_Parameters .reset ();
647
+ make_note_serial_Parameters .reset ();
645
648
646
649
// Action
647
650
notecard.begin (Serial, EXPECTED_BAUD_RATE);
648
651
649
652
// Assert
650
- if (EXPECTED_BAUD_RATE == hardwareSerialBegin_Parameters. baud )
653
+ if (EXPECTED_BAUD_RATE == make_note_serial_Parameters. baud_rate )
651
654
{
652
655
result = 0 ;
653
656
}
654
657
else
655
658
{
656
659
result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
657
660
std::cout << " FAILED] " << __FILE__ << " :" << __LINE__ << std::endl;
658
- std::cout << " \t hardwareSerialBegin_Parameters.baud == " << hardwareSerialBegin_Parameters. baud << " , EXPECTED: " << EXPECTED_BAUD_RATE << std::endl;
661
+ std::cout << " \t make_note_serial_Parameters.baud_rate == " << make_note_serial_Parameters. baud_rate << " , EXPECTED: " << EXPECTED_BAUD_RATE << std::endl;
659
662
std::cout << " [" ;
660
663
}
661
664
662
665
return result;
663
666
}
664
667
665
- int test_notecard_begin_serial_default_parameter_for_baud_rate_is_passed_to_note_c ()
668
+ int test_notecard_begin_serial_initializes_the_provided_serial_interface_with_default_speed ()
666
669
{
667
670
int result;
668
671
669
672
// Arrange
670
673
Notecard notecard;
671
674
const unsigned int EXPECTED_BAUD_RATE = 9600 ;
672
675
673
- hardwareSerialBegin_Parameters .reset ();
676
+ make_note_serial_Parameters .reset ();
674
677
675
678
// Action
676
679
notecard.begin (Serial);
677
680
678
681
// Assert
679
- if (EXPECTED_BAUD_RATE == hardwareSerialBegin_Parameters. baud )
682
+ if (EXPECTED_BAUD_RATE == make_note_serial_Parameters. baud_rate )
680
683
{
681
684
result = 0 ;
682
685
}
683
686
else
684
687
{
685
688
result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
686
689
std::cout << " FAILED] " << __FILE__ << " :" << __LINE__ << std::endl;
687
- std::cout << " \t hardwareSerialBegin_Parameters.baud == " << hardwareSerialBegin_Parameters. baud << " , EXPECTED: " << EXPECTED_BAUD_RATE << std::endl;
690
+ std::cout << " \t make_note_serial_Parameters.baud_rate == " << make_note_serial_Parameters. baud_rate << " , EXPECTED: " << EXPECTED_BAUD_RATE << std::endl;
688
691
std::cout << " [" ;
689
692
}
690
693
@@ -1315,8 +1318,8 @@ int main(void)
1315
1318
{test_notecard_begin_i2c_shares_an_i2c_receive_functon_pointer, " test_notecard_begin_i2c_shares_an_i2c_receive_functon_pointer" },
1316
1319
{test_notecard_begin_i2c_default_parameter_for_i2c_max_is_passed_to_note_c, " test_notecard_begin_i2c_default_parameter_for_i2c_max_is_passed_to_note_c" },
1317
1320
{test_notecard_begin_i2c_default_parameter_for_i2c_address_is_passed_to_note_c, " test_notecard_begin_i2c_default_parameter_for_i2c_address_is_passed_to_note_c" },
1318
- {test_notecard_begin_i2c_default_parameter_for_wirePort_has_begin_method_called , " test_notecard_begin_i2c_default_parameter_for_wirePort_has_begin_method_called " },
1319
- {test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called , " test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called " },
1321
+ {test_notecard_begin_i2c_default_parameter_for_wirePort_instantiates_the_note_i2c_interface_with_wire , " test_notecard_begin_i2c_default_parameter_for_wirePort_instantiates_the_note_i2c_interface_with_wire " },
1322
+ {test_notecard_begin_i2c_parameter_for_wirePort_instantiates_the_note_i2c_interface_with_wirePort , " test_notecard_begin_i2c_parameter_for_wirePort_instantiates_the_note_i2c_interface_with_wirePort " },
1320
1323
{test_notecard_begin_i2c_sets_user_agent_to_note_arduino, " test_notecard_begin_i2c_sets_user_agent_to_note_arduino" },
1321
1324
{test_notecard_begin_serial_shares_a_memory_allocation_functon_pointer, " test_notecard_begin_serial_shares_a_memory_allocation_functon_pointer" },
1322
1325
{test_notecard_begin_serial_shares_a_memory_free_functon_pointer, " test_notecard_begin_serial_shares_a_memory_free_functon_pointer" },
@@ -1327,7 +1330,7 @@ int main(void)
1327
1330
{test_notecard_begin_serial_shares_a_serial_available_functon_pointer, " test_notecard_begin_serial_shares_a_serial_available_functon_pointer" },
1328
1331
{test_notecard_begin_serial_shares_a_serial_receive_functon_pointer, " test_notecard_begin_serial_shares_a_serial_receive_functon_pointer" },
1329
1332
{test_notecard_begin_serial_initializes_the_provided_serial_interface_with_provided_speed, " test_notecard_begin_serial_initializes_the_provided_serial_interface_with_provided_speed" },
1330
- {test_notecard_begin_serial_default_parameter_for_baud_rate_is_passed_to_note_c , " test_notecard_begin_serial_default_parameter_for_baud_rate_is_passed_to_note_c " },
1333
+ {test_notecard_begin_serial_initializes_the_provided_serial_interface_with_default_speed , " test_notecard_begin_serial_initializes_the_provided_serial_interface_with_default_speed " },
1331
1334
{test_notecard_begin_serial_sets_user_agent_to_note_arduino, " test_notecard_begin_serial_sets_user_agent_to_note_arduino" },
1332
1335
{test_notecard_setDebugOutputStream_shares_a_debug_log_functon_pointer, " test_notecard_setDebugOutputStream_shares_a_debug_log_functon_pointer" },
1333
1336
{test_notecard_clearDebugOutputStream_clears_the_debug_log_functon_pointer, " test_notecard_clearDebugOutputStream_clears_the_debug_log_functon_pointer" },
0 commit comments