diff options
| author | hathach <[email protected]> | 2019-06-10 17:42:00 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-06-10 17:42:00 +0700 |
| commit | f3c2b9c2aab11487d79c3592c2a2137a2fc4e7fe (patch) | |
| tree | b3068bbfd5053bf2215b70825b9239836332298b /test | |
| parent | a26430b90fda9679c22ce87d728cd23201a0f76f (diff) | |
update fifo test
Diffstat (limited to 'test')
| -rw-r--r-- | test/project.yml | 4 | ||||
| -rw-r--r-- | test/test/test_fifo.c | 36 |
2 files changed, 25 insertions, 15 deletions
diff --git a/test/project.yml b/test/project.yml index 311a672d5..403aa0119 100644 --- a/test/project.yml +++ b/test/project.yml @@ -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 diff --git a/test/test/test_fifo.c b/test/test/test_fifo.c index f34f9d1bb..2cb8ada91 100644 --- a/test/test/test_fifo.c +++ b/test/test/test_fifo.c @@ -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)); } |
