50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
#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_configWithCorecctArgs(void)
|
|
{
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
{
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_configWithCorecctArgs);
|
|
RUN_TEST(test_configWithoutPointerToDisplay);
|
|
|
|
return UNITY_END();
|
|
} |