Refactor and reformat.

This commit is contained in:
2023-09-23 18:55:52 +01:00
parent 33f021fd54
commit 1905cb0d43
41 changed files with 1557 additions and 1462 deletions

View File

@@ -16,19 +16,19 @@
#define EXPECTED_FLETCHER16_63BYTES 0x1CA0
#define EXPECTED_FLETCHER16_2352BYTES 0x0AC5
static const uint8_t* buffer;
static const uint8_t* buffer_misaligned;
static const uint8_t *buffer;
static const uint8_t *buffer_misaligned;
class fletcher16Fixture : public ::testing::Test
{
public:
public:
fletcher16Fixture()
{
// initialization;
// can also be done in SetUp()
}
protected:
protected:
void SetUp()
{
char path[PATH_MAX];
@@ -37,18 +37,19 @@ class fletcher16Fixture : public ::testing::Test
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
FILE *file = fopen(filename, "rb");
buffer = (const uint8_t *)malloc(1048576);
fread((void *)buffer, 1, 1048576, file);
fclose(file);
buffer_misaligned = (const uint8_t*)malloc(1048577);
memcpy((void*)(buffer_misaligned + 1), buffer, 1048576);
buffer_misaligned = (const uint8_t *)malloc(1048577);
memcpy((void *)(buffer_misaligned + 1), buffer, 1048576);
}
void TearDown() {
free((void*)buffer);
free((void*)buffer_misaligned);
void TearDown()
{
free((void *)buffer);
free((void *)buffer_misaligned);
}
~fletcher16Fixture()
@@ -61,8 +62,8 @@ class fletcher16Fixture : public ::testing::Test
TEST_F(fletcher16Fixture, fletcher16_auto)
{
fletcher16_ctx* ctx = fletcher16_init();
uint16_t fletcher;
fletcher16_ctx *ctx = fletcher16_init();
uint16_t fletcher;
EXPECT_NE(ctx, nullptr);
@@ -74,12 +75,12 @@ TEST_F(fletcher16Fixture, fletcher16_auto)
TEST_F(fletcher16Fixture, fletcher16_auto_misaligned)
{
fletcher16_ctx* ctx = fletcher16_init();
uint16_t fletcher;
fletcher16_ctx *ctx = fletcher16_init();
uint16_t fletcher;
EXPECT_NE(ctx, nullptr);
fletcher16_update(ctx, buffer_misaligned+1, 1048576);
fletcher16_update(ctx, buffer_misaligned + 1, 1048576);
fletcher16_final(ctx, &fletcher);
EXPECT_EQ(fletcher, EXPECTED_FLETCHER16);
@@ -87,8 +88,8 @@ TEST_F(fletcher16Fixture, fletcher16_auto_misaligned)
TEST_F(fletcher16Fixture, fletcher16_auto_15bytes)
{
fletcher16_ctx* ctx = fletcher16_init();
uint16_t fletcher;
fletcher16_ctx *ctx = fletcher16_init();
uint16_t fletcher;
EXPECT_NE(ctx, nullptr);
@@ -100,8 +101,8 @@ TEST_F(fletcher16Fixture, fletcher16_auto_15bytes)
TEST_F(fletcher16Fixture, fletcher16_auto_31bytes)
{
fletcher16_ctx* ctx = fletcher16_init();
uint16_t fletcher;
fletcher16_ctx *ctx = fletcher16_init();
uint16_t fletcher;
EXPECT_NE(ctx, nullptr);
@@ -113,8 +114,8 @@ TEST_F(fletcher16Fixture, fletcher16_auto_31bytes)
TEST_F(fletcher16Fixture, fletcher16_auto_63bytes)
{
fletcher16_ctx* ctx = fletcher16_init();
uint16_t fletcher;
fletcher16_ctx *ctx = fletcher16_init();
uint16_t fletcher;
EXPECT_NE(ctx, nullptr);
@@ -126,8 +127,8 @@ TEST_F(fletcher16Fixture, fletcher16_auto_63bytes)
TEST_F(fletcher16Fixture, fletcher16_auto_2352bytes)
{
fletcher16_ctx* ctx = fletcher16_init();
uint16_t fletcher;
fletcher16_ctx *ctx = fletcher16_init();
uint16_t fletcher;
EXPECT_NE(ctx, nullptr);