Skip to content

Commit

Permalink
test: conform to new implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
zfields committed Sep 29, 2023
1 parent 1eee868 commit 6448a5e
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.gcov
vgcore.*
*.tests
failed_test_run

.vscode/
build/
Expand Down
12 changes: 8 additions & 4 deletions src/NoteI2c_Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ NoteI2c_Arduino::receive (
transmission_error = _i2cPort.endTransmission();

switch (transmission_error) {
case 0:
// I2C transmission was successful
result = nullptr;
break;
case 1:
result = ERRSTR("i2c: data too long to fit in transmit buffer {io}",i2cerr);
break;
Expand All @@ -71,12 +75,12 @@ NoteI2c_Arduino::receive (
result = ERRSTR("i2c: unknown error encounter during I2C transmission {io}",i2cerr);
}

// Delay briefly ensuring that the Notecard can
// deliver the data in real-time to the I2C ISR
::delay(2);

// Read and cache response from Notecard
if (!transmission_error) {
// Delay briefly ensuring that the Notecard can
// deliver the data in real-time to the I2C ISR
::delay(2);

const int request_length = requested_byte_count_ + NoteI2c::REQUEST_HEADER_SIZE;
const int response_length = _i2cPort.requestFrom((int)device_address_, request_length);
if (!response_length) {
Expand Down
97 changes: 51 additions & 46 deletions test/NoteI2c_Arduino.test.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/NoteLog_Arduino.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <cassert>
#include <cstring>

// Compile command: g++ -Wall -Wextra -Wpedantic mock/mock-arduino.cpp ../src/NoteLog_Arduino.cpp NoteLog_Arduino.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK && ./a.out || echo "Tests Result: $?"
// Compile command: g++ -Wall -Wextra -Wpedantic mock/mock-arduino.cpp ../src/NoteLog_Arduino.cpp NoteLog_Arduino.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK -ggdb -O0 -o noteLog_arduino.tests && ./noteLog_arduino.tests || echo "Tests Result: $?"

int test_make_note_log_instantiates_notelog_object()
{
Expand Down
2 changes: 1 addition & 1 deletion test/NoteSerial_Arduino.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <cassert>
#include <cstring>

// Compile command: g++ -Wall -Wextra -Wpedantic mock/mock-arduino.cpp ../src/NoteSerial_Arduino.cpp NoteSerial_Arduino.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK && ./a.out || echo "Tests Result: $?"
// Compile command: g++ -Wall -Wextra -Wpedantic mock/mock-arduino.cpp ../src/NoteSerial_Arduino.cpp NoteSerial_Arduino.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK -ggdb -O0 -o noteSerial_arduino.tests && ./noteSerial_arduino.tests || echo "Tests Result: $?"

int test_make_note_serial_instantiates_noteserial_object()
{
Expand Down
2 changes: 1 addition & 1 deletion test/NoteTxn_Arduino.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <cassert>

// Compile command: g++ -std=c++11 -Wall -Wextra -Wpedantic mock/mock-arduino.cpp ../src/NoteTxn_Arduino.cpp NoteTxn_Arduino.test.cpp -I. -I../src -DNOTE_MOCK && ./a.out || echo "Tests Result: $?"
// Compile command: g++ -std=c++11 -Wall -Wextra -Wpedantic mock/mock-arduino.cpp ../src/NoteTxn_Arduino.cpp NoteTxn_Arduino.test.cpp -I. -I../src -DNOTE_MOCK -ggdb -O0 -o noteTxn_arduino.tests && ./noteTxn_arduino.tests || echo "Tests Result: $?"

int test_make_note_txn_instantiates_notetxn_object()
{
Expand Down
2 changes: 1 addition & 1 deletion test/Notecard.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "mock/NoteSerial_Mock.hpp"
#include "mock/NoteTxn_Mock.hpp"

// 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 mock/NoteTime_Mock.cpp mock/NoteTxn_Mock.cpp ../src/Notecard.cpp Notecard.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK -o notecard.tests && ./notecard.tests || echo "Tests Result: $?"
// 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 mock/NoteTime_Mock.cpp mock/NoteTxn_Mock.cpp ../src/Notecard.cpp Notecard.test.cpp -std=c++11 -I. -I../src -DNOTE_MOCK -ggdb -O0 -o notecard.tests && ./notecard.tests || echo "Tests Result: $?"

int test_notecard_begin_i2c_sets_user_agent_to_note_arduino()
{
Expand Down
3 changes: 3 additions & 0 deletions test/mock/mock-parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

#include "note-c/note.h"

#define NoteDebugWithLevel(...)
#define NoteDebugWithLevelLn(...)

#ifdef NoteDeleteResponse
#undef NoteDeleteResponse
#endif
Expand Down

0 comments on commit 6448a5e

Please sign in to comment.