From 7bf1ea32b0cf2a518c8fcbd3fa6d20fef48fa02b Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 12 Oct 2025 10:19:06 +0200 Subject: [PATCH] Disable not working tests for MSVC std::streambuf in MSVC does not support buffers larger than 2**31 - 1: https://developercommunity.visualstudio.com/t/stdbasic-stringbuf-is-broken/290124 Simple test to check if it works: TEST(IMemStreamTest, shouldRead) { std::string src(std::numeric_limits::max() / 2 + 1, '\0'); Files::IMemStream stream(src.data(), src.size()); std::string dst(src.size(), '\0'); stream.read(dst.data(), src.size()); EXPECT_FALSE(stream.fail()) << std::generic_category().message(errno); } --- apps/components_tests/bsa/testbsafile.cpp | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/apps/components_tests/bsa/testbsafile.cpp b/apps/components_tests/bsa/testbsafile.cpp index ab5ab31930..365697e6ae 100644 --- a/apps/components_tests/bsa/testbsafile.cpp +++ b/apps/components_tests/bsa/testbsafile.cpp @@ -284,6 +284,34 @@ namespace Bsa })); } + TEST(BSAFileTest, shouldHandleSomewhatLargeFiles) + { + constexpr std::uint32_t maxUInt32 = std::numeric_limits::max(); + constexpr std::uint32_t fileSize = maxUInt32 / 4; + constexpr std::uint32_t fileOffset = maxUInt32 / 4 - 34; + const Buffer buffer = makeBsaBuffer(fileSize, fileOffset); + + TestBSAFile file; + // Use capacity assuming we never read beyond small header. + Files::IMemStream stream(buffer.mData.get(), buffer.mCapacity); + file.readHeader(stream); + + std::vector namesBuffer = { 'a', '\0' }; + + EXPECT_THAT(file.getList(), + ElementsAre(BSAFile::FileStruct{ + .mFileSize = maxUInt32 / 4, + .mOffset = maxUInt32 / 4, + .mHash = BSAFile::Hash{ .mLow = 0xaaaabbbb, .mHigh = 0xccccdddd }, + .mNameOffset = 0, + .mNameSize = 1, + .mNamesBuffer = &namesBuffer, + })); + } + +// std::streambuf in MSVC does not support buffers larger than 2**31 - 1: +// https://developercommunity.visualstudio.com/t/stdbasic-stringbuf-is-broken/290124 +#ifndef _MSC_VER TEST(BSAFileTest, shouldHandleSingleFileAtTheEndOfLargeFile) { constexpr std::uint32_t maxUInt32 = std::numeric_limits::max(); @@ -323,5 +351,6 @@ namespace Bsa EXPECT_THAT(file.getList(), IsEmpty()); } +#endif } }