diff --git a/.gitignore b/.gitignore index e4a39ebd..d239f93b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ html latex +test/_build test_old -tests/build *.d *.o *.P @@ -13,6 +13,4 @@ tests/build *.elf *.ind .env -/tests/lpc175x_6x/build/ -/tests/lpc18xx_43xx/build/ /examples/*/*/build-* diff --git a/test/project.yml b/test/project.yml index 311a672d..403aa011 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 f34f9d1b..2cb8ada9 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)); } diff --git a/tests_obsolete/lpc18xx_43xx/test/test_fifo.c b/tests_obsolete/lpc18xx_43xx/test/test_fifo.c deleted file mode 100644 index 311f6f6d..00000000 --- a/tests_obsolete/lpc18xx_43xx/test/test_fifo.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "unity.h" -#include "fifo.h" - -#define FIFO_SIZE 10 -TU_FIFO_DEF(ff, FIFO_SIZE, uint8_t, false); - -void setUp(void) -{ - tu_fifo_clear(&ff); -} - -void tearDown(void) -{ -} - -void test_normal(void) -{ - uint8_t i; - - for(i=0; i < FIFO_SIZE; i++) - { - tu_fifo_write(&ff, &i); - } - - for(i=0; i < FIFO_SIZE; i++) - { - uint8_t c; - tu_fifo_read(&ff, &c); - TEST_ASSERT_EQUAL(i, c); - } -} - -void test_is_empty(void) -{ - uint8_t temp; - TEST_ASSERT_TRUE(tu_fifo_is_empty(&ff)); - tu_fifo_write(&ff, &temp); - TEST_ASSERT_FALSE(tu_fifo_is_empty(&ff)); -} - -void test_is_full(void) -{ - uint8_t i; - - TEST_ASSERT_FALSE(tu_fifo_is_full(&ff)); - - for(i=0; i < FIFO_SIZE; i++) - { - tu_fifo_write(&ff, &i); - } - - TEST_ASSERT_TRUE(tu_fifo_is_full(&ff)); -} diff --git a/tests_obsolete/lpc18xx_43xx/test/test_project_settings.c b/tests_obsolete/lpc18xx_43xx/test/test_project_settings.c deleted file mode 100644 index 60d9b684..00000000 --- a/tests_obsolete/lpc18xx_43xx/test/test_project_settings.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "unity.h" -#include "common.h" -#include "tusb_option.h" - -#define LATEST_VERSION "00.00" -#define LATEST_VERSION_NAME "alpha" - -void setUp(void) -{ -} - -void tearDown(void) -{ -} - -void test_latest_version(void) -{ - TEST_ASSERT_EQUAL_STRING(LATEST_VERSION, TUSB_VERSION); - TEST_ASSERT_EQUAL_STRING(LATEST_VERSION_NAME, TUSB_VERSION_NAME); -}