update fifo test

This commit is contained in:
hathach
2019-06-10 17:42:00 +07:00
parent a26430b90f
commit f3c2b9c2aa
5 changed files with 26 additions and 143 deletions

View File

@@ -6,10 +6,10 @@
# This sample, therefore, only demonstrates running a collection of unit tests.
:project:
:use_exceptions: FALSE
:use_exceptions: TRUE
:use_test_preprocessor: TRUE
:use_auxiliary_dependencies: TRUE
:build_root: build
:build_root: _build
# :release_build: TRUE
:test_file_prefix: test_
:which_ceedling: vendor/ceedling

View File

@@ -39,16 +39,14 @@ void tearDown(void)
{
}
//--------------------------------------------------------------------+
// Tests
//--------------------------------------------------------------------+
void test_normal(void)
{
uint8_t i;
for(uint8_t i=0; i < FIFO_SIZE; i++) tu_fifo_write(&ff, &i);
for(i=0; i < FIFO_SIZE; i++)
{
tu_fifo_write(&ff, &i);
}
for(i=0; i < FIFO_SIZE; i++)
for(uint8_t i=0; i < FIFO_SIZE; i++)
{
uint8_t c;
tu_fifo_read(&ff, &c);
@@ -56,6 +54,23 @@ void test_normal(void)
}
}
void test_peek(void)
{
uint8_t temp;
temp = 10; tu_fifo_write(&ff, &temp);
temp = 20; tu_fifo_write(&ff, &temp);
temp = 30; tu_fifo_write(&ff, &temp);
temp = 0;
tu_fifo_peek(&ff, &temp);
TEST_ASSERT_EQUAL(10, temp);
tu_fifo_peek_at(&ff, 1, &temp);
TEST_ASSERT_EQUAL(20, temp);
}
void test_empty(void)
{
uint8_t temp;
@@ -66,14 +81,9 @@ void test_empty(void)
void test_full(void)
{
uint8_t i;
TEST_ASSERT_FALSE(tu_fifo_full(&ff));
for(i=0; i < FIFO_SIZE; i++)
{
tu_fifo_write(&ff, &i);
}
for(uint8_t i=0; i < FIFO_SIZE; i++) tu_fifo_write(&ff, &i);
TEST_ASSERT_TRUE(tu_fifo_full(&ff));
}