mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2025-12-16 19:24:31 +00:00
General refactor and cleanup.
This commit is contained in:
@@ -26,18 +26,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0x954bf76e
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class lzmaFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
lzmaFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -46,13 +46,13 @@ class lzmaFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/lzma.bin", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1200275);
|
||||
fread((void*)buffer, 1, 1200275, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1200275);
|
||||
fread((void *)buffer, 1, 1200275, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~lzmaFixture()
|
||||
{
|
||||
@@ -67,7 +67,7 @@ TEST_F(lzmaFixture, lzma)
|
||||
uint8_t params[] = {0x5D, 0x00, 0x00, 0x00, 0x02};
|
||||
size_t destLen = 8388608;
|
||||
size_t srcLen = 1200275;
|
||||
auto* outBuf = (uint8_t*)malloc(8388608);
|
||||
auto *outBuf = (uint8_t *)malloc(8388608);
|
||||
|
||||
auto err = AARU_lzma_decode_buffer(outBuf, &destLen, buffer, &srcLen, params, 5);
|
||||
|
||||
@@ -88,34 +88,34 @@ TEST_F(lzmaFixture, lzmaCompress)
|
||||
size_t decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
int err;
|
||||
uint8_t props[5];
|
||||
size_t props_len = 5;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
original_crc = crc32_data(original, original_len);
|
||||
|
||||
// Compress
|
||||
err = AARU_lzma_encode_buffer(
|
||||
cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2, 273, 2);
|
||||
err = AARU_lzma_encode_buffer(cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2,
|
||||
273, 2);
|
||||
EXPECT_EQ(err, 0);
|
||||
|
||||
// Decompress
|
||||
@@ -127,7 +127,7 @@ TEST_F(lzmaFixture, lzmaCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user