From ae1a122b2ee25a79a1b4189ada6d9b6669162490 Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Sat, 22 Jun 2024 01:27:24 +0000 Subject: [PATCH] [TS-267] Add `HardwareSerial::end()` to `NoteSerialReset` in `note-arduino` --- src/NoteSerial_Arduino.cpp | 1 + test/NoteI2c_Arduino.test.cpp | 76 ++++++++++++++++---------------- test/NoteLog_Arduino.test.cpp | 10 ++--- test/NoteSerial_Arduino.test.cpp | 64 +++++++++++++++++++-------- test/NoteTxn_Arduino.test.cpp | 32 +++++++------- test/mock/mock-arduino.cpp | 9 ++++ test/mock/mock-arduino.hpp | 22 ++++++++- 7 files changed, 135 insertions(+), 79 deletions(-) diff --git a/src/NoteSerial_Arduino.cpp b/src/NoteSerial_Arduino.cpp index 2187c07..b5adaf1 100644 --- a/src/NoteSerial_Arduino.cpp +++ b/src/NoteSerial_Arduino.cpp @@ -50,6 +50,7 @@ NoteSerial_Arduino::reset ( void ) { + _notecardSerial.end(); _notecardSerial.begin(_notecardSerialSpeed); return true; diff --git a/test/NoteI2c_Arduino.test.cpp b/test/NoteI2c_Arduino.test.cpp index fd45278..bca0186 100644 --- a/test/NoteI2c_Arduino.test.cpp +++ b/test/NoteI2c_Arduino.test.cpp @@ -26,7 +26,7 @@ int test_make_note_i2c_instantiates_notei2c_object() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c == " << (!!notei2c ? "not nullptr" : "nullptr") << ", EXPECTED: not nullptr" << std::endl; std::cout << "["; } @@ -55,7 +55,7 @@ int test_make_note_i2c_enforces_singleton_by_returning_same_notei2c_object_for_a else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c_2 == " << std::hex << notei2c_2 << ", EXPECTED: " << notei2c_1 << std::endl; std::cout << "["; } @@ -86,7 +86,7 @@ int test_make_note_i2c_deletes_singleton_when_nullptr_is_passed_as_parameter() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c == " << std::hex << notei2c << ", EXPECTED: 0 (nullptr)" << std::endl; std::cout << "["; } @@ -112,7 +112,7 @@ int test_notei2c_arduino_constructor_invokes_twowire_parameter_begin_method() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireBegin_Parameters.invoked == " << (!!twoWireBegin_Parameters.invoked ? "true" : "false") << ", EXPECTED: true" << std::endl; std::cout << "["; } @@ -157,7 +157,7 @@ int test_notei2c_arduino_receive_requests_response_data_from_notecard() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireBeginTransmission_Parameters.address == 0x" << std::hex << static_cast(twoWireBeginTransmission_Parameters.address) << ", EXPECTED: 0x" << EXPECTED_ADDRESS << std::dec << std::endl; std::cout << "\ttwoWireWriteByte_Parameters.write_buffer[0] == " << static_cast(twoWireWriteByte_Parameters.write_buffer[0]) << ", EXPECTED: " << 0 << std::endl; std::cout << "\ttwoWireWriteByte_Parameters.write_buffer[1] == " << static_cast(twoWireWriteByte_Parameters.write_buffer[1]) << ", EXPECTED: " << static_cast(REQUEST_SIZE) << std::endl; @@ -204,7 +204,7 @@ int test_notei2c_arduino_receive_will_retry_transmission_on_i2c_failure() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireBeginTransmission_Parameters.invoked == " << twoWireBeginTransmission_Parameters.invoked << ", EXPECTED: > 1" << std::endl; std::cout << "\ttwoWireWriteByte_Parameters.invoked == " << twoWireWriteByte_Parameters.invoked << ", EXPECTED: > 2" << std::endl; std::cout << "\ttwoWireEndTransmission_Parameters.invoked == " << twoWireEndTransmission_Parameters.invoked << ", EXPECTED: > 1" << std::endl; @@ -254,7 +254,7 @@ int test_notei2c_arduino_receive_will_not_retry_transmission_on_i2c_success() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireBeginTransmission_Parameters.invoked == " << twoWireBeginTransmission_Parameters.invoked << ", EXPECTED: " << 1 << std::endl; std::cout << "\ttwoWireWriteByte_Parameters.invoked == " << twoWireWriteByte_Parameters.invoked << ", EXPECTED: " << 2 << std::endl; std::cout << "\ttwoWireEndTransmission_Parameters.invoked == " << twoWireEndTransmission_Parameters.invoked << ", EXPECTED: " << 1 << std::endl; @@ -301,7 +301,7 @@ int test_notei2c_arduino_receive_will_only_retry_i2c_transmission_thrice() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireBeginTransmission_Parameters.invoked == " << twoWireBeginTransmission_Parameters.invoked << ", EXPECTED: " << 4 << std::endl; std::cout << "\ttwoWireWriteByte_Parameters.invoked == " << twoWireWriteByte_Parameters.invoked << ", EXPECTED: " << 8 << std::endl; std::cout << "\ttwoWireEndTransmission_Parameters.invoked == " << twoWireEndTransmission_Parameters.invoked << ", EXPECTED: " << 4 << std::endl; @@ -351,7 +351,7 @@ int test_notei2c_arduino_receive_reads_response_data_from_notecard() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireRequestFrom_Parameters.address == 0x" << std::hex << static_cast(twoWireRequestFrom_Parameters.address) << ", EXPECTED: 0x" << EXPECTED_ADDRESS << std::dec << std::endl; std::cout << "\ttwoWireRequestFrom_Parameters.quantity == " << twoWireRequestFrom_Parameters.quantity << ", EXPECTED: " << (REQUEST_SIZE + NoteI2c::REQUEST_HEADER_SIZE) << std::endl; std::cout << "\tresponse_buffer == \"" << response_buffer << "\"" << ", EXPECTED: " << EXPECTED_RESPONSE << std::endl; @@ -396,7 +396,7 @@ int test_notei2c_arduino_receive_updates_available_parameter_with_remaining_byte else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tbytes_remaining == " << bytes_remaining << ", EXPECTED: " << 5 << std::endl; std::cout << "["; } @@ -443,7 +443,7 @@ int test_notei2c_arduino_receive_does_not_request_or_read_i2c_when_trasmission_e else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireRequestFrom_Parameters.invoked == " << (!!twoWireRequestFrom_Parameters.invoked ? "true" : "false") << ", EXPECTED: false" << std::endl; std::cout << "\ttwoWireRead_Parameters.invoked == " << (!!twoWireRead_Parameters.invoked ? "true" : "false") << ", EXPECTED: false" << std::endl; std::cout << "["; @@ -490,7 +490,7 @@ int test_notei2c_arduino_receive_will_not_attempt_to_read_when_i2c_port_request_ else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireRequestFrom_Parameters.invoked == " << (!!twoWireRequestFrom_Parameters.invoked ? "true" : "false") << ", EXPECTED: true" << std::endl; std::cout << "\ttwoWireRead_Parameters.invoked == " << (!!twoWireRead_Parameters.invoked ? "true" : "false") << ", EXPECTED: false" << std::endl; std::cout << "["; @@ -538,7 +538,7 @@ int test_notei2c_arduino_receive_will_not_attempt_to_read_remaining_bytes_when_f else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireRequestFrom_Parameters.invoked == " << (!!twoWireRequestFrom_Parameters.invoked ? "true" : "false") << ", EXPECTED: true" << std::endl; std::cout << "\ttwoWireRead_Parameters.invoked == " << twoWireRead_Parameters.invoked << ", EXPECTED: <= 4" << std::endl; std::cout << "["; @@ -585,7 +585,7 @@ int test_notei2c_arduino_receive_will_not_attempt_to_read_when_i2c_port_request_ else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireRequestFrom_Parameters.invoked == " << (!!twoWireRequestFrom_Parameters.invoked ? "true" : "false") << ", EXPECTED: true" << std::endl; std::cout << "\ttwoWireRead_Parameters.invoked == " << (!!twoWireRead_Parameters.invoked ? "true" : "false") << ", EXPECTED: false" << std::endl; std::cout << "["; @@ -632,7 +632,7 @@ int test_notei2c_arduino_receive_will_not_read_full_response_when_i2c_over_seria else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireRequestFrom_Parameters.invoked == " << (!!twoWireRequestFrom_Parameters.invoked ? "true" : "false") << ", EXPECTED: true" << std::endl; std::cout << "\ttwoWireRead_Parameters.invoked == " << twoWireRead_Parameters.invoked << ", EXPECTED: " << 8 << std::endl; std::cout << "["; @@ -680,7 +680,7 @@ int test_notei2c_arduino_receive_returns_nullptr_on_success() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tresponse_buffer == \"" << response_buffer << "\"" << ", EXPECTED: " << EXPECTED_RESPONSE << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << ACTUAL_RESULT << ", EXPECTED: 0 (nullptr)" << std::endl; std::cout << "["; @@ -729,7 +729,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_i2c_transmission_failu else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -777,7 +777,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_i2c_transmission_failu else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -825,7 +825,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_i2c_transmission_failu else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -873,7 +873,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_i2c_transmission_failu else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -921,7 +921,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_i2c_transmission_failu else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -969,7 +969,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_unexpected_i2c_transmi else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1015,7 +1015,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_serial_over_i2c_protoc else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1062,7 +1062,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_serial_over_i2c_protoc else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1110,7 +1110,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_serial_over_i2c_protoc else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1157,7 +1157,7 @@ int test_notei2c_arduino_receive_returns_error_message_on_serial_over_i2c_protoc else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.receive(EXPECTED_ADDRESS,response_buffer,REQUEST_SIZE,&bytes_remaining) == " << (ACTUAL_RESULT ? ACTUAL_RESULT : "nullptr") << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1185,7 +1185,7 @@ int test_notei2c_arduino_reset_invokes_begin_method_on_constructor_twowire_param else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireBegin_Parameters.invoked == " << (!!twoWireBegin_Parameters.invoked ? "true" : "false") << ", EXPECTED: true" << std::endl; std::cout << "["; } @@ -1213,7 +1213,7 @@ int test_notei2c_arduino_reset_returns_true() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.reset(DEVICE_ADDRESS) == " << ACTUAL_RESULT << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -1244,7 +1244,7 @@ int test_notei2c_arduino_reset_does_not_invoke_end_method_on_constructor_twowire else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireEnd_Parameters.invoked == " << (!!twoWireEnd_Parameters.invoked ? "true" : "false") << ", EXPECTED: false" << std::endl; std::cout << "["; } @@ -1275,7 +1275,7 @@ int test_notei2c_arduino_reset_invokes_end_method_on_constructor_twowire_paramet else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireEnd_Parameters.invoked == " << (!!twoWireEnd_Parameters.invoked ? "true" : "false") << ", EXPECTED: true" << std::endl; std::cout << "["; } @@ -1323,7 +1323,7 @@ int test_notei2c_arduino_transmit_translates_parameters_for_arduino_two_wire() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\ttwoWireBeginTransmission_Parameters.address == 0x" << std::hex << static_cast(twoWireBeginTransmission_Parameters.address) << ", EXPECTED: 0x" << EXPECTED_ADDRESS << std::dec << std::endl; std::cout << "\ttwoWireWriteByte_Parameters.write_buffer[0] == " << static_cast(twoWireWriteByte_Parameters.write_buffer[0]) << ", EXPECTED: " << static_cast(REQUEST_SIZE) << std::endl; std::cout << "\ttwoWireWriteBuffer_Parameters.buffer == \"" << twoWireWriteBuffer_Parameters.buffer << "\", EXPECTED: \"" << write_buffer << "\"" << std::endl; @@ -1367,7 +1367,7 @@ int test_notei2c_arduino_transmit_returns_nullptr_on_success() else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.transmit(EXPECTED_ADDRESS,write_buffer,REQUEST_SIZE) == " << ACTUAL_RESULT << ", EXPECTED: 0 (nullptr)" << std::endl; std::cout << "["; } @@ -1410,7 +1410,7 @@ int test_notei2c_arduino_transmit_returns_error_message_on_i2c_transmission_fail else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.transmit(EXPECTED_ADDRESS,write_buffer,REQUEST_SIZE) == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1453,7 +1453,7 @@ int test_notei2c_arduino_transmit_returns_error_message_on_i2c_transmission_fail else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.transmit(EXPECTED_ADDRESS,write_buffer,REQUEST_SIZE) == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1496,7 +1496,7 @@ int test_notei2c_arduino_transmit_returns_error_message_on_i2c_transmission_fail else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.transmit(EXPECTED_ADDRESS,write_buffer,REQUEST_SIZE) == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1539,7 +1539,7 @@ int test_notei2c_arduino_transmit_returns_error_message_on_i2c_transmission_fail else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.transmit(EXPECTED_ADDRESS,write_buffer,REQUEST_SIZE) == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1582,7 +1582,7 @@ int test_notei2c_arduino_transmit_returns_error_message_on_i2c_transmission_fail else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.transmit(EXPECTED_ADDRESS,write_buffer,REQUEST_SIZE) == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -1625,7 +1625,7 @@ int test_notei2c_arduino_transmit_returns_error_message_on_unexpected_i2c_transm else { result = static_cast('i' + '2' + 'c'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotei2c.transmit(EXPECTED_ADDRESS,write_buffer,REQUEST_SIZE) == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } diff --git a/test/NoteLog_Arduino.test.cpp b/test/NoteLog_Arduino.test.cpp index ede7a75..06e1d25 100644 --- a/test/NoteLog_Arduino.test.cpp +++ b/test/NoteLog_Arduino.test.cpp @@ -26,7 +26,7 @@ int test_make_note_log_instantiates_notelog_object() else { result = static_cast('d' + 'e' + 'b' + 'u' + 'g'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotelog == " << !!notelog << ", EXPECTED: not nullptr" << std::endl; std::cout << "["; } @@ -55,7 +55,7 @@ int test_make_note_log_enforces_singleton_by_returning_same_notelog_object_for_a else { result = static_cast('d' + 'e' + 'b' + 'u' + 'g'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotelog_2 == " << std::hex << notelog_2 << ", EXPECTED: " << notelog_1 << std::endl; std::cout << "["; } @@ -86,7 +86,7 @@ int test_make_note_log_deletes_singleton_when_nullptr_is_passed_as_parameter() else { result = static_cast('d' + 'e' + 'b' + 'u' + 'g'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotelog == " << std::hex << notelog << ", EXPECTED: 0 (nullptr)" << std::endl; std::cout << "["; } @@ -115,7 +115,7 @@ int test_notelog_arduino_print_does_not_modify_str_parameter_value_before_passin else { result = static_cast('d' + 'e' + 'b' + 'u' + 'g'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tstreamPrint_Parameters.str_cache.c_str() == \"" << streamPrint_Parameters.str_cache.c_str() << "\", EXPECTED: \"" << EXPECTED_RESULT << "\"" << std::endl; std::cout << "["; } @@ -145,7 +145,7 @@ int test_notelog_arduino_print_does_not_modify_stream_print_result_value_before_ else { result = static_cast('d' + 'e' + 'b' + 'u' + 'g'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotelog.print(\"Hello, Test!\") == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } diff --git a/test/NoteSerial_Arduino.test.cpp b/test/NoteSerial_Arduino.test.cpp index a1a88a8..44f54c0 100644 --- a/test/NoteSerial_Arduino.test.cpp +++ b/test/NoteSerial_Arduino.test.cpp @@ -27,7 +27,7 @@ int test_make_note_serial_instantiates_noteserial_object() else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnoteserial == " << !!noteserial << ", EXPECTED: not nullptr" << std::endl; std::cout << "["; } @@ -57,7 +57,7 @@ int test_make_note_serial_enforces_singleton_by_returning_same_noteserial_object else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnoteserial_2 == " << std::hex << noteserial_2 << ", EXPECTED: " << noteserial_1 << std::endl; std::cout << "["; } @@ -89,7 +89,7 @@ int test_make_note_serial_deletes_singleton_when_nullptr_is_passed_as_parameter( else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnoteserial == " << std::hex << noteserial << ", EXPECTED: 0 (nullptr)" << std::endl; std::cout << "["; } @@ -115,7 +115,7 @@ int test_noteserial_arduino_constructor_invokes_hardware_serial_parameter_begin_ else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialBegin_Parameters.invoked == " << !!hardwareSerialBegin_Parameters.invoked << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -143,7 +143,7 @@ int test_noteserial_arduino_constructor_does_not_modify_baud_parameter_before_pa else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialBegin_Parameters.baud == " << hardwareSerialBegin_Parameters.baud << ", EXPECTED: " << EXPECTED_BAUD_RATE << std::endl; std::cout << "["; } @@ -170,7 +170,7 @@ int test_noteserial_arduino_available_invokes_hardware_serial_available() else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialAvailable_Parameters.invoked == " << !!hardwareSerialAvailable_Parameters.invoked << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -200,7 +200,7 @@ int test_noteserial_arduino_available_does_not_modify_hardware_serial_available_ else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnoteserial.available() == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -228,7 +228,7 @@ int test_noteserial_arduino_receive_invokes_hardware_serial_read() else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialRead_Parameters.invoked == " << hardwareSerialRead_Parameters.invoked << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -258,7 +258,7 @@ int test_noteserial_arduino_receive_does_not_modify_hardware_serial_read_result_ else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnoteserial.receive() == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -266,6 +266,33 @@ int test_noteserial_arduino_receive_does_not_modify_hardware_serial_read_result_ return result; } +int test_noteserial_arduino_reset_invokes_hardware_serial_end() +{ + int result; + + // Arrange + NoteSerial_Arduino noteserial(Serial, 9600); + hardwareSerialEnd_Parameters.reset(); + + // Action + noteserial.reset(); + + // Assert + if (hardwareSerialEnd_Parameters.invoked) + { + result = 0; + } + else + { + result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\thardwareSerialEnd_Parameters.invoked == " << !!hardwareSerialEnd_Parameters.invoked << ", EXPECTED: " << true << std::endl; + std::cout << "["; + } + + return result; +} + int test_noteserial_arduino_reset_invokes_hardware_serial_begin() { int result; @@ -285,7 +312,7 @@ int test_noteserial_arduino_reset_invokes_hardware_serial_begin() else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialBegin_Parameters.invoked == " << !!hardwareSerialBegin_Parameters.invoked << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -314,7 +341,7 @@ int test_noteserial_arduino_reset_invokes_hardware_serial_begin_with_the_baud_pa else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialBegin_Parameters.baud == " << hardwareSerialBegin_Parameters.baud << ", EXPECTED: " << EXPECTED_BAUD_RATE << std::endl; std::cout << "["; } @@ -340,7 +367,7 @@ int test_noteserial_arduino_reset_always_returns_true() else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnoteserial.reset() == " << ACTUAL_RESULT << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -368,7 +395,7 @@ int test_noteserial_arduino_transmit_invokes_hardware_serial_write() else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialWrite_Parameters.invoked == " << !!hardwareSerialWrite_Parameters.invoked << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -397,7 +424,7 @@ int test_noteserial_arduino_transmit_does_not_modify_buffer_parameter_value_befo else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialWrite_Parameters.buffer_cache.c_str() == \"" << hardwareSerialWrite_Parameters.buffer_cache.c_str() << "\", EXPECTED: \"" << EXPECTED_RESULT << "\"" << std::endl; std::cout << "["; } @@ -426,7 +453,7 @@ int test_noteserial_arduino_transmit_does_not_modify_size_parameter_value_before else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialWrite_Parameters.size == " << hardwareSerialWrite_Parameters.size << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -453,7 +480,7 @@ int test_noteserial_arduino_transmit_invokes_hardware_serial_flush_when_flush_pa else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialFlush_Parameters.invoked == " << !!hardwareSerialFlush_Parameters.invoked << ", EXPECTED: " << true << std::endl; std::cout << "["; } @@ -480,7 +507,7 @@ int test_noteserial_arduino_transmit_does_not_invoke_hardware_serial_flush_when_ else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\thardwareSerialFlush_Parameters.invoked == " << !!hardwareSerialFlush_Parameters.invoked << ", EXPECTED: " << false << std::endl; std::cout << "["; } @@ -510,7 +537,7 @@ int test_noteserial_arduino_transmit_does_not_modify_hardware_serial_write_resul else { result = static_cast('s' + 'e' + 'r' + 'i' + 'a' + 'l'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnoteserial.transmit(reinterpret_cast(const_cast(\"Hello, Test!\")), 13, true) == " << ACTUAL_RESULT << ", EXPECTED: " << EXPECTED_RESULT << std::endl; std::cout << "["; } @@ -532,6 +559,7 @@ int main(void) {test_noteserial_arduino_receive_does_not_modify_hardware_serial_read_result_value_before_returning_to_caller, "test_noteserial_arduino_receive_does_not_modify_hardware_serial_read_result_value_before_returning_to_caller"}, {test_noteserial_arduino_reset_invokes_hardware_serial_begin, "test_noteserial_arduino_reset_invokes_hardware_serial_begin"}, {test_noteserial_arduino_reset_invokes_hardware_serial_begin_with_the_baud_parameter_that_was_originally_supplied_to_the_constructor, "test_noteserial_arduino_reset_invokes_hardware_serial_begin_with_the_baud_parameter_that_was_originally_supplied_to_the_constructor"}, + {test_noteserial_arduino_reset_invokes_hardware_serial_end, "test_noteserial_arduino_reset_invokes_hardware_serial_end"}, {test_noteserial_arduino_reset_always_returns_true, "test_noteserial_arduino_reset_always_returns_true"}, {test_noteserial_arduino_transmit_invokes_hardware_serial_write, "test_noteserial_arduino_transmit_invokes_hardware_serial_write"}, {test_noteserial_arduino_transmit_does_not_modify_buffer_parameter_value_before_passing_to_hardware_serial_write, "test_noteserial_arduino_transmit_does_not_modify_buffer_parameter_value_before_passing_to_hardware_serial_write"}, diff --git a/test/NoteTxn_Arduino.test.cpp b/test/NoteTxn_Arduino.test.cpp index 434572d..0d349e1 100644 --- a/test/NoteTxn_Arduino.test.cpp +++ b/test/NoteTxn_Arduino.test.cpp @@ -26,7 +26,7 @@ int test_make_note_txn_instantiates_notetxn_object() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotetxn == " << !!notetxn << ", EXPECTED: not nullptr" << std::endl; std::cout << "["; } @@ -57,7 +57,7 @@ int test_make_note_txn_enforces_singleton_by_returning_same_notetxn_object_for_a else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotetxn_2 == " << std::hex << notetxn_2 << ", EXPECTED: " << notetxn_1 << std::endl; std::cout << "["; } @@ -89,7 +89,7 @@ int test_make_note_txn_deletes_singleton_when_nullptr_is_passed_as_parameter() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tnotetxn == " << std::hex << notetxn << ", EXPECTED: 0 (nullptr)" << std::endl; std::cout << "["; } @@ -117,7 +117,7 @@ int test_notetxn_arduino_constructor_floats_ctx_pin() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tpinMode_Parameters.pin_mode[CTX_PIN][(pinMode_Parameters.invoked[CTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[CTX_PIN][(pinMode_Parameters.invoked[CTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << INPUT << std::endl; std::cout << "["; } @@ -145,7 +145,7 @@ int test_notetxn_arduino_constructor_floats_rtx_pin() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tpinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << INPUT << std::endl; std::cout << "["; } @@ -180,7 +180,7 @@ int test_notetxn_arduino_start_initially_configures_ctx_pin_as_input_pullup() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; if (pinMode_Parameters.pin_mode.find(CTX_PIN) != pinMode_Parameters.pin_mode.end()) { std::cout << "\tpinMode_Parameters.pin_mode[CTX_PIN][0] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[CTX_PIN][0]) << ", EXPECTED: 0x" << std::hex << static_cast(INPUT_PULLUP) << std::endl; } else { @@ -219,7 +219,7 @@ int test_notetxn_arduino_start_configures_rtx_pin_as_output() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; if (pinMode_Parameters.pin_mode.find(RTX_PIN) != pinMode_Parameters.pin_mode.end()) { std::cout << "\tpinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(OUTPUT) << std::endl; } else { @@ -258,7 +258,7 @@ int test_notetxn_arduino_start_sets_rtx_pin_high() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; if (digitalWrite_Parameters.pin_val.find(RTX_PIN) != digitalWrite_Parameters.pin_val.end()) { std::cout << "\tdigitalWrite_Parameters.pin_val[RTX_PIN][(digitalWrite_Parameters.invoked[RTX_PIN] - 1)] == 0x" << std::hex << static_cast(digitalWrite_Parameters.pin_val[RTX_PIN][(digitalWrite_Parameters.invoked[RTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(HIGH) << std::endl; } else { @@ -302,7 +302,7 @@ int test_notetxn_arduino_start_blocks_until_ctx_pin_goes_high() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; if (digitalRead_Parameters.result.find(CTX_PIN) != digitalRead_Parameters.result.end()) { std::cout << "\tdigitalRead_Parameters.invoked[CTX_PIN] == " << std::dec << static_cast(digitalRead_Parameters.invoked[CTX_PIN]) << ", EXPECTED: " << std::dec << static_cast(digitalRead_Parameters.result[CTX_PIN].size()) << std::endl; std::cout << "\tdigitalRead_Parameters.result[CTX_PIN][(digitalRead_Parameters.invoked[CTX_PIN] - 1)] == 0x" << std::hex << static_cast(digitalRead_Parameters.result[CTX_PIN][(digitalRead_Parameters.invoked[CTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(HIGH) << std::endl; @@ -348,7 +348,7 @@ int test_notetxn_arduino_start_blocks_until_timeout_ms() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tdigitalRead_Parameters.invoked[CTX_PIN] == " << std::dec << static_cast(digitalRead_Parameters.invoked[CTX_PIN]) << ", EXPECTED: > 0" << std::endl; std::cout << "\tdigitalRead_Parameters.result[CTX_PIN].size() == " << std::dec << static_cast(digitalRead_Parameters.result[CTX_PIN].size()) << ", EXPECTED: 0" << std::endl; std::cout << "["; @@ -386,7 +386,7 @@ int test_notetxn_arduino_start_leaves_rtx_pin_as_output_when_ctx_responds_high() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tdigitalRead_Parameters.invoked[CTX_PIN] == " << std::dec << static_cast(digitalRead_Parameters.invoked[CTX_PIN]) << ", EXPECTED: > 0" << std::endl; std::cout << "\tdigitalRead_Parameters.result[CTX_PIN].size() == " << std::dec << static_cast(digitalRead_Parameters.result[CTX_PIN].size()) << ", EXPECTED: 0" << std::endl; std::cout << "\tpinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(OUTPUT) << std::endl; @@ -425,7 +425,7 @@ int test_notetxn_arduino_start_leaves_rtx_pin_high_when_ctx_responds_high() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tdigitalRead_Parameters.invoked[CTX_PIN] == " << std::dec << static_cast(digitalRead_Parameters.invoked[CTX_PIN]) << ", EXPECTED: > 0" << std::endl; std::cout << "\tdigitalRead_Parameters.result[CTX_PIN].size() == " << std::dec << static_cast(digitalRead_Parameters.result[CTX_PIN].size()) << ", EXPECTED: 0" << std::endl; std::cout << "\tdigitalWrite_Parameters.pin_val[RTX_PIN][(digitalWrite_Parameters.invoked[RTX_PIN] - 1)] == 0x" << std::hex << static_cast(digitalWrite_Parameters.pin_val[RTX_PIN][(digitalWrite_Parameters.invoked[RTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(HIGH) << std::endl; @@ -462,7 +462,7 @@ int test_notetxn_arduino_start_leaves_ctx_pin_floating_when_ctx_responds_high() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tpinMode_Parameters.invoked[CTX_PIN] == " << std::dec << static_cast(pinMode_Parameters.invoked[CTX_PIN]) << ", EXPECTED: > 1" << std::endl; std::cout << "\tpinMode_Parameters.pin_mode[CTX_PIN][(pinMode_Parameters.invoked[CTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[CTX_PIN][(pinMode_Parameters.invoked[CTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(INPUT) << std::endl; std::cout << "["; @@ -507,7 +507,7 @@ int test_notetxn_arduino_start_leaves_ctx_pin_floating_on_timeout() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tdigitalRead_Parameters.invoked[CTX_PIN] == " << std::dec << static_cast(digitalRead_Parameters.invoked[CTX_PIN]) << ", EXPECTED: > 0" << std::endl; std::cout << "\tdigitalRead_Parameters.result[CTX_PIN].size() == " << std::dec << static_cast(digitalRead_Parameters.result[CTX_PIN].size()) << ", EXPECTED: 0" << std::endl; std::cout << "\tpinMode_Parameters.pin_mode[CTX_PIN][(pinMode_Parameters.invoked[CTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[CTX_PIN][(pinMode_Parameters.invoked[CTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(INPUT) << std::endl; @@ -552,7 +552,7 @@ int test_notetxn_arduino_start_floats_rtx_pin_on_timeout() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; std::cout << "\tdigitalRead_Parameters.invoked[CTX_PIN] == " << std::dec << static_cast(digitalRead_Parameters.invoked[CTX_PIN]) << ", EXPECTED: > 0" << std::endl; std::cout << "\tdigitalRead_Parameters.result[CTX_PIN].size() == " << std::dec << static_cast(digitalRead_Parameters.result[CTX_PIN].size()) << ", EXPECTED: 0" << std::endl; std::cout << "\tpinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(INPUT) << std::endl; @@ -587,7 +587,7 @@ int test_notetxn_arduino_stop_floats_rtx_pin() else { result = static_cast('t' + 'x' + 'n'); - std::cout << "FAILED] " << __FILE__ << ":" << __LINE__ << std::endl; + std::cout << "\33[31mFAILED\33[0m] " << __FILE__ << ":" << __LINE__ << std::endl; if (pinMode_Parameters.pin_mode.find(RTX_PIN) != pinMode_Parameters.pin_mode.end()) { std::cout << "\tpinMode_Parameters.invoked[RTX_PIN] == " << std::dec << static_cast(pinMode_Parameters.invoked[RTX_PIN]) << ", EXPECTED: > 0" << std::endl; std::cout << "\tpinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)] == 0x" << std::hex << static_cast(pinMode_Parameters.pin_mode[RTX_PIN][(pinMode_Parameters.invoked[RTX_PIN] - 1)]) << ", EXPECTED: 0x" << std::hex << static_cast(INPUT) << std::endl; diff --git a/test/mock/mock-arduino.cpp b/test/mock/mock-arduino.cpp index 5ae1522..1a66ead 100644 --- a/test/mock/mock-arduino.cpp +++ b/test/mock/mock-arduino.cpp @@ -8,6 +8,7 @@ PinMode_Parameters pinMode_Parameters; HardwareSerialAvailable_Parameters hardwareSerialAvailable_Parameters; HardwareSerialBegin_Parameters hardwareSerialBegin_Parameters; +HardwareSerialEnd_Parameters hardwareSerialEnd_Parameters; HardwareSerialFlush_Parameters hardwareSerialFlush_Parameters; HardwareSerialRead_Parameters hardwareSerialRead_Parameters; HardwareSerialWrite_Parameters hardwareSerialWrite_Parameters; @@ -122,6 +123,14 @@ HardwareSerial::begin ( hardwareSerialBegin_Parameters.baud = baud; } +void +HardwareSerial::end ( + void +) { + // Record invocation(s) + ++hardwareSerialEnd_Parameters.invoked; +} + void HardwareSerial::flush ( void diff --git a/test/mock/mock-arduino.hpp b/test/mock/mock-arduino.hpp index 0935b65..0eaa830 100644 --- a/test/mock/mock-arduino.hpp +++ b/test/mock/mock-arduino.hpp @@ -158,6 +158,7 @@ struct StreamPrint_Parameters { struct HardwareSerial : public Stream { unsigned int available (void); void begin(unsigned int baud); + void end(void); void flush(void); char read (void); size_t write(uint8_t * buffer, size_t size); @@ -185,7 +186,8 @@ struct HardwareSerialBegin_Parameters { HardwareSerialBegin_Parameters( void ) : - baud(0) + baud(0), + invoked(0) { } void reset ( @@ -194,8 +196,23 @@ struct HardwareSerialBegin_Parameters { invoked = 0; baud = 0; } - size_t invoked; unsigned int baud; + size_t invoked; +}; + +struct HardwareSerialEnd_Parameters { + HardwareSerialEnd_Parameters( + void + ) : + invoked(0) + { } + void + reset ( + void + ) { + invoked = 0; + } + size_t invoked; }; struct HardwareSerialFlush_Parameters { @@ -425,6 +442,7 @@ extern PinMode_Parameters pinMode_Parameters; extern HardwareSerial Serial; extern HardwareSerialAvailable_Parameters hardwareSerialAvailable_Parameters; extern HardwareSerialBegin_Parameters hardwareSerialBegin_Parameters; +extern HardwareSerialEnd_Parameters hardwareSerialEnd_Parameters; extern HardwareSerialFlush_Parameters hardwareSerialFlush_Parameters; extern HardwareSerialRead_Parameters hardwareSerialRead_Parameters; extern HardwareSerialWrite_Parameters hardwareSerialWrite_Parameters;