16 #include <gtest/gtest.h>
27 EXPECT_EQ(std_str.empty(), str.
Empty());
28 EXPECT_EQ((
int)std_str.size(), str.
Size());
29 if (std_str.size() > 0) {
30 EXPECT_EQ(strncmp(std_str.c_str(), str.
str().
ptr, std_str.size()), 0);
34 TEST(StringBufferTest, Basic) {
49 std_str.append(
"Hello");
50 str.
Append(
"Hello", strlen(
"Hello"));
54 std_str.append(
"World");
55 str.
Append(
"World", strlen(
"World"));
59 std_str.assign(
"foo");
60 str.
Assign(
"foo", strlen(
"foo"));
76 int main(
int argc,
char **argv) {
77 ::testing::InitGoogleTest(&argc, argv);
78 return RUN_ALL_TESTS();
const StringValue & str() const
Returns the underlying StringValue.
int Size() const
Returns the length of the current string.
void Append(const char *str, int len)
Append 'str' to the current string, allocating a new buffer as necessary.
void Assign(const char *str, int len)
Assigns contents to StringBuffer.
int buffer_size() const
Returns the buffer size.
void Clear()
Clear the underlying StringValue. The allocated buffer can be reused.
bool Empty() const
Returns whether the current string is empty.
This class is thread-safe.
int main(int argc, char **argv)
void ValidateString(const string &std_str, const StringBuffer &str)