mirror of
https://github.com/aaru-dps/Aaru.Checksums.Native.git
synced 2025-12-16 19:24:29 +00:00
Refactor and reformat.
This commit is contained in:
@@ -16,19 +16,19 @@
|
||||
#define EXPECTED_ADLER32_63BYTES 0xD8AC2081
|
||||
#define EXPECTED_ADLER32_2352BYTES 0xECD1738B
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class adler32Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
adler32Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -37,18 +37,19 @@ class adler32Fixture : 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);
|
||||
}
|
||||
|
||||
~adler32Fixture()
|
||||
@@ -61,8 +62,8 @@ class adler32Fixture : public ::testing::Test
|
||||
|
||||
TEST_F(adler32Fixture, adler32_auto)
|
||||
{
|
||||
adler32_ctx* ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
adler32_ctx *ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -90,12 +91,12 @@ TEST_F(adler32Fixture, adler32_slicing)
|
||||
|
||||
TEST_F(adler32Fixture, adler32_auto_misaligned)
|
||||
{
|
||||
adler32_ctx* ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
adler32_ctx *ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
adler32_update(ctx, buffer_misaligned+1, 1048576);
|
||||
adler32_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
adler32_final(ctx, &adler32);
|
||||
|
||||
EXPECT_EQ(adler32, EXPECTED_ADLER32);
|
||||
@@ -110,7 +111,7 @@ TEST_F(adler32Fixture, adler32_slicing_misaligned)
|
||||
sum1 = 1;
|
||||
sum2 = 0;
|
||||
|
||||
adler32_slicing(&sum1, &sum2, buffer_misaligned+1, 1048576);
|
||||
adler32_slicing(&sum1, &sum2, buffer_misaligned + 1, 1048576);
|
||||
|
||||
adler32 = (sum2 << 16) | sum1;
|
||||
|
||||
@@ -119,8 +120,8 @@ TEST_F(adler32Fixture, adler32_slicing_misaligned)
|
||||
|
||||
TEST_F(adler32Fixture, adler32_auto_15bytes)
|
||||
{
|
||||
adler32_ctx* ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
adler32_ctx *ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -148,8 +149,8 @@ TEST_F(adler32Fixture, adler32_slicing_15bytes)
|
||||
|
||||
TEST_F(adler32Fixture, adler32_auto_31bytes)
|
||||
{
|
||||
adler32_ctx* ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
adler32_ctx *ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -177,8 +178,8 @@ TEST_F(adler32Fixture, adler32_slicing_31bytes)
|
||||
|
||||
TEST_F(adler32Fixture, adler32_auto_63bytes)
|
||||
{
|
||||
adler32_ctx* ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
adler32_ctx *ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -206,8 +207,8 @@ TEST_F(adler32Fixture, adler32_slicing_63bytes)
|
||||
|
||||
TEST_F(adler32Fixture, adler32_auto_2352bytes)
|
||||
{
|
||||
adler32_ctx* ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
adler32_ctx *ctx = adler32_init();
|
||||
uint32_t adler32;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -263,7 +264,7 @@ TEST_F(adler32Fixture, adler32_neon_misaligned)
|
||||
sum1 = 1;
|
||||
sum2 = 0;
|
||||
|
||||
adler32_neon(&sum1, &sum2, buffer_misaligned+1, 1048576);
|
||||
adler32_neon(&sum1, &sum2, buffer_misaligned + 1, 1048576);
|
||||
|
||||
adler32 = (sum2 << 16) | sum1;
|
||||
|
||||
@@ -341,9 +342,10 @@ TEST_F(adler32Fixture, adler32_neon_2352bytes)
|
||||
|
||||
EXPECT_EQ(adler32, EXPECTED_ADLER32_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
|
||||
TEST_F(adler32Fixture, adler32_avx2)
|
||||
@@ -393,7 +395,7 @@ TEST_F(adler32Fixture, adler32_avx2_misaligned)
|
||||
sum1 = 1;
|
||||
sum2 = 0;
|
||||
|
||||
adler32_avx2(&sum1, &sum2, buffer_misaligned+1, 1048576);
|
||||
adler32_avx2(&sum1, &sum2, buffer_misaligned + 1, 1048576);
|
||||
|
||||
adler32 = (sum2 << 16) | sum1;
|
||||
|
||||
@@ -411,7 +413,7 @@ TEST_F(adler32Fixture, adler32_ssse3_misaligned)
|
||||
sum1 = 1;
|
||||
sum2 = 0;
|
||||
|
||||
adler32_ssse3(&sum1, &sum2, buffer_misaligned+1, 1048576);
|
||||
adler32_ssse3(&sum1, &sum2, buffer_misaligned + 1, 1048576);
|
||||
|
||||
adler32 = (sum2 << 16) | sum1;
|
||||
|
||||
@@ -561,4 +563,5 @@ TEST_F(adler32Fixture, adler32_ssse3_2352bytes)
|
||||
|
||||
EXPECT_EQ(adler32, EXPECTED_ADLER32_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
#define EXPECTED_CRC16_63BYTES 0xFBD9
|
||||
#define EXPECTED_CRC16_2352BYTES 0x23F4
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class crc16Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
crc16Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -37,18 +37,19 @@ class crc16Fixture : 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);
|
||||
}
|
||||
|
||||
~crc16Fixture()
|
||||
@@ -61,8 +62,8 @@ class crc16Fixture : public ::testing::Test
|
||||
|
||||
TEST_F(crc16Fixture, crc16_auto)
|
||||
{
|
||||
crc16_ctx* ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
crc16_ctx *ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -74,12 +75,12 @@ TEST_F(crc16Fixture, crc16_auto)
|
||||
|
||||
TEST_F(crc16Fixture, crc16_auto_misaligned)
|
||||
{
|
||||
crc16_ctx* ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
crc16_ctx *ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
crc16_update(ctx, buffer_misaligned+1, 1048576);
|
||||
crc16_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
crc16_final(ctx, &crc);
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC16);
|
||||
@@ -87,8 +88,8 @@ TEST_F(crc16Fixture, crc16_auto_misaligned)
|
||||
|
||||
TEST_F(crc16Fixture, crc16_auto_15bytes)
|
||||
{
|
||||
crc16_ctx* ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
crc16_ctx *ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -100,8 +101,8 @@ TEST_F(crc16Fixture, crc16_auto_15bytes)
|
||||
|
||||
TEST_F(crc16Fixture, crc16_auto_31bytes)
|
||||
{
|
||||
crc16_ctx* ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
crc16_ctx *ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -113,8 +114,8 @@ TEST_F(crc16Fixture, crc16_auto_31bytes)
|
||||
|
||||
TEST_F(crc16Fixture, crc16_auto_63bytes)
|
||||
{
|
||||
crc16_ctx* ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
crc16_ctx *ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -126,8 +127,8 @@ TEST_F(crc16Fixture, crc16_auto_63bytes)
|
||||
|
||||
TEST_F(crc16Fixture, crc16_auto_2352bytes)
|
||||
{
|
||||
crc16_ctx* ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
crc16_ctx *ctx = crc16_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
#define EXPECTED_CRC16_CCITT_63BYTES 0x73c4
|
||||
#define EXPECTED_CRC16_CCITT_2352BYTES 0x1946
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class crc16_ccittFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
crc16_ccittFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -37,18 +37,19 @@ class crc16_ccittFixture : 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);
|
||||
}
|
||||
|
||||
~crc16_ccittFixture()
|
||||
@@ -61,8 +62,8 @@ class crc16_ccittFixture : public ::testing::Test
|
||||
|
||||
TEST_F(crc16_ccittFixture, crc16_ccitt_auto)
|
||||
{
|
||||
crc16_ccitt_ctx* ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
crc16_ccitt_ctx *ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -74,12 +75,12 @@ TEST_F(crc16_ccittFixture, crc16_ccitt_auto)
|
||||
|
||||
TEST_F(crc16_ccittFixture, crc16_ccitt_auto_misaligned)
|
||||
{
|
||||
crc16_ccitt_ctx* ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
crc16_ccitt_ctx *ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
crc16_ccitt_update(ctx, buffer_misaligned+1, 1048576);
|
||||
crc16_ccitt_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
crc16_ccitt_final(ctx, &crc);
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC16_CCITT);
|
||||
@@ -87,8 +88,8 @@ TEST_F(crc16_ccittFixture, crc16_ccitt_auto_misaligned)
|
||||
|
||||
TEST_F(crc16_ccittFixture, crc16_ccitt_auto_15bytes)
|
||||
{
|
||||
crc16_ccitt_ctx* ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
crc16_ccitt_ctx *ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -100,8 +101,8 @@ TEST_F(crc16_ccittFixture, crc16_ccitt_auto_15bytes)
|
||||
|
||||
TEST_F(crc16_ccittFixture, crc16_ccitt_auto_31bytes)
|
||||
{
|
||||
crc16_ccitt_ctx* ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
crc16_ccitt_ctx *ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -113,8 +114,8 @@ TEST_F(crc16_ccittFixture, crc16_ccitt_auto_31bytes)
|
||||
|
||||
TEST_F(crc16_ccittFixture, crc16_ccitt_auto_63bytes)
|
||||
{
|
||||
crc16_ccitt_ctx* ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
crc16_ccitt_ctx *ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -126,8 +127,8 @@ TEST_F(crc16_ccittFixture, crc16_ccitt_auto_63bytes)
|
||||
|
||||
TEST_F(crc16_ccittFixture, crc16_ccitt_auto_2352bytes)
|
||||
{
|
||||
crc16_ccitt_ctx* ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
crc16_ccitt_ctx *ctx = crc16_ccitt_init();
|
||||
uint16_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
#define EXPECTED_CRC32_63BYTES 0xbff6a341
|
||||
#define EXPECTED_CRC32_2352BYTES 0x08ba93ea
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class crc32Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
crc32Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -37,18 +37,19 @@ class crc32Fixture : 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);
|
||||
}
|
||||
|
||||
~crc32Fixture()
|
||||
@@ -61,8 +62,8 @@ class crc32Fixture : public ::testing::Test
|
||||
|
||||
TEST_F(crc32Fixture, crc32_auto)
|
||||
{
|
||||
crc32_ctx* ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
crc32_ctx *ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -85,12 +86,12 @@ TEST_F(crc32Fixture, crc32_slicing)
|
||||
|
||||
TEST_F(crc32Fixture, crc32_auto_misaligned)
|
||||
{
|
||||
crc32_ctx* ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
crc32_ctx *ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
crc32_update(ctx, buffer_misaligned+1, 1048576);
|
||||
crc32_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
crc32_final(ctx, &crc);
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC32);
|
||||
@@ -100,7 +101,7 @@ TEST_F(crc32Fixture, crc32_slicing_misaligned)
|
||||
{
|
||||
uint32_t crc = CRC32_ISO_SEED;
|
||||
|
||||
crc32_slicing(&crc, buffer_misaligned+1, 1048576);
|
||||
crc32_slicing(&crc, buffer_misaligned + 1, 1048576);
|
||||
|
||||
crc ^= CRC32_ISO_SEED;
|
||||
|
||||
@@ -109,8 +110,8 @@ TEST_F(crc32Fixture, crc32_slicing_misaligned)
|
||||
|
||||
TEST_F(crc32Fixture, crc32_auto_15bytes)
|
||||
{
|
||||
crc32_ctx* ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
crc32_ctx *ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -133,8 +134,8 @@ TEST_F(crc32Fixture, crc32_slicing_15bytes)
|
||||
|
||||
TEST_F(crc32Fixture, crc32_auto_31bytes)
|
||||
{
|
||||
crc32_ctx* ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
crc32_ctx *ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -157,8 +158,8 @@ TEST_F(crc32Fixture, crc32_slicing_31bytes)
|
||||
|
||||
TEST_F(crc32Fixture, crc32_auto_63bytes)
|
||||
{
|
||||
crc32_ctx* ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
crc32_ctx *ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -181,8 +182,8 @@ TEST_F(crc32Fixture, crc32_slicing_63bytes)
|
||||
|
||||
TEST_F(crc32Fixture, crc32_auto_2352bytes)
|
||||
{
|
||||
crc32_ctx* ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
crc32_ctx *ctx = crc32_init();
|
||||
uint32_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -203,7 +204,7 @@ TEST_F(crc32Fixture, crc32_slicing_2352bytes)
|
||||
EXPECT_EQ(crc, EXPECTED_CRC32_2352BYTES);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
TEST_F(crc32Fixture, crc32_clmul)
|
||||
{
|
||||
@@ -282,6 +283,7 @@ TEST_F(crc32Fixture, crc32_clmul_2352bytes)
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC32_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
|
||||
@@ -305,7 +307,7 @@ TEST_F(crc32Fixture, crc32_arm_crc32_misaligned)
|
||||
|
||||
uint32_t crc = CRC32_ISO_SEED;
|
||||
|
||||
crc = armv8_crc32_little(crc, buffer_misaligned+1, 1048576);
|
||||
crc = armv8_crc32_little(crc, buffer_misaligned + 1, 1048576);
|
||||
|
||||
crc ^= CRC32_ISO_SEED;
|
||||
|
||||
@@ -363,6 +365,7 @@ TEST_F(crc32Fixture, crc32_arm_crc32_2352bytes)
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC32_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST_F(crc32Fixture, crc32_vmull)
|
||||
@@ -442,4 +445,5 @@ TEST_F(crc32Fixture, crc32_vmull_2352bytes)
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC32_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
#define EXPECTED_CRC64_63BYTES 0x29F331FC90702BF4
|
||||
#define EXPECTED_CRC64_2352BYTES 0x126435DB43477623
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class crc64Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
crc64Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -37,18 +37,19 @@ class crc64Fixture : 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);
|
||||
}
|
||||
|
||||
~crc64Fixture()
|
||||
@@ -61,8 +62,8 @@ class crc64Fixture : public ::testing::Test
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto)
|
||||
{
|
||||
crc64_ctx* ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
crc64_ctx *ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -85,12 +86,12 @@ TEST_F(crc64Fixture, crc64_slicing)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_misaligned)
|
||||
{
|
||||
crc64_ctx* ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
crc64_ctx *ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
crc64_update(ctx, buffer_misaligned+1, 1048576);
|
||||
crc64_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
crc64_final(ctx, &crc);
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC64);
|
||||
@@ -100,7 +101,7 @@ TEST_F(crc64Fixture, crc64_slicing_misaligned)
|
||||
{
|
||||
uint64_t crc = CRC64_ECMA_SEED;
|
||||
|
||||
crc64_slicing(&crc, buffer_misaligned+1, 1048576);
|
||||
crc64_slicing(&crc, buffer_misaligned + 1, 1048576);
|
||||
|
||||
crc ^= CRC64_ECMA_SEED;
|
||||
|
||||
@@ -109,8 +110,8 @@ TEST_F(crc64Fixture, crc64_slicing_misaligned)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_15bytes)
|
||||
{
|
||||
crc64_ctx* ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
crc64_ctx *ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -133,8 +134,8 @@ TEST_F(crc64Fixture, crc64_slicing_15bytes)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_31bytes)
|
||||
{
|
||||
crc64_ctx* ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
crc64_ctx *ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -157,8 +158,8 @@ TEST_F(crc64Fixture, crc64_slicing_31bytes)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_63bytes)
|
||||
{
|
||||
crc64_ctx* ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
crc64_ctx *ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -181,8 +182,8 @@ TEST_F(crc64Fixture, crc64_slicing_63bytes)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_2352bytes)
|
||||
{
|
||||
crc64_ctx* ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
crc64_ctx *ctx = crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -203,7 +204,7 @@ TEST_F(crc64Fixture, crc64_slicing_2352bytes)
|
||||
EXPECT_EQ(crc, EXPECTED_CRC64_2352BYTES);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
TEST_F(crc64Fixture, crc64_clmul)
|
||||
{
|
||||
@@ -224,7 +225,7 @@ TEST_F(crc64Fixture, crc64_clmul_misaligned)
|
||||
|
||||
uint64_t crc = CRC64_ECMA_SEED;
|
||||
|
||||
crc = ~crc64_clmul(~crc, buffer_misaligned+1, 1048576);
|
||||
crc = ~crc64_clmul(~crc, buffer_misaligned + 1, 1048576);
|
||||
|
||||
crc ^= CRC64_ECMA_SEED;
|
||||
|
||||
@@ -282,13 +283,14 @@ TEST_F(crc64Fixture, crc64_clmul_2352bytes)
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC64_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
|
||||
TEST_F(crc64Fixture, crc64_vmull)
|
||||
{
|
||||
if(!have_neon()) return;
|
||||
|
||||
|
||||
uint64_t crc = CRC64_ECMA_SEED;
|
||||
|
||||
crc = ~crc64_vmull(~crc, buffer, 1048576);
|
||||
@@ -304,7 +306,7 @@ TEST_F(crc64Fixture, crc64_vmull_misaligned)
|
||||
|
||||
uint64_t crc = CRC64_ECMA_SEED;
|
||||
|
||||
crc = ~crc64_vmull(~crc, buffer_misaligned+1, 1048576);
|
||||
crc = ~crc64_vmull(~crc, buffer_misaligned + 1, 1048576);
|
||||
|
||||
crc ^= CRC64_ECMA_SEED;
|
||||
|
||||
@@ -362,4 +364,5 @@ TEST_F(crc64Fixture, crc64_vmull_2352bytes)
|
||||
|
||||
EXPECT_EQ(crc, EXPECTED_CRC64_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
#define EXPECTED_FLETCHER32_63BYTES 0xD8432080
|
||||
#define EXPECTED_FLETCHER32_2352BYTES 0xCB3E7352
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class fletcher32Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
fletcher32Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -37,18 +37,19 @@ class fletcher32Fixture : 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);
|
||||
}
|
||||
|
||||
~fletcher32Fixture()
|
||||
@@ -61,8 +62,8 @@ class fletcher32Fixture : public ::testing::Test
|
||||
|
||||
TEST_F(fletcher32Fixture, fletcher32_auto)
|
||||
{
|
||||
fletcher32_ctx* ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
fletcher32_ctx *ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -74,12 +75,12 @@ TEST_F(fletcher32Fixture, fletcher32_auto)
|
||||
|
||||
TEST_F(fletcher32Fixture, fletcher32_auto_misaligned)
|
||||
{
|
||||
fletcher32_ctx* ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
fletcher32_ctx *ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
fletcher32_update(ctx, buffer_misaligned+1, 1048576);
|
||||
fletcher32_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
fletcher32_final(ctx, &fletcher);
|
||||
|
||||
EXPECT_EQ(fletcher, EXPECTED_FLETCHER32);
|
||||
@@ -87,8 +88,8 @@ TEST_F(fletcher32Fixture, fletcher32_auto_misaligned)
|
||||
|
||||
TEST_F(fletcher32Fixture, fletcher32_auto_15bytes)
|
||||
{
|
||||
fletcher32_ctx* ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
fletcher32_ctx *ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -100,8 +101,8 @@ TEST_F(fletcher32Fixture, fletcher32_auto_15bytes)
|
||||
|
||||
TEST_F(fletcher32Fixture, fletcher32_auto_31bytes)
|
||||
{
|
||||
fletcher32_ctx* ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
fletcher32_ctx *ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -113,8 +114,8 @@ TEST_F(fletcher32Fixture, fletcher32_auto_31bytes)
|
||||
|
||||
TEST_F(fletcher32Fixture, fletcher32_auto_63bytes)
|
||||
{
|
||||
fletcher32_ctx* ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
fletcher32_ctx *ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -126,8 +127,8 @@ TEST_F(fletcher32Fixture, fletcher32_auto_63bytes)
|
||||
|
||||
TEST_F(fletcher32Fixture, fletcher32_auto_2352bytes)
|
||||
{
|
||||
fletcher32_ctx* ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
fletcher32_ctx *ctx = fletcher32_init();
|
||||
uint32_t fletcher;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
|
||||
@@ -167,7 +168,7 @@ TEST_F(fletcher32Fixture, fletcher32_neon_misaligned)
|
||||
sum1 = 0xFFFF;
|
||||
sum2 = 0xFFFF;
|
||||
|
||||
fletcher32_neon(&sum1, &sum2, buffer_misaligned+1, 1048576);
|
||||
fletcher32_neon(&sum1, &sum2, buffer_misaligned + 1, 1048576);
|
||||
|
||||
fletcher32 = (sum2 << 16) | sum1;
|
||||
|
||||
@@ -245,9 +246,10 @@ TEST_F(fletcher32Fixture, fletcher32_neon_2352bytes)
|
||||
|
||||
EXPECT_EQ(fletcher32, EXPECTED_FLETCHER32_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
|
||||
TEST_F(fletcher32Fixture, fletcher32_avx2)
|
||||
@@ -297,7 +299,7 @@ TEST_F(fletcher32Fixture, fletcher32_avx2_misaligned)
|
||||
sum1 = 0xFFFF;
|
||||
sum2 = 0xFFFF;
|
||||
|
||||
fletcher32_avx2(&sum1, &sum2, buffer_misaligned+1, 1048576);
|
||||
fletcher32_avx2(&sum1, &sum2, buffer_misaligned + 1, 1048576);
|
||||
|
||||
fletcher32 = (sum2 << 16) | sum1;
|
||||
|
||||
@@ -315,7 +317,7 @@ TEST_F(fletcher32Fixture, fletcher32_ssse3_misaligned)
|
||||
sum1 = 0xFFFF;
|
||||
sum2 = 0xFFFF;
|
||||
|
||||
fletcher32_ssse3(&sum1, &sum2, buffer_misaligned+1, 1048576);
|
||||
fletcher32_ssse3(&sum1, &sum2, buffer_misaligned + 1, 1048576);
|
||||
|
||||
fletcher32 = (sum2 << 16) | sum1;
|
||||
|
||||
@@ -465,4 +467,5 @@ TEST_F(fletcher32Fixture, fletcher32_ssse3_2352bytes)
|
||||
|
||||
EXPECT_EQ(fletcher32, EXPECTED_FLETCHER32_2352BYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
#define EXPECTED_SPAMSUM_63BYTES "3:Ac4E9E5+S09q2kABV9:Ac4E9EgSs7kW9"
|
||||
#define EXPECTED_SPAMSUM_2352BYTES "48:pasCLoANDXmjCz1p2OpPm+Gek3xmZfJJ5DD4BacmmlodQMQa/58Z:csK1Nxz7XFGeJS/flHMQu2Z"
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class spamsumFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
spamsumFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -37,18 +37,19 @@ class spamsumFixture : 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);
|
||||
}
|
||||
|
||||
~spamsumFixture()
|
||||
@@ -61,96 +62,96 @@ class spamsumFixture : public ::testing::Test
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto)
|
||||
{
|
||||
spamsum_ctx* ctx = spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
spamsum_update(ctx, buffer, 1048576);
|
||||
spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_misaligned)
|
||||
{
|
||||
spamsum_ctx* ctx = spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
spamsum_update(ctx, buffer_misaligned+1, 1048576);
|
||||
spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
spamsum_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_15bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
spamsum_update(ctx, buffer, 15);
|
||||
spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_15BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_31bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
spamsum_update(ctx, buffer, 31);
|
||||
spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_31BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_63bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
spamsum_update(ctx, buffer, 63);
|
||||
spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_63BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_2352bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
spamsum_update(ctx, buffer, 2352);
|
||||
spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_2352BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user