240 EXPECT_EQ(buf.size, 8); |
240 EXPECT_EQ(buf.size, 8); |
241 EXPECT_TRUE(memcmp(buf.space, "Testing", 8) == 0); |
241 EXPECT_TRUE(memcmp(buf.space, "Testing", 8) == 0); |
242 cxBufferDestroy(&buf); |
242 cxBufferDestroy(&buf); |
243 EXPECT_TRUE(alloc.verify()); |
243 EXPECT_TRUE(alloc.verify()); |
244 } |
244 } |
|
245 |
|
246 TEST(BufferClear, Test) { |
|
247 char space[16]; |
|
248 strcpy(space, "clear test"); |
|
249 CxBuffer buf; |
|
250 cxBufferInit(&buf, space, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
|
251 ASSERT_EQ(buf.size, 0); |
|
252 // only clear the used part of the buffer |
|
253 cxBufferClear(&buf); |
|
254 EXPECT_EQ(memcmp(space, "clear test", 10), 0); |
|
255 buf.size = 5; |
|
256 buf.pos = 3; |
|
257 cxBufferClear(&buf); |
|
258 EXPECT_EQ(memcmp(space, "\0\0\0\0\0 test", 10), 0); |
|
259 EXPECT_EQ(buf.size, 0); |
|
260 EXPECT_EQ(buf.pos, 0); |
|
261 } |