43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
#include "unity.h"
|
|
#include "ntc_3950.c"
|
|
|
|
void setUp(void)
|
|
{
|
|
// 这里可以进行每个测试用例开始前的设置
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
// 这里可以进行每个测试用例结束后的清理
|
|
}
|
|
|
|
void test_ntc_lookup(void)
|
|
{
|
|
const uint32_t table[] = {8989000, 8242680, 7592960, 7021380, 6513750, 6059060};
|
|
TEST_ASSERT_EQUAL_UINT8(0, ntc_lookup(table, 8989000));
|
|
TEST_ASSERT_EQUAL_UINT8(1, ntc_lookup(table, 8242680));
|
|
TEST_ASSERT_EQUAL_UINT8(2, ntc_lookup(table, 7592960));
|
|
TEST_ASSERT_EQUAL_UINT8(3, ntc_lookup(table, 7021380));
|
|
TEST_ASSERT_EQUAL_UINT8(4, ntc_lookup(table, 6513750));
|
|
TEST_ASSERT_EQUAL_UINT8(5, ntc_lookup(table, 6059060));
|
|
}
|
|
|
|
void test_ntc_get_temp(void)
|
|
{
|
|
TEST_ASSERT_EQUAL_FLOAT(0.0, ntc_get_temp(4095).f);
|
|
TEST_ASSERT_EQUAL_FLOAT(-55.0, ntc_get_temp(0).f);
|
|
TEST_ASSERT_EQUAL_FLOAT(-54.9, ntc_get_temp(1).f);
|
|
TEST_ASSERT_EQUAL_FLOAT(-54.8, ntc_get_temp(2).f);
|
|
// Add more test cases here
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
UNITY_BEGIN();
|
|
|
|
RUN_TEST(test_ntc_lookup);
|
|
RUN_TEST(test_ntc_get_temp);
|
|
|
|
return UNITY_END();
|
|
}
|