From 093f6fe758a6b88f3362df42d32d7a3da0212651 Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Wed, 29 Nov 2023 18:50:10 +0800 Subject: [PATCH] fix --- include/ylt/struct_pack/unpacker.hpp | 2 +- src/struct_pack/tests/test_stream.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ylt/struct_pack/unpacker.hpp b/include/ylt/struct_pack/unpacker.hpp index da0ade4bb..a2d92e5f8 100644 --- a/include/ylt/struct_pack/unpacker.hpp +++ b/include/ylt/struct_pack/unpacker.hpp @@ -1066,7 +1066,7 @@ class unpacker { else if constexpr (NotSkip) { item.clear(); if constexpr (can_reserve) { - item.reserve(std::min(size, block_lim_cnt)); + item.reserve((std::min)(size, block_lim_cnt)); } for (size_t i = 0; i < size; ++i) { item.emplace_back(); diff --git a/src/struct_pack/tests/test_stream.cpp b/src/struct_pack/tests/test_stream.cpp index cfde3d0a5..fa8525e39 100644 --- a/src/struct_pack/tests/test_stream.cpp +++ b/src/struct_pack/tests/test_stream.cpp @@ -255,7 +255,7 @@ TEST_CASE("testing broken container size") { auto ec = struct_pack::deserialize_to(data2, ifi); CHECK(ec == struct_pack::errc::no_buffer_space); CHECK(data2.size() == 1 * 1024 * 1024); - CHECK(data2.capacity() == 1 * 1024 * 1024); + CHECK(data2.capacity() < 2 * 1024 * 1024); } } std::filesystem::remove("tmp.data");