summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-01-16 13:25:02 +0700
committerhathach <[email protected]>2013-01-16 13:25:02 +0700
commit8155fd38a580603af60bc91fa54197b08ce68464 (patch)
tree98db374db9fbd50201fd690436cce88fd2363917 /tests
parentc004cd438724063007eec0f43a4681e84a839252 (diff)
added some tests for fifo.c
Diffstat (limited to 'tests')
-rw-r--r--tests/project.yml5
-rw-r--r--tests/test/test_fifo.c48
2 files changed, 49 insertions, 4 deletions
diff --git a/tests/project.yml b/tests/project.yml
index 10885baca..f45531096 100644
--- a/tests/project.yml
+++ b/tests/project.yml
@@ -32,6 +32,7 @@
- ../tinyusb/**
- -:../demos
- -:../test_old
+ - ../../CMSISv2p10_LPC13Uxx/**
#- ../../CMSISv2p10_LPC43xx_DriverLib/inc
:support:
- test/support
@@ -44,12 +45,12 @@
:test:
- *common_defines
- _TEST_
- - MCU=MCU_LPC43XX
+ - MCU=MCU_LPC13UXX
- CORE_M4
:test_preprocess:
- *common_defines
- _TEST_
- - MCU=MCU_LPC43XX
+ - MCU=MCU_LPC13UXX
- CORE_M4
#:flags:
diff --git a/tests/test/test_fifo.c b/tests/test/test_fifo.c
index edc76783b..5741d6bcb 100644
--- a/tests/test/test_fifo.c
+++ b/tests/test/test_fifo.c
@@ -38,16 +38,60 @@
#include "unity.h"
#include "fifo.h"
+#define FIFO_SIZE 10
+static fifo_t ff;
+static uint8_t buffer[FIFO_SIZE];
+
void setUp(void)
{
+ fifo_init(&ff, buffer, FIFO_SIZE, 0, 0);
}
void tearDown(void)
{
+ memset(&ff, 0, sizeof(fifo_t));
+}
+void test_create_null(void)
+{
+ memset(&ff, 0, sizeof(fifo_t)); // clear fifo to test null created
+ TEST_ASSERT_FALSE( fifo_init(&ff, buffer, 0, 0, 0) );
+ TEST_ASSERT_TRUE( fifo_init(&ff, buffer, 1, 0, 0) );
}
-void test_()
+void test_normal(void)
{
- TEST_IGNORE();
+ uint8_t i;
+
+ for(i=0; i < FIFO_SIZE; i++)
+ {
+ fifo_write(&ff, i);
+ }
+
+ for(i=0; i < FIFO_SIZE; i++)
+ {
+ uint8_t c;
+ fifo_read(&ff, &c);
+ TEST_ASSERT_EQUAL(i, c);
+ }
}
+void test_is_empty(void)
+{
+ TEST_ASSERT_TRUE(fifo_isEmpty(&ff));
+ fifo_write(&ff, 1);
+ TEST_ASSERT_FALSE(fifo_isEmpty(&ff));
+}
+
+void test_is_full(void)
+{
+ uint8_t i;
+
+ TEST_ASSERT_FALSE(fifo_isFull(&ff));
+
+ for(i=0; i < FIFO_SIZE; i++)
+ {
+ fifo_write(&ff, i);
+ }
+
+ TEST_ASSERT_TRUE(fifo_isFull(&ff));
+}