18 #include "test_Queue.h"
27 #define max_length_of_queue 5
35 void QueueInit_returns_a_pointer_to_a_Queue_struct(
void)
43 void QueueInit_memory_for_Queue_struct_is_allocated_in_Queue_object_file(
void)
55 void QueueInit_assigns_input_buffer_as_Queue_buffer(
void)
59 void QueueInit_size_input_is_the_maximum_Queue_length(
void)
63 void QueueInit_initializes_Queue_with_length_0(
void)
72 void QueueLength_increments_after_a_push(
void)
82 void QueueLength_does_not_increase_beyond_max_length(
void)
88 uint8_t bytes_pushed=0;
103 void QueueLength_decrements_after_a_pop(
void)
118 void QueueLength_does_not_decrease_below_zero(
void)
138 void QueuePush_writes_byte_to_Queue_buffer(
void)
148 void QueuePush_writes_next_byte_to_address_after_previous_write(
void)
159 void QueuePush_does_not_write_byte_if_Queue_is_full(
void)
165 uint8_t bytes_pushed=0;
185 void QueuePush_hits_end_of_buffer_and_wraps_around_if_Queue_is_not_full(
void)
191 uint8_t bytes_pushed=0;
202 uint8_t bytes_popped=0;
214 TEST_ASSERT_EQUAL_MESSAGE(
216 "Failed to overwrite byte 0! "
217 "Head should wrap around when it reaches the end of the array."
220 void QueuePop_removes_oldest_byte_from_Queue(
void)
232 TEST_ASSERT_EQUAL_UINT8(0xAB, byte_0);
238 TEST_ASSERT_EQUAL_UINT8(0xCD, byte_1);
240 void QueuePop_returns_oldest_byte(
void)
251 TEST_ASSERT_EQUAL_UINT8(0xAB, byte_0);
253 void QueuePop_does_not_remove_any_bytes_if_Queue_is_empty(
void)
261 TEST_ASSERT_EQUAL_UINT8(0,
QueuePop(SpiFifo));
270 TEST_ASSERT_EQUAL_UINT8(0x01,
QueuePop(SpiFifo));
272 TEST_ASSERT_EQUAL_UINT8(0,
QueuePop(SpiFifo));
274 void QueuePop_returns_0_if_Queue_is_empty(
void)
284 TEST_ASSERT_EQUAL_UINT8(0,
QueuePop(SpiFifo));
286 void QueuePop_hits_end_of_buffer_and_wraps_around_if_Queue_is_not_empty(
void)
293 uint8_t bytes_pushed=0;
304 uint8_t bytes_popped=0;
315 TEST_ASSERT_EQUAL_MESSAGE(
317 "Failed to overwrite byte 0! "
318 "Head should wrap around when it reaches the end of the array."
324 TEST_ASSERT_EQUAL_UINT8(33,
QueuePop(SpiFifo));
326 void QueueIsFull_returns_true_if_Queue_is_full(
void)
332 uint16_t bytes_pushed = 0;
343 void QueueIsFull_returns_false_if_Queue_is_not_full(
void)
349 uint8_t bytes_pushed=0;
350 while(bytes_pushed < underfilled)
356 TEST_ASSERT_EQUAL_UINT16(underfilled,
QueueLength(SpiFifo));
360 void QueueIsEmpty_returns_true_if_Queue_is_empty(
void)
370 void QueueIsEmpty_returns_false_if_Queue_is_not_empty(
void)
uint8_t QueuePop(volatile Queue_s *SpiFifo)
uint16_t QueueLength(volatile Queue_s *pq)
bool QueueIsFull(volatile Queue_s *SpiFifo)
void QueuePush(volatile Queue_s *SpiFifo, uint8_t data_to_push)
volatile Queue_s * QueueInit(volatile uint8_t *buffer, uint16_t const buffer_size_in_bytes)
bool QueueIsEmpty(volatile Queue_s *SpiFifo)
Queue uses a byte array as a circular buffer.
#define max_length_of_queue
Maximum size of the Queue's FIFO buffer is 24 bytes.
volatile uint8_t spi_rx_buffer[max_length_of_queue]
Allocate static memory for the Queue's FIFO buffer.