23 RAPIDJSON_DIAG_OFF(c++98-compat)
28 static const char kJson[] =
"{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[1,2,3,-1],\"u64\":1234567890123456789,\"i64\":-1234567890123456789}";
29 static const char kPrettyJson[] =
31 " \"hello\": \"world\",\n" 43 " \"u64\": 1234567890123456789,\n" 44 " \"i64\": -1234567890123456789\n" 47 static const char kPrettyJson_FormatOptions_SLA[] =
49 " \"hello\": \"world\",\n" 55 " \"a\": [1, 2, 3, -1],\n" 56 " \"u64\": 1234567890123456789,\n" 57 " \"i64\": -1234567890123456789\n" 65 reader.
Parse(s, writer);
75 reader.
Parse(s, writer);
85 reader.
Parse(s, writer);
88 "\t\"hello\": \"world\",\n" 100 "\t\"u64\": 1234567890123456789,\n" 101 "\t\"i64\": -1234567890123456789\n" 115 #if RAPIDJSON_HAS_STDSTRING 134 Ch Peek()
const { assert(
false);
return '\0'; }
135 Ch Take() { assert(
false);
return '\0'; }
136 size_t Tell()
const {
return 0; }
154 std::stringstream ss;
160 reader.
Parse(s, writer);
168 char filename[L_tmpnam];
176 reader.
Parse(s, writer);
179 fp = fopen(filename,
"rb");
180 fseek(fp, 0, SEEK_END);
181 size_t size =
static_cast<size_t>(ftell(fp));
182 fseek(fp, 0, SEEK_SET);
183 char*
json =
static_cast<char*
>(malloc(size + 1));
184 size_t readLength = fread(
json, 1, size, fp);
185 json[readLength] =
'\0';
199 const char json[] =
"[\"Hello\\nWorld\", 123.456]";
206 " \"raw\": [\"Hello\\nWorld\", 123.456]\n" 263 double nan = std::numeric_limits<double>::quiet_NaN();
282 double inf = std::numeric_limits<double>::infinity();
306 char buf[100] =
"Hello";
319 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 323 writer.StartObject();
TEST(PrettyWriter, Basic)
#define EXPECT_TRUE(condition)
#define EXPECT_STREQ(s1, s2)
C-runtime library allocator.
#define EXPECT_THROW(statement, expected_exception)
bool Key(const Ch *str, SizeType length, bool copy=false)
bool EndArray(SizeType memberCount=0)
FILE * TempFile(char *filename)
PrettyWriter & SetFormatOptions(PrettyFormatOptions options)
Set pretty writer formatting options.
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
bool IsComplete() const
Checks whether the output is a complete JSON.
BasicOStreamWrapper< std::ostream > OStreamWrapper
Writer with indentation and spacing.
PrettyWriter & SetIndent(Ch indentChar, unsigned indentCharCount)
Set custom indentation.
bool RawValue(const Ch *json, size_t length, Type type)
Write a raw JSON value.
#define ASSERT_TRUE(condition)
const Ch * GetString() const
connection< TProtocol > & operator=(const connection< TProtocol > &obj)
bool EndObject(SizeType memberCount=0)
OStreamWrapper(std::ostream &os)
#define EXPECT_FALSE(condition)
Allow writing of Infinity, -Infinity and NaN.
Format arrays on a single line.
bool String(const Ch *str, SizeType length, bool copy=false)
Wrapper of C file stream for output using fwrite().