mirror of
https://github.com/OpenMW/openmw.git
synced 2025-10-16 13:16:33 +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:
parent
ab4637f6c7
commit
7bf1ea32b0
1 changed files with 29 additions and 0 deletions
|
@ -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)
|
TEST(BSAFileTest, shouldHandleSingleFileAtTheEndOfLargeFile)
|
||||||
{
|
{
|
||||||
constexpr std::uint32_t maxUInt32 = std::numeric_limits<uint32_t>::max();
|
constexpr std::uint32_t maxUInt32 = std::numeric_limits<uint32_t>::max();
|
||||||
|
@ -323,5 +351,6 @@ namespace Bsa
|
||||||
|
|
||||||
EXPECT_THAT(file.getList(), IsEmpty());
|
EXPECT_THAT(file.getList(), IsEmpty());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue