Electroneum
stringbuffertest.cpp File Reference
#include "unittest.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
Include dependency graph for stringbuffertest.cpp:

Go to the source code of this file.

Functions

 TEST (StringBuffer, InitialSize)
 
 TEST (StringBuffer, Put)
 
 TEST (StringBuffer, PutN_Issue672)
 
 TEST (StringBuffer, Clear)
 
 TEST (StringBuffer, Push)
 
 TEST (StringBuffer, Pop)
 
 TEST (StringBuffer, GetLength_Issue744)
 

Function Documentation

◆ TEST() [1/7]

TEST ( StringBuffer  ,
InitialSize   
)

Definition at line 26 of file stringbuffertest.cpp.

26  {
27  StringBuffer buffer;
28  EXPECT_EQ(0u, buffer.GetSize());
29  EXPECT_EQ(0u, buffer.GetLength());
30  EXPECT_STREQ("", buffer.GetString());
31 }
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
size_t GetLength() const
Get the length of string in Ch in the string buffer.
Definition: stringbuffer.h:85
const Ch * GetString() const
Definition: stringbuffer.h:73
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function:

◆ TEST() [2/7]

TEST ( StringBuffer  ,
Put   
)

Definition at line 33 of file stringbuffertest.cpp.

33  {
34  StringBuffer buffer;
35  buffer.Put('A');
36 
37  EXPECT_EQ(1u, buffer.GetSize());
38  EXPECT_EQ(1u, buffer.GetLength());
39  EXPECT_STREQ("A", buffer.GetString());
40 }
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
size_t GetLength() const
Get the length of string in Ch in the string buffer.
Definition: stringbuffer.h:85
const Ch * GetString() const
Definition: stringbuffer.h:73
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function:

◆ TEST() [3/7]

TEST ( StringBuffer  ,
PutN_Issue672   
)

Definition at line 42 of file stringbuffertest.cpp.

42  {
44  EXPECT_EQ(0, buffer.GetSize());
45  EXPECT_EQ(0, buffer.GetLength());
46  rapidjson::PutN(buffer, ' ', 1);
47  EXPECT_EQ(1, buffer.GetSize());
48  EXPECT_EQ(1, buffer.GetLength());
49 }
Represents an in-memory output stream.
Definition: fwd.h:59
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
void PutN(FileWriteStream &stream, char c, size_t n)
Implement specialized version of PutN() with memset() for better performance.
size_t GetLength() const
Get the length of string in Ch in the string buffer.
Definition: stringbuffer.h:85
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function:

◆ TEST() [4/7]

TEST ( StringBuffer  ,
Clear   
)

Definition at line 51 of file stringbuffertest.cpp.

51  {
52  StringBuffer buffer;
53  buffer.Put('A');
54  buffer.Put('B');
55  buffer.Put('C');
56  buffer.Clear();
57 
58  EXPECT_EQ(0u, buffer.GetSize());
59  EXPECT_EQ(0u, buffer.GetLength());
60  EXPECT_STREQ("", buffer.GetString());
61 }
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
size_t GetLength() const
Get the length of string in Ch in the string buffer.
Definition: stringbuffer.h:85
const Ch * GetString() const
Definition: stringbuffer.h:73
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function:

◆ TEST() [5/7]

TEST ( StringBuffer  ,
Push   
)

Definition at line 63 of file stringbuffertest.cpp.

63  {
64  StringBuffer buffer;
65  buffer.Push(5);
66 
67  EXPECT_EQ(5u, buffer.GetSize());
68  EXPECT_EQ(5u, buffer.GetLength());
69 
70  // Causes sudden expansion to make the stack's capacity equal to size
71  buffer.Push(65536u);
72  EXPECT_EQ(5u + 65536u, buffer.GetSize());
73 }
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
size_t GetLength() const
Get the length of string in Ch in the string buffer.
Definition: stringbuffer.h:85
Ch * Push(size_t count)
Definition: stringbuffer.h:69
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function:

◆ TEST() [6/7]

TEST ( StringBuffer  ,
Pop   
)

Definition at line 75 of file stringbuffertest.cpp.

75  {
76  StringBuffer buffer;
77  buffer.Put('A');
78  buffer.Put('B');
79  buffer.Put('C');
80  buffer.Put('D');
81  buffer.Put('E');
82  buffer.Pop(3);
83 
84  EXPECT_EQ(2u, buffer.GetSize());
85  EXPECT_EQ(2u, buffer.GetLength());
86  EXPECT_STREQ("AB", buffer.GetString());
87 }
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
size_t GetLength() const
Get the length of string in Ch in the string buffer.
Definition: stringbuffer.h:85
const Ch * GetString() const
Definition: stringbuffer.h:73
void Pop(size_t count)
Definition: stringbuffer.h:71
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function:

◆ TEST() [7/7]

TEST ( StringBuffer  ,
GetLength_Issue744   
)

Definition at line 89 of file stringbuffertest.cpp.

89  {
91  buffer.Put('A');
92  buffer.Put('B');
93  buffer.Put('C');
94  EXPECT_EQ(3u * sizeof(wchar_t), buffer.GetSize());
95  EXPECT_EQ(3u, buffer.GetLength());
96 }
Represents an in-memory output stream.
Definition: fwd.h:59
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
size_t GetLength() const
Get the length of string in Ch in the string buffer.
Definition: stringbuffer.h:85
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function: