From 713465fb416785c3a544e8626f85aca7e57dafa1 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 14 Feb 2016 20:07:51 +0200 Subject: Add some full round trip tests Mostly to ensure that the receive and send framing works the same way. Especially for the special case with 254 non-zeros. --- serial_link/tests/byte_stuffer_tests.c | 77 ++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'serial_link') diff --git a/serial_link/tests/byte_stuffer_tests.c b/serial_link/tests/byte_stuffer_tests.c index 8598cddd30..fbdf39e1b2 100644 --- a/serial_link/tests/byte_stuffer_tests.c +++ b/serial_link/tests/byte_stuffer_tests.c @@ -428,3 +428,80 @@ Ensure(ByteStuffer, sends_frame_with_254_non_zeroes_followed_by_zero) { assert_that(sent_data_size, is_equal_to(sizeof(expected))); assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected))); } + +Ensure(ByteStuffer, sends_and_receives_full_roundtrip_small_packet) { + uint8_t original_data[] = { 1, 2, 3}; + send_frame(original_data, sizeof(original_data)); + expect(recv_frame, + when(size, is_equal_to(sizeof(original_data))), + when(data, is_equal_to_contents_of(original_data, sizeof(original_data))) + ); + int i; + for(i=0;i