1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-15 22:16:35 +00:00

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<uint32_t>::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);
}
This commit is contained in:
elsid 2025-10-12 10:19:06 +02:00
parent ab4637f6c7
commit 7bf1ea32b0
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40

View file

@ -284,6 +284,34 @@ namespace Bsa
}));
}
TEST(BSAFileTest, shouldHandleSomewhatLargeFiles)
{
constexpr std::uint32_t maxUInt32 = std::numeric_limits<uint32_t>::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<char> 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<uint32_t>::max();
@ -323,5 +351,6 @@ namespace Bsa
EXPECT_THAT(file.getList(), IsEmpty());
}
#endif
}
}