| 9 | //////////////////////////////////////////////////////////////////////////////// |
| 10 | |
| 11 | TEST(TChunkedMemoryPoolOutputTest, Basic) |
| 12 | { |
| 13 | constexpr size_t PoolChunkSize = 10; |
| 14 | constexpr size_t PoolOutputChunkSize = 7; |
| 15 | TChunkedMemoryPool pool(NullRefCountedTypeCookie, PoolChunkSize); |
| 16 | TChunkedMemoryPoolOutput output(&pool, PoolOutputChunkSize); |
| 17 | |
| 18 | TString s1("Short."); |
| 19 | output.Write(s1); |
| 20 | |
| 21 | TString s2("Quite a long string."); |
| 22 | output.Write(s2); |
| 23 | |
| 24 | char* buf; |
| 25 | auto len = output.Next(&buf); |
| 26 | output.Undo(len); |
| 27 | |
| 28 | auto chunks = output.Finish(); |
| 29 | TString s; |
| 30 | for (auto chunk : chunks) { |
| 31 | s += TString(chunk.Begin(), chunk.End()); |
| 32 | } |
| 33 | ASSERT_EQ(s1 + s2, s); |
| 34 | } |
| 35 | |
| 36 | //////////////////////////////////////////////////////////////////////////////// |
| 37 | |