diff options
Diffstat (limited to '02-usart/tests')
-rw-r--r-- | 02-usart/tests/test_dma.c | 2 | ||||
-rw-r--r-- | 02-usart/tests/test_lib.c | 19 | ||||
-rw-r--r-- | 02-usart/tests/test_memory.c | 12 | ||||
-rw-r--r-- | 02-usart/tests/test_usart.c | 20 |
4 files changed, 52 insertions, 1 deletions
diff --git a/02-usart/tests/test_dma.c b/02-usart/tests/test_dma.c index 7704590..ae34a69 100644 --- a/02-usart/tests/test_dma.c +++ b/02-usart/tests/test_dma.c @@ -1,5 +1,5 @@ #include "test_harness.h" -#include "dma.h" +#include "core/dma.h" #include <stdio.h> #include <stdlib.h> diff --git a/02-usart/tests/test_lib.c b/02-usart/tests/test_lib.c new file mode 100644 index 0000000..8d63577 --- /dev/null +++ b/02-usart/tests/test_lib.c @@ -0,0 +1,19 @@ +#include "test_harness.h" +#include "lib.h" + +TEST(lib, hexify) +{ + char buf[10]; + + hexify(0xaaaaaaaa, buf); + ASSERT_EQ_STR(buf, "AAAAAAAA"); + + hexify(0xdddddddd, buf); + ASSERT_EQ_STR(buf, "DDDDDDDD"); + + hexify(0x02468ace, buf); + ASSERT_EQ_STR(buf, "02468ACE"); + + hexify(0xdeadbeef, buf); + ASSERT_EQ_STR(buf, "DEADBEEF"); +} diff --git a/02-usart/tests/test_memory.c b/02-usart/tests/test_memory.c new file mode 100644 index 0000000..e62877a --- /dev/null +++ b/02-usart/tests/test_memory.c @@ -0,0 +1,12 @@ +#include "test_harness.c" +#include "memory.h" + +TEST(memory, memcpy) +{ + const char* from = "Hello"; + char to[16]; + + memcpy(to, from, 6); + + ASSERT_EQ_STR(to, from); +} diff --git a/02-usart/tests/test_usart.c b/02-usart/tests/test_usart.c new file mode 100644 index 0000000..e2cfdf8 --- /dev/null +++ b/02-usart/tests/test_usart.c @@ -0,0 +1,20 @@ +#include "test_harness.h" +#include "core/usart.h" + +#include <stdlib.h> + +TEST(usart, enable_dma) +{ + __IO usart_t* usart = &USART1; + + usart->c_r3 = 0; + + usart_enable_dma(usart, USART_ENABLE_TX); + ASSERT_EQ(usart->c_r3, 128); + + usart_enable_dma(usart, USART_ENABLE_RX); + ASSERT_EQ(usart->c_r3, 192); + + usart_enable_dma(usart, USART_ENABLE_DISABLED); + ASSERT_EQ(usart->c_r3, 0); +} |