Electroneum
namespacetest.cpp File Reference
Include dependency graph for namespacetest.cpp:

Go to the source code of this file.

Macros

#define RAPIDJSON_NAMESPACE   my::rapid::json
 
#define RAPIDJSON_NAMESPACE_BEGIN   namespace my { namespace rapid { namespace json {
 
#define RAPIDJSON_NAMESPACE_END   } } }
 

Functions

 TEST (NamespaceTest, Using)
 
 TEST (NamespaceTest, Direct)
 

Macro Definition Documentation

◆ RAPIDJSON_NAMESPACE

#define RAPIDJSON_NAMESPACE   my::rapid::json

Definition at line 19 of file namespacetest.cpp.

◆ RAPIDJSON_NAMESPACE_BEGIN

#define RAPIDJSON_NAMESPACE_BEGIN   namespace my { namespace rapid { namespace json {

Definition at line 20 of file namespacetest.cpp.

◆ RAPIDJSON_NAMESPACE_END

#define RAPIDJSON_NAMESPACE_END   } } }

Definition at line 21 of file namespacetest.cpp.

Function Documentation

◆ TEST() [1/2]

TEST ( NamespaceTest  ,
Using   
)

Definition at line 34 of file namespacetest.cpp.

34  {
35  using namespace RAPIDJSON_NAMESPACE;
36  typedef GenericDocument<UTF8<>, CrtAllocator> DocumentType;
37  DocumentType doc;
38 
39  doc.Parse(json);
40  EXPECT_TRUE(!doc.HasParseError());
41 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
C-runtime library allocator.
Definition: allocators.h:75
#define RAPIDJSON_NAMESPACE
A document for parsing JSON text as DOM.
Definition: document.h:60
rapidjson::Document json
Definition: transport.cpp:49

◆ TEST() [2/2]

TEST ( NamespaceTest  ,
Direct   
)

Definition at line 43 of file namespacetest.cpp.

43  {
48  typedef RAPIDJSON_NAMESPACE::Writer<StringBuffer> WriterType;
49 
50  StringStream s(json);
51  StringBuffer buffer;
52  WriterType writer(buffer);
53  buffer.ShrinkToFit();
54  Reader reader;
55  reader.Parse(s, writer);
56 
57  EXPECT_STREQ(json, buffer.GetString());
58  EXPECT_EQ(sizeof(json)-1, buffer.GetSize());
59  EXPECT_TRUE(writer.IsComplete());
60 
61  Document doc;
62  doc.Parse(buffer.GetString());
63  EXPECT_TRUE(!doc.HasParseError());
64 
65  buffer.Clear();
66  writer.Reset(buffer);
67  doc.Accept(writer);
68  EXPECT_STREQ(json, buffer.GetString());
69  EXPECT_TRUE(writer.IsComplete());
70 }
GenericReader< UTF8< char >, UTF8< char >, CrtAllocator > Reader
Definition: fwd.h:88
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
GenericStringStream< UTF8< char > > StringStream
Definition: fwd.h:47
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
Definition: reader.h:557
Read-only string stream.
Definition: fwd.h:47
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:2512
GenericStringBuffer< UTF8< char >, CrtAllocator > StringBuffer
Definition: fwd.h:59
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition: document.h:2331
const Ch * GetString() const
Definition: stringbuffer.h:73
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
Here is the call graph for this function: