| 35 | } |
| 36 | |
| 37 | TEST(StringBufferTest, Basic) { |
| 38 | MemTracker tracker; |
| 39 | MemPool pool(&tracker); |
| 40 | StringBuffer str(&pool); |
| 41 | string std_str; |
| 42 | |
| 43 | // Empty string |
| 44 | ValidateString(std_str, str); |
| 45 | |
| 46 | // Clear empty string |
| 47 | std_str.clear(); |
| 48 | str.Clear(); |
| 49 | ValidateString(std_str, str); |
| 50 | |
| 51 | // Append to empty |
| 52 | std_str.append("Hello"); |
| 53 | ASSERT_OK(str.Append("Hello", strlen("Hello"))); |
| 54 | ValidateString(std_str, str); |
| 55 | |
| 56 | // Append some more |
| 57 | std_str.append("World"); |
| 58 | ASSERT_OK(str.Append("World", strlen("World"))); |
| 59 | ValidateString(std_str, str); |
| 60 | |
| 61 | // Clear |
| 62 | std_str.clear(); |
| 63 | str.Clear(); |
| 64 | ValidateString(std_str, str); |
| 65 | |
| 66 | // Underlying buffer size should be the length of the max string during the test. |
| 67 | EXPECT_EQ(str.buffer_size(), strlen("HelloWorld")); |
| 68 | |
| 69 | pool.FreeAll(); |
| 70 | } |
| 71 | |
| 72 | TEST(StringBufferTest, AppendBoundary) { |
| 73 | // Test StringBuffer::Append() works beyond 1GB. |
nothing calls this directly
no test coverage detected