99 lines
3.5 KiB
C
99 lines
3.5 KiB
C
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
|
|
|
/*=======Test Runner Used To Run Each Test Below=====*/
|
|
#define RUN_TEST(TestFunc, TestLineNum) \
|
|
{ \
|
|
Unity.CurrentTestName = #TestFunc; \
|
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
|
Unity.NumberOfTests++; \
|
|
if (TEST_PROTECT()) { \
|
|
setUp(); \
|
|
TestFunc(); \
|
|
} \
|
|
if (TEST_PROTECT()) { \
|
|
tearDown(); \
|
|
} \
|
|
UnityConcludeTest(); \
|
|
}
|
|
|
|
/*=======Automagically Detected Files To Include=====*/
|
|
#include "unity.h"
|
|
#include <setjmp.h>
|
|
#include <stdio.h>
|
|
|
|
/*======= Functions This Runner Calls=====*/
|
|
#include "Driver_GPIO.h"
|
|
|
|
void *gpio_A = NULL;
|
|
void *gpio_B = NULL;
|
|
|
|
void setUp(void)
|
|
{
|
|
/* This is run before EACH TEST */
|
|
gpio_A = GPIOA();
|
|
gpio_B = GPIOB();
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
}
|
|
|
|
void test_gpio_pointer_verify(void)
|
|
{
|
|
TEST_ASSERT_NOT_NULL(gpio_A);
|
|
}
|
|
|
|
void test_gpio_init_and_verify(void)
|
|
{
|
|
TEST_ASSERT_EQUAL(0, GPIO_Initialize(gpio_A, NULL, NULL));
|
|
}
|
|
|
|
void test_gpio_set_direction(void)
|
|
{
|
|
// 设置为输出
|
|
TEST_ASSERT_EQUAL(0, GPIO_SetDir(gpio_A, CSK_GPIO_PIN0, CSK_GPIO_DIR_OUTPUT));
|
|
// 设置为输入
|
|
TEST_ASSERT_EQUAL(0, GPIO_SetDir(gpio_A, CSK_GPIO_PIN0, CSK_GPIO_DIR_INPUT));
|
|
}
|
|
|
|
void test_gpio_write_operations(void)
|
|
{
|
|
// 设置为输出模式
|
|
TEST_ASSERT_EQUAL(0, GPIO_SetDir(gpio_A, CSK_GPIO_PIN0, CSK_GPIO_DIR_OUTPUT));
|
|
|
|
// 仅测试写操作是否成功,不测试回读值(平台不支持回读)
|
|
TEST_ASSERT_EQUAL(0, GPIO_PinWrite(gpio_A, CSK_GPIO_PIN0, 1));
|
|
TEST_ASSERT_EQUAL(0, GPIO_PinWrite(gpio_A, CSK_GPIO_PIN0, 0));
|
|
|
|
// 测试写入其他引脚
|
|
TEST_ASSERT_EQUAL(0, GPIO_PinWrite(gpio_A, CSK_GPIO_PIN1, 1));
|
|
TEST_ASSERT_EQUAL(0, GPIO_PinWrite(gpio_B, CSK_GPIO_PIN0, 1));
|
|
}
|
|
|
|
void test_gpio_uninitialize(void)
|
|
{
|
|
TEST_ASSERT_EQUAL(0, GPIO_Uninitialize(gpio_A));
|
|
TEST_ASSERT_EQUAL(0, GPIO_Uninitialize(gpio_B));
|
|
}
|
|
|
|
/*=======Test Reset Option=====*/
|
|
void resetTest(void);
|
|
void resetTest(void)
|
|
{
|
|
tearDown();
|
|
setUp();
|
|
}
|
|
|
|
/*=======MAIN=====*/
|
|
int main(void)
|
|
{
|
|
UnityBegin("test/derivers/gpio/test_gpio.c");
|
|
RUN_TEST(test_gpio_pointer_verify, 46);
|
|
RUN_TEST(test_gpio_init_and_verify, 51);
|
|
RUN_TEST(test_gpio_set_direction, 53);
|
|
RUN_TEST(test_gpio_write_operations, 58);
|
|
RUN_TEST(test_gpio_uninitialize, 64);
|
|
|
|
return (UnityEnd());
|
|
}
|