mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
41bdcd4aed
* Update logging * Remove duplicate code * Update unit tests * Clean up includes * Merge ProtobufSerializer into protobuf_util namespace * Precompile regex * Add const * Add Split() convenience method, update log level/ID parsing * Move log.h to legacy folder * Elimininate gotos * Fixes for gcc 13 * Update compiler flags * Update default folder handling * Use references instead of pointers * Move code for better encapsulation * Move code * Remove unused method argument * Move device logger * Remove redundant to_string * Rename for consistency * Update handling of protobuf pointers * Simplify protobuf usage * Memory handling update * Add hasher
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2022-2023 Uwe Seimet
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#include "mocks.h"
|
|
#include <net/ethernet.h>
|
|
#include "devices/ctapdriver.h"
|
|
|
|
TEST(CTapDriverTest, Crc32)
|
|
{
|
|
array<uint8_t, ETH_FRAME_LEN> buf;
|
|
|
|
buf.fill(0x00);
|
|
EXPECT_EQ(0xe3d887bb, CTapDriver::Crc32(span(buf.data(), ETH_FRAME_LEN)));
|
|
|
|
buf.fill(0xff);
|
|
EXPECT_EQ(0x814765f4, CTapDriver::Crc32(span(buf.data(), ETH_FRAME_LEN)));
|
|
|
|
buf.fill(0x10);
|
|
EXPECT_EQ(0xb7288Cd3, CTapDriver::Crc32(span(buf.data(), ETH_FRAME_LEN)));
|
|
|
|
buf.fill(0x7f);
|
|
EXPECT_EQ(0x4b543477, CTapDriver::Crc32(span(buf.data(), ETH_FRAME_LEN)));
|
|
|
|
buf.fill(0x80);
|
|
EXPECT_EQ(0x29cbd638, CTapDriver::Crc32(span(buf.data(), ETH_FRAME_LEN)));
|
|
|
|
for (size_t i = 0; i < buf.size(); i++) {
|
|
buf[i] = (uint8_t)i;
|
|
}
|
|
EXPECT_EQ(0xe7870705, CTapDriver::Crc32(span(buf.data(), ETH_FRAME_LEN)));
|
|
|
|
for (size_t i = buf.size() - 1; i > 0; i--) {
|
|
buf[i] = (uint8_t)i;
|
|
}
|
|
EXPECT_EQ(0xe7870705, CTapDriver::Crc32(span(buf.data(), ETH_FRAME_LEN)));
|
|
}
|