mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2025-12-16 19:24:31 +00:00
Add LZFSE.
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
|||||||
[submodule "3rdparty/bzip2"]
|
[submodule "3rdparty/bzip2"]
|
||||||
path = 3rdparty/bzip2
|
path = 3rdparty/bzip2
|
||||||
url = https://gitlab.com/bzip2/bzip2.git
|
url = https://gitlab.com/bzip2/bzip2.git
|
||||||
|
[submodule "3rdparty/lzfse"]
|
||||||
|
path = 3rdparty/lzfse
|
||||||
|
url = https://github.com/lzfse/lzfse
|
||||||
|
|||||||
3
3rdparty/CMakeLists.txt
vendored
3
3rdparty/CMakeLists.txt
vendored
@@ -5,3 +5,6 @@ SET(ENABLE_STATIC_LIB ON)
|
|||||||
|
|
||||||
add_subdirectory(bzip2)
|
add_subdirectory(bzip2)
|
||||||
include(lzip.cmake)
|
include(lzip.cmake)
|
||||||
|
|
||||||
|
set(LZFSE_BUNDLE_MODE ON)
|
||||||
|
add_subdirectory(lzfse)
|
||||||
1
3rdparty/lzfse
vendored
Submodule
1
3rdparty/lzfse
vendored
Submodule
Submodule 3rdparty/lzfse added at e634ca58b4
@@ -94,6 +94,6 @@ MACRO (TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE target)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
ENDMACRO()
|
ENDMACRO()
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE("Aaru.Compression.Native" bz2_static lzlib)
|
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE("Aaru.Compression.Native" bz2_static lzlib lzfse)
|
||||||
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/bzip2.bz2
|
|||||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/lzip.lz
|
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/lzip.lz
|
||||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||||
|
|
||||||
|
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/lzfse.bin
|
||||||
|
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||||
|
|
||||||
# 'Google_Tests_run' is the target name
|
# 'Google_Tests_run' is the target name
|
||||||
# 'test1.cpp tests2.cpp' are source files with tests
|
# 'test1.cpp tests2.cpp' are source files with tests
|
||||||
add_executable(tests_run apple_rle.cpp crc32.c crc32.h adc.cpp bzip2.cpp lzip.cpp)
|
add_executable(tests_run apple_rle.cpp crc32.c crc32.h adc.cpp bzip2.cpp lzip.cpp lzfse.cpp)
|
||||||
target_link_libraries(tests_run gtest gtest_main "Aaru.Compression.Native")
|
target_link_libraries(tests_run gtest gtest_main "Aaru.Compression.Native")
|
||||||
|
|||||||
76
tests/lzfse.cpp
Normal file
76
tests/lzfse.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Aaru Data Preservation Suite.
|
||||||
|
* Copyright (c) 2019-2021 Natalia Portillo.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
|
#include "../3rdparty/lzfse/src/lzfse.h"
|
||||||
|
#include "crc32.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#define EXPECTED_CRC32 0xc64059c0
|
||||||
|
|
||||||
|
static const uint8_t* buffer;
|
||||||
|
|
||||||
|
class lzfseFixture : public ::testing::Test
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
lzfseFixture()
|
||||||
|
{
|
||||||
|
// initialization;
|
||||||
|
// can also be done in SetUp()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetUp()
|
||||||
|
{
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char filename[PATH_MAX];
|
||||||
|
|
||||||
|
getcwd(path, PATH_MAX);
|
||||||
|
snprintf(filename, PATH_MAX, "%s/data/lzfse.bin", path);
|
||||||
|
|
||||||
|
FILE* file = fopen(filename, "rb");
|
||||||
|
buffer = (const uint8_t*)malloc(1059299);
|
||||||
|
fread((void*)buffer, 1, 1059299, file);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() { free((void*)buffer); }
|
||||||
|
|
||||||
|
~lzfseFixture()
|
||||||
|
{
|
||||||
|
// resources cleanup, no exceptions allowed
|
||||||
|
}
|
||||||
|
|
||||||
|
// shared user data
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(lzfseFixture, lzfse)
|
||||||
|
{
|
||||||
|
auto* outBuf = (uint8_t*)malloc(1048576);
|
||||||
|
|
||||||
|
auto decoded = lzfse_decode_buffer(outBuf, 1048576, buffer, 1059299, NULL);
|
||||||
|
|
||||||
|
EXPECT_EQ(decoded, 1048576);
|
||||||
|
|
||||||
|
auto crc = crc32_data(outBuf, 1048576);
|
||||||
|
|
||||||
|
free(outBuf);
|
||||||
|
|
||||||
|
EXPECT_EQ(crc, EXPECTED_CRC32);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user