Add link parameter
This commit is contained in:
parent
419908e5ef
commit
5a1600e24f
8 changed files with 171 additions and 162 deletions
|
|
@ -26,11 +26,11 @@ SOFTWARE.
|
|||
#include <cgreen/mocks.h>
|
||||
#include "protocol/frame_validator.c"
|
||||
|
||||
void route_incoming_frame(uint8_t* data, uint16_t size) {
|
||||
void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size) {
|
||||
mock(data, size);
|
||||
}
|
||||
|
||||
void send_frame(uint8_t* data, uint16_t size) {
|
||||
void send_frame(uint8_t link, uint8_t* data, uint16_t size) {
|
||||
mock(data, size);
|
||||
}
|
||||
|
||||
|
|
@ -41,10 +41,10 @@ AfterEach(FrameValidator) {}
|
|||
Ensure(FrameValidator, doesnt_validate_frames_under_5_bytes) {
|
||||
never_expect(route_incoming_frame);
|
||||
uint8_t data[] = {1, 2};
|
||||
validator_recv_frame(0, 1);
|
||||
validator_recv_frame(data, 2);
|
||||
validator_recv_frame(data, 3);
|
||||
validator_recv_frame(data, 4);
|
||||
validator_recv_frame(0, 0, 1);
|
||||
validator_recv_frame(0, data, 2);
|
||||
validator_recv_frame(0, data, 3);
|
||||
validator_recv_frame(0, data, 4);
|
||||
}
|
||||
|
||||
Ensure(FrameValidator, validates_one_byte_frame_with_correct_crc) {
|
||||
|
|
@ -53,13 +53,13 @@ Ensure(FrameValidator, validates_one_byte_frame_with_correct_crc) {
|
|||
when(size, is_equal_to(1)),
|
||||
when(data, is_equal_to_contents_of(data, 1))
|
||||
);
|
||||
validator_recv_frame(data, 5);
|
||||
validator_recv_frame(0, data, 5);
|
||||
}
|
||||
|
||||
Ensure(FrameValidator, does_not_validate_one_byte_frame_with_incorrect_crc) {
|
||||
uint8_t data[] = {0x44, 0, 0, 0, 0};
|
||||
never_expect(route_incoming_frame);
|
||||
validator_recv_frame(data, 5);
|
||||
validator_recv_frame(1, data, 5);
|
||||
}
|
||||
|
||||
Ensure(FrameValidator, validates_four_byte_frame_with_correct_crc) {
|
||||
|
|
@ -68,7 +68,7 @@ Ensure(FrameValidator, validates_four_byte_frame_with_correct_crc) {
|
|||
when(size, is_equal_to(4)),
|
||||
when(data, is_equal_to_contents_of(data, 4))
|
||||
);
|
||||
validator_recv_frame(data, 8);
|
||||
validator_recv_frame(1, data, 8);
|
||||
}
|
||||
|
||||
Ensure(FrameValidator, validates_five_byte_frame_with_correct_crc) {
|
||||
|
|
@ -77,7 +77,7 @@ Ensure(FrameValidator, validates_five_byte_frame_with_correct_crc) {
|
|||
when(size, is_equal_to(5)),
|
||||
when(data, is_equal_to_contents_of(data, 5))
|
||||
);
|
||||
validator_recv_frame(data, 9);
|
||||
validator_recv_frame(0, data, 9);
|
||||
}
|
||||
|
||||
Ensure(FrameValidator, sends_one_byte_with_correct_crc) {
|
||||
|
|
@ -87,7 +87,7 @@ Ensure(FrameValidator, sends_one_byte_with_correct_crc) {
|
|||
when(size, is_equal_to(sizeof(expected))),
|
||||
when(data, is_equal_to_contents_of(expected, sizeof(expected)))
|
||||
);
|
||||
validator_send_frame(original, 1);
|
||||
validator_send_frame(0, original, 1);
|
||||
}
|
||||
|
||||
Ensure(FrameValidator, sends_five_bytes_with_correct_crc) {
|
||||
|
|
@ -97,5 +97,5 @@ Ensure(FrameValidator, sends_five_bytes_with_correct_crc) {
|
|||
when(size, is_equal_to(sizeof(expected))),
|
||||
when(data, is_equal_to_contents_of(expected, sizeof(expected)))
|
||||
);
|
||||
validator_send_frame(original, 5);
|
||||
validator_send_frame(0, original, 5);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue