Files
DTU-HMI/tests/test_p0_utf8_hz12_get.c

44 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* -------------------------------------------------------------------------
* 文件名: test_p0_utf8_hz12_get.c
* 作用:
* 验证中文点阵查询接口 utf8_hz12_get() 的基础行为是否正确。
*
* 被测接口:
* const uint8_t* utf8_hz12_get(uint32_t unicode);
*
* 测试目标:
* 1) 对于字库中存在的码点,应返回非 NULL 位图指针。
* 2) 对于字库范围外或不存在的码点,应返回 NULL。
*
* 说明:
* - 本测试只校验“是否命中”这一契约,不校验位图内容本身。
* - 若后续需要,可新增逐字节位图校验测试。
* ------------------------------------------------------------------------- */
#include "../src/Drv/lcd/ascii.h"
#include "test_common.h"
/* -------------------------------------------------------------------------
* 测试入口:
* 按“命中/低位未命中/高位未命中”三个场景依次断言。
*
* 返回值约定:
* 0 -> 测试通过
* 非0 -> 断言失败(由 ASSERT_* 宏返回)
* ------------------------------------------------------------------------- */
int main(void)
{
/* 命中用例U+4F60“你”通常在当前字库中存在 */
const uint8_t* hit = utf8_hz12_get(0x4F60u); /* 你 */
/* 低位未命中:非常低的控制区码点,预期不在中文字库 */
const uint8_t* miss_low = utf8_hz12_get(0x0001u);
/* 高位未命中:超高码点,预期不在当前 12 点阵中文表中 */
const uint8_t* miss_high = utf8_hz12_get(0x10FFFFu);
/* 命中必须返回有效指针 */
ASSERT_TRUE(hit != NULL);
/* 非命中必须返回 NULL */
ASSERT_TRUE(miss_low == NULL);
ASSERT_TRUE(miss_high == NULL);
return 0;
}