diff options
| author | Zousar Shaker <[email protected]> | 2024-12-06 21:47:11 -0700 |
|---|---|---|
| committer | Zousar Shaker <[email protected]> | 2024-12-06 21:47:11 -0700 |
| commit | 5688fa8f46fe3cd32f283adcc590e447174c58a8 (patch) | |
| tree | dccaef1a87cf454639f45e330732221ce4eb1712 /src/zencore/testutils.cpp | |
| parent | changelog (diff) | |
| parent | 5.5.16-pre0 (diff) | |
| download | zen-zs/xrepo.tar.xz zen-zs/xrepo.zip | |
Merge branch 'main' into zs/xrepozs/xrepo
Diffstat (limited to 'src/zencore/testutils.cpp')
| -rw-r--r-- | src/zencore/testutils.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/zencore/testutils.cpp b/src/zencore/testutils.cpp index d4c8aeaef..641d5508a 100644 --- a/src/zencore/testutils.cpp +++ b/src/zencore/testutils.cpp @@ -71,6 +71,26 @@ CreateRandomBlob(uint64_t Size) return Data; }; +IoBuffer +CreateSemiRandomBlob(uint64_t Size) +{ + IoBuffer Result(Size); + const size_t PartCount = (Size / (1u * 1024u * 64)) + 1; + const size_t PartSize = Size / PartCount; + auto Part = CreateRandomBlob(PartSize); + auto Remain = Result.GetMutableView().CopyFrom(Part.GetView()); + while (Remain.GetSize() >= PartSize) + { + Remain = Remain.CopyFrom(Part.GetView()); + } + if (Remain.GetSize() > 0) + { + auto RemainBuffer = CreateRandomBlob(Remain.GetSize()); + Remain.CopyFrom(RemainBuffer.GetView()); + } + return Result; +}; + } // namespace zen #endif // ZEN_WITH_TESTS |