Skip to content

Commit 88b1ad1

Browse files
nzmichaelhAnas Nashif
authored andcommitted
crc: add test vectors for the ANSI version.
The test cases match http://reveng.sourceforge.net/crc-catalogue/16.htm for CRC-16/DDS-110. Signed-off-by: Michael Hope <[email protected]>
1 parent acc0adb commit 88b1ad1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/unit/lib/crc/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ void test_crc16(void)
2020
zassert(crc16_ccitt(test2, sizeof(test2)) == 0xe5cc, "pass", "fail");
2121
}
2222

23+
void test_crc16_ansi(void)
24+
{
25+
u8_t test0[] = { };
26+
u8_t test1[] = { 'A' };
27+
u8_t test2[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
28+
29+
zassert(crc16_ansi(test0, sizeof(test0)) == 0x800d, "pass", "fail");
30+
zassert(crc16_ansi(test1, sizeof(test1)) == 0x8f85, "pass", "fail");
31+
zassert(crc16_ansi(test2, sizeof(test2)) == 0x9ecf, "pass", "fail");
32+
}
33+
2334
void test_crc8_ccitt(void)
2435
{
2536
u8_t test0[] = { 0 };
@@ -38,6 +49,7 @@ void test_main(void)
3849
{
3950
ztest_test_suite(test_crc,
4051
ztest_unit_test(test_crc16),
52+
ztest_unit_test(test_crc16_ansi),
4153
ztest_unit_test(test_crc8_ccitt));
4254
ztest_run_test_suite(test_crc);
4355
}

0 commit comments

Comments
 (0)