add test
minor changes
This commit is contained in:
@@ -10,12 +10,12 @@ set(INCLUDE_DIRS
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
# ../../oled/oled.c
|
||||
# ../../oled/connection.c
|
||||
# ../../oled/ssd1306/ssd1306.c
|
||||
# ../../oled/sh1106/sh1106.c
|
||||
../../oled/oled.c
|
||||
../../oled/connection.c
|
||||
../../oled/ssd1306/ssd1306.c
|
||||
../../oled/sh1106/sh1106.c
|
||||
|
||||
# helpers/src/mock_i2c.c
|
||||
helpers/src/mock_i2c.c
|
||||
oled_test.c
|
||||
)
|
||||
|
||||
|
||||
@@ -1,18 +1,41 @@
|
||||
#include "stdlib.h"
|
||||
#include "unity.h"
|
||||
#include "oled.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
OLED_HandleTypeDef* display;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
// uint32_t size = sizeof(OLED_HandleTypeDef);
|
||||
// printf("size in B: %u\n", size);
|
||||
display = (OLED_HandleTypeDef*)malloc(sizeof(OLED_HandleTypeDef));
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
free(display);
|
||||
}
|
||||
|
||||
void test_one(void)
|
||||
void test_configWithCorecctArgs(void)
|
||||
{
|
||||
TEST_FAIL();
|
||||
HAL_StatusTypeDef status = oled_Config(display, 0x0F, 128, 64, SH1106);
|
||||
|
||||
TEST_ASSERT_EQUAL(status, HAL_OK);
|
||||
TEST_ASSERT_NULL(display->hi2c);
|
||||
TEST_ASSERT_EQUAL(display->OledType, SH1106);
|
||||
TEST_ASSERT_EQUAL_HEX8(display->DevAddress, 0x0F);
|
||||
TEST_ASSERT_EQUAL(display->Width, 128);
|
||||
TEST_ASSERT_EQUAL(display->Height, 64);
|
||||
TEST_ASSERT_EQUAL(display->BufSize, 128*64/8);
|
||||
TEST_ASSERT_NOT_NULL(display->Buffer);
|
||||
}
|
||||
|
||||
void test_configWithoutPointerToDisplay(void)
|
||||
{
|
||||
HAL_StatusTypeDef status = oled_Config(NULL, 0x0F, 128, 64, SH1106);
|
||||
|
||||
TEST_ASSERT_EQUAL(status, HAL_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +43,8 @@ void test_one(void)
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_one);
|
||||
RUN_TEST(test_configWithCorecctArgs);
|
||||
RUN_TEST(test_configWithoutPointerToDisplay);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
Reference in New Issue
Block a user