blob: 22ee9e379e96685195857cdd3338a4e8788cd363 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <library/cpp/testing/gtest/gtest.h>
#include <library/cpp/yt/memory/chunked_memory_pool.h>
#include <library/cpp/yt/memory/chunked_memory_pool_output.h>
namespace NYT {
namespace {
////////////////////////////////////////////////////////////////////////////////
TEST(TChunkedMemoryPoolOutputTest, Basic)
{
constexpr size_t PoolChunkSize = 10;
constexpr size_t PoolOutputChunkSize = 7;
TChunkedMemoryPool pool(NullRefCountedTypeCookie, PoolChunkSize);
TChunkedMemoryPoolOutput output(&pool, PoolOutputChunkSize);
TString s1("Short.");
output.Write(s1);
TString s2("Quite a long string.");
output.Write(s2);
char* buf;
auto len = output.Next(&buf);
output.Undo(len);
auto chunks = output.Finish();
TString s;
for (auto chunk : chunks) {
s += TString(chunk.Begin(), chunk.End());
}
ASSERT_EQ(s1 + s2, s);
}
////////////////////////////////////////////////////////////////////////////////
} // namespace
} // namespace NYT
|