Skip to content

Commit 8dc3a46

Browse files
committed
io: Add test for ByteCount for 4GB+ objects
1 parent f45e056 commit 8dc3a46

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

io/io/test/testByteCount.cxx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ int testReadWriteObjectAny()
182182
// SetBufferOffset does not check against the size,
183183
// so we can provide and use a larger buffer.
184184
std::vector<char> databuffer{};
185-
databuffer.reserve(8 * 1024 * 1024 * 1024ll);
186-
TBufferFile b(TBuffer::kWrite, 8 * 1024 * 1024 * 1024ll - 100, databuffer.data(), false /* don't adopt */, DoNothingAllocator);
185+
databuffer.reserve(9 * 1024 * 1024 * 1024ll);
186+
TBufferFile b(TBuffer::kWrite, 9 * 1024 * 1024 * 1024ll - 100, databuffer.data(), false /* don't adopt */, DoNothingAllocator);
187187

188188
LargeByteCountsFixture fixture;
189189
fixture.resize(100); // Small object, should be written with the regular byte count mechanism.
@@ -215,6 +215,17 @@ int testReadWriteObjectAny()
215215
b.SetBufferOffset(startPos);
216216
errors += readAndCheck("Large object written in long range section", b, 1024 * 1024 * 256);
217217

218+
// Very Large object written in long range section, should be written with
219+
// the large byte count mechanism
220+
b.SetWriteMode();
221+
b.SetBufferOffset(4 * 1024 * 1024 * 1024ll + 200);
222+
startPos = b.GetCurrent() - b.Buffer();
223+
fixture.resize(1024 * 1024 * 1024 + 8ll); // a bit more than 4GB of data
224+
b.WriteObject(&fixture, false /* cacheReuse */);
225+
b.SetReadMode();
226+
b.SetBufferOffset(startPos);
227+
errors += readAndCheck("Very Large object written in long range section", b, 1024 * 1024 * 1024 + 8);
228+
218229
return errors;
219230
}
220231

0 commit comments

Comments
 (0)