diff --git a/.github/workflows/s390x.yml b/.github/workflows/s390x.yml index a5899873a..3edac918d 100644 --- a/.github/workflows/s390x.yml +++ b/.github/workflows/s390x.yml @@ -33,4 +33,5 @@ jobs: -DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF -DBUILD_STRUCT_PB=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARK=OFF cmake --build ${{github.workspace}}/build -j cd ${{github.workspace}}/build/output/tests - ./struct_pack_test \ No newline at end of file + ./struct_pack_test + ./struct_pack_test_with_optimize \ No newline at end of file diff --git a/include/ylt/struct_pack.hpp b/include/ylt/struct_pack.hpp index 3d5b2c50a..971874801 100644 --- a/include/ylt/struct_pack.hpp +++ b/include/ylt/struct_pack.hpp @@ -616,7 +616,7 @@ template ())>; expected ret; - auto ec = get_field_to(ret.value(), v); + auto ec = get_field_to(ret.value(), v); if SP_UNLIKELY (ec != struct_pack::errc{}) { ret = unexpected{ec}; } @@ -627,7 +627,7 @@ template [[nodiscard]] STRUCT_PACK_INLINE auto get_field(const char *data, size_t size) { using T_Field = std::tuple_element_t())>; expected ret; - auto ec = get_field_to(ret.value(), data, size); + auto ec = get_field_to(ret.value(), data, size); if SP_UNLIKELY (ec != struct_pack::errc{}) { ret = unexpected{ec}; } @@ -644,7 +644,7 @@ template ())>; expected ret; - auto ec = get_field_to(ret.value(), reader); + auto ec = get_field_to(ret.value(), reader); if SP_UNLIKELY (ec != struct_pack::errc{}) { ret = unexpected{ec}; } diff --git a/src/struct_pack/tests/CMakeLists.txt b/src/struct_pack/tests/CMakeLists.txt index cf513a4f8..6bded7ebf 100644 --- a/src/struct_pack/tests/CMakeLists.txt +++ b/src/struct_pack/tests/CMakeLists.txt @@ -1,31 +1,17 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/tests) -add_executable(struct_pack_test - test_serialize.cpp - test_compile_time_calculate.cpp - test_data_struct.cpp - test_data_struct2.cpp - test_tuplet.cpp - test_alignas.cpp - test_pragma_pack.cpp - test_pragma_pack_and_alignas_mix.cpp - test_varint.cpp - test_fast_varint.cpp - test_stream.cpp - test_compatible.cpp - test_non_aggregated_type.cpp - test_derived.cpp - test_cross_platform.cpp - test_disable_meta_info.cpp - test_optimize.cpp - main.cpp - ) +file(GLOB SRCS_PATHS ./*.cpp) +add_executable(struct_pack_test ${SRCS_PATHS}) +add_executable(struct_pack_test_with_optimize ${SRCS_PATHS}) add_test(NAME struct_pack_test COMMAND struct_pack_test) +add_test(NAME struct_pack_test_with_optimize COMMAND struct_pack_test_with_optimize) include (TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) if(NOT IS_BIG_ENDIAN) target_compile_definitions(struct_pack_test PRIVATE STRUCT_PACK_ENABLE_UNPORTABLE_TYPE TEST_IN_LITTLE_ENDIAN) +target_compile_definitions(struct_pack_test_with_optimize PRIVATE STRUCT_PACK_ENABLE_UNPORTABLE_TYPE STRUCT_PACK_OPTIMIZE TEST_IN_LITTLE_ENDIAN ) else() -target_compile_definitions(struct_pack_test PRIVATE STRUCT_PACK_ENABLE_UNPORTABLE_TYPE) +target_compile_definitions(struct_pack_test PRIVATE STRUCT_PACK_ENABLE_UNPORTABLE_TYPE ) +target_compile_definitions(struct_pack_test_with_optimize PRIVATE STRUCT_PACK_ENABLE_UNPORTABLE_TYPE STRUCT_PACK_OPTIMIZE) endif() add_custom_command( TARGET struct_pack_test PRE_BUILD @@ -36,4 +22,4 @@ add_custom_command( TARGET struct_pack_test PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/binary_data - ${CMAKE_BINARY_DIR}/src/struct_pack/tests/binary_data) + ${CMAKE_BINARY_DIR}/src/struct_pack/tests/binary_data) \ No newline at end of file diff --git a/src/struct_pack/tests/test_optimize.cpp b/src/struct_pack/tests/test_optimize.cpp deleted file mode 100644 index b786f5922..000000000 --- a/src/struct_pack/tests/test_optimize.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "ylt/struct_pack/derived_helper.hpp" -#define STRUCT_PACK_OPTIMIZE -#include "doctest.h" -#include "ylt/struct_pack.hpp" -TEST_CASE("test width too big") { - SUBCASE("1") { - std::string buffer; - buffer.push_back(0b11000); - auto result = struct_pack::deserialize(buffer); - REQUIRE(result.has_value() == false); - if constexpr (sizeof(std::size_t) < 8) { - CHECK(result.error() == struct_pack::errc::too_width_size); - } - else { - CHECK(result.error() == struct_pack::errc::no_buffer_space); - } - } - SUBCASE("2") { - std::string buffer; - buffer.push_back(0b11000); - std::size_t len = 0; - auto result = struct_pack::deserialize(buffer, len); - REQUIRE(result.has_value() == false); - if constexpr (sizeof(std::size_t) < 8) { - CHECK(result.error() == struct_pack::errc::too_width_size); - } - else { - CHECK(result.error() == struct_pack::errc::no_buffer_space); - } - } - SUBCASE("3") { - std::string buffer; - buffer.push_back(0b11000); - auto result = - struct_pack::get_field, 0, - struct_pack::DISABLE_ALL_META_INFO>(buffer); - REQUIRE(result.has_value() == false); - if constexpr (sizeof(std::size_t) < 8) { - CHECK(result.error() == struct_pack::errc::too_width_size); - } - else { - CHECK(result.error() == struct_pack::errc::no_buffer_space); - } - } - SUBCASE("4") { - std::string buffer; - using T = std::pair>; - auto code = struct_pack::get_type_code() + 1; - buffer.resize(4); - memcpy(buffer.data(), &code, sizeof(code)); - buffer.push_back(0b11); - auto result = struct_pack::deserialize< - std::pair>>(buffer); - REQUIRE(result.has_value() == false); - if constexpr (sizeof(std::size_t) < 8) { - CHECK(result.error() == struct_pack::errc::too_width_size); - } - else { - CHECK(result.error() == struct_pack::errc::no_buffer_space); - } - } -} \ No newline at end of file