MCPcopy Create free account
hub / github.com/bytedance/bolt / TEST_F

Function TEST_F

bolt/common/memory/tests/HashStringAllocatorTest.cpp:114–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112};
113
114TEST_F(HashStringAllocatorTest, headerToString) {
115 ASSERT_NO_THROW(allocator_->toString());
116
117 auto h1 = allocate(123);
118 auto h2 = allocate(456);
119
120 ASSERT_EQ(h1->toString(), "size: 123");
121 ASSERT_EQ(h2->toString(), "size: 456");
122
123 allocator_->free(h1);
124 ASSERT_EQ(h1->toString(), "|free| size: 123");
125 ASSERT_EQ(h2->toString(), "size: 456, previous is free (123 bytes)");
126
127 auto h3 = allocate(123'456);
128 ASSERT_EQ(h3->toString(), "size: 123456");
129
130 ASSERT_NO_THROW(allocator_->toString());
131
132 ByteOutputStream stream(allocator_.get());
133 auto h4 = allocator_->newWrite(stream).header;
134 std::string data(123'456, 'x');
135 stream.appendStringView(data);
136 allocator_->finishWrite(stream, 0);
137
138 ASSERT_EQ(h4->toString(), "|multipart| size: 123 [64913, 58436]");
139
140 ASSERT_EQ(
141 h4->nextContinued()->toString(),
142 "|multipart| size: 64913 [58436], at end");
143
144 ASSERT_EQ(h4->nextContinued()->nextContinued()->toString(), "size: 58436");
145
146 ASSERT_NO_THROW(allocator_->toString());
147}
148
149TEST_F(HashStringAllocatorTest, allocate) {
150 for (auto count = 0; count < 3; ++count) {

Callers

nothing calls this directly

Calls 15

prepareReadFunction · 0.85
memoryManagerFunction · 0.85
randFunction · 0.85
newWriteMethod · 0.80
finishWriteMethod · 0.80
nextContinuedMethod · 0.80
extendWriteMethod · 0.80
newContiguousRangeMethod · 0.80
ensureAvailableMethod · 0.80
addRootPoolMethod · 0.80
addLeafChildMethod · 0.80
copyMultipartMethod · 0.80

Tested by

no test coverage detected