u-boot/test/lib/test_crc8.c
Simon Glass b073d48e8d test: Drop the blank line before test macros
Most tests don't have this. It helps to keep the test declaration
clearly associated with the function it relates to, rather than the next
one in the file. Remove the extra blank line and mention this in the
docs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 18:51:49 -06:00

28 lines
762 B
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2023, Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
*
* Unit test for crc8
*/
#include <test/lib.h>
#include <test/ut.h>
#include <u-boot/crc.h>
static int lib_crc8(struct unit_test_state *uts) {
const char str[] = {0x20, 0xf4, 0xd8, 0x24, 0x6f, 0x41, 0x91, 0xae,
0x46, 0x61, 0xf6, 0x55, 0xeb, 0x38, 0x47, 0x0f,
0xec, 0xd8};
int actual1, actual2, actual3;
int expected1 = 0x47, expected2 = 0xea, expected3 = expected1;
actual1 = crc8(0, str, sizeof(str));
ut_asserteq(expected1, actual1);
actual2 = crc8(0, str, 7);
ut_asserteq(expected2, actual2);
actual3 = crc8(actual2, str + 7, sizeof(str) - 7);
ut_asserteq(expected3, actual3);
return 0;
}
LIB_TEST(lib_crc8, 0);