mirror of
https://github.com/nqtronix/fifofast.git
synced 2026-02-06 00:52:43 +08:00
Add test case for '_write_multiple()' with overflow + rename
This commit is contained in:
@@ -40,7 +40,7 @@ int main(void)
|
||||
fifofast_test_macro_remove_lite(0x50);
|
||||
fifofast_test_macro_remove(0x60);
|
||||
fifofast_test_macro_rebase(0x70);
|
||||
fifofast_test_macro_multiple_write(0x80);
|
||||
fifofast_test_macro_write_multiple(0x80);
|
||||
|
||||
fifofast_test_func_initial((fff_proto_t*)&fifo_uint8p);
|
||||
fifofast_test_func_write((fff_proto_t*)&fifo_uint8p, 0x80);
|
||||
|
||||
@@ -374,31 +374,46 @@ void fifofast_test_macro_rebase(uint8_t startvalue)
|
||||
_fff_reset(fifo_uint8);
|
||||
}
|
||||
|
||||
void fifofast_test_macro_multiple_write(uint8_t startvalue) {
|
||||
uint8_t multidata[3] = {startvalue + 3, startvalue + 4, startvalue + 5};
|
||||
void fifofast_test_macro_write_multiple(uint8_t startvalue) {
|
||||
uint8_t multidata[4] = {startvalue + 3, startvalue + 4, startvalue + 5, startvalue + 6};
|
||||
|
||||
// initialize fifo with some data
|
||||
_fff_write_lite(fifo_uint8, startvalue+0);
|
||||
_fff_write_lite(fifo_uint8, startvalue+1);
|
||||
_fff_write_lite(fifo_uint8, startvalue+2);
|
||||
|
||||
_fff_remove_lite(fifo_uint8, 2);
|
||||
|
||||
// write test data, case: all data fits
|
||||
_fff_write_multiple(fifo_uint8, multidata, 3);
|
||||
|
||||
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 0) == startvalue+2);
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 1) == startvalue+3);
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 2) == startvalue+4);
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 3) == startvalue+5);
|
||||
|
||||
|
||||
UT_ASSERT(_fff_mem_level(fifo_uint8) == 4);
|
||||
UT_ASSERT(_fff_mem_free(fifo_uint8) == 0);
|
||||
UT_ASSERT(_fff_is_empty(fifo_uint8) == 0);
|
||||
UT_ASSERT(_fff_is_full(fifo_uint8) == 1);
|
||||
|
||||
|
||||
_fff_reset(fifo_uint8);
|
||||
|
||||
// re-initialize fifo with some data
|
||||
_fff_write_lite(fifo_uint8, startvalue+7);
|
||||
_fff_write_multiple(fifo_uint8, multidata, 3);
|
||||
|
||||
// write test data, case: NOT all data fits (overflow is discarded)
|
||||
_fff_write_multiple(fifo_uint8, multidata, 4);
|
||||
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 0) == startvalue+7);
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 1) == startvalue+3);
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 2) == startvalue+4);
|
||||
UT_ASSERT(_fff_peek(fifo_uint8, 3) == startvalue+5);
|
||||
|
||||
UT_ASSERT(_fff_mem_level(fifo_uint8) == 4);
|
||||
UT_ASSERT(_fff_mem_free(fifo_uint8) == 0);
|
||||
UT_ASSERT(_fff_is_empty(fifo_uint8) == 0);
|
||||
UT_ASSERT(_fff_is_full(fifo_uint8) == 1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -27,7 +27,7 @@ void fifofast_test_macro_add(uint8_t startvalue);
|
||||
void fifofast_test_macro_remove_lite(uint8_t startvalue);
|
||||
void fifofast_test_macro_remove(uint8_t startvalue);
|
||||
void fifofast_test_macro_rebase(uint8_t startvalue);
|
||||
void fifofast_test_macro_multiple_write(uint8_t startvalue);
|
||||
void fifofast_test_macro_write_multiple(uint8_t startvalue);
|
||||
|
||||
void fifofast_test_func_initial(fff_proto_t* fifo);
|
||||
void fifofast_test_func_write(fff_proto_t* fifo, uint8_t startvalue);
|
||||
|
||||
Reference in New Issue
Block a user