|
9 | 9 | #include "../../../lib/os/crc8_sw.c" |
10 | 10 | #include "../../../lib/os/crc16_sw.c" |
11 | 11 | #include "../../../lib/os/crc32_sw.c" |
| 12 | +#include "../../../lib/os/crc32c_sw.c" |
12 | 13 | #include "../../../lib/os/crc7_sw.c" |
13 | 14 |
|
| 15 | +void test_crc32c(void) |
| 16 | +{ |
| 17 | + uint8_t test1[] = { 'A' }; |
| 18 | + uint8_t test2[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' }; |
| 19 | + uint8_t test3[] = { 'Z', 'e', 'p', 'h', 'y', 'r' }; |
| 20 | + |
| 21 | + /* Single streams */ |
| 22 | + zassert_equal(crc32_c(0, test1, sizeof(test1), true, true), |
| 23 | + 0xE16DCDEE, NULL); |
| 24 | + zassert_equal(crc32_c(0, test2, sizeof(test2), true, true), |
| 25 | + 0xE3069283, NULL); |
| 26 | + zassert_equal(crc32_c(0, test3, sizeof(test3), true, true), |
| 27 | + 0xFCDEB58D, NULL); |
| 28 | + |
| 29 | + /* Continuous streams - test1, test2 and test3 are considered part |
| 30 | + * of one big stream whose CRC needs to be calculated. Note that the |
| 31 | + * CRC of the first string is passed over to the second crc calculation, |
| 32 | + * second to third and so on. |
| 33 | + */ |
| 34 | + zassert_equal(crc32_c(0, test1, sizeof(test1), true, false), |
| 35 | + 0x1E923211, NULL); |
| 36 | + zassert_equal(crc32_c(0x1E923211, test2, sizeof(test2), false, false), |
| 37 | + 0xB2983B83, NULL); |
| 38 | + zassert_equal(crc32_c(0xB2983B83, test3, sizeof(test3), false, true), |
| 39 | + 0x7D4F9D21, NULL); |
| 40 | +} |
14 | 41 |
|
15 | 42 | void test_crc32_ieee(void) |
16 | 43 | { |
@@ -205,6 +232,7 @@ void test_crc8(void) |
205 | 232 | void test_main(void) |
206 | 233 | { |
207 | 234 | ztest_test_suite(test_crc, |
| 235 | + ztest_unit_test(test_crc32c), |
208 | 236 | ztest_unit_test(test_crc32_ieee), |
209 | 237 | ztest_unit_test(test_crc16), |
210 | 238 | ztest_unit_test(test_crc16_ansi), |
|
0 commit comments