fix bugs in the cursor StringOperations test
Summary:
The IOBuf.StringOperations test contained two buggy tests. According to
the comments, they were intended to test a string spanning multiple
buffers. They created a chain of two buffers, but used Appender to
write the string, which only writes in the final buffer in the chain.
Additionally, the test didn't request enough space in the final buffer
for the string data, and didn't allow Appender to grow the buffer. (The
code also didn't check the return value from pushAtMost() to see if it
actually wrote all of the string data.) The test only passed because
IOBuf would normally allocate more capacity than the caller requested.
I fixed the tests to request sufficient capacity for the string data,
and use push() rather than pushAtMost() to ensure that all data was
written correctly. I also added two new tests which actually test with
strings spanning multiple buffers.
Test Plan:
Ran this test with some changes to IOBuf that cause it to only allocate
the requested capacity in some cases, and verified that the
StringOperations test pass now.
(The changes I was testing with use goodMallocSize() to determine the
allocation size even for small internal buffers. When not using
jemalloc, goodMallocSize() returns the original size, so it only
allocates the capacity requested by the caller.)
Reviewed By: pgriess@fb.com
FB internal diff:
D1072283