23RAPIDJSON_DIAG_OFF(c++98-compat)
28static 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}";
29static const char kPrettyJson[] =
31" \"hello\": \"world\",\n"
43" \"u64\": 1234567890123456789,\n"
44" \"i64\": -1234567890123456789\n"
47static const char kPrettyJson_FormatOptions_SLA[] =
49" \"hello\": \"world\",\n"
55" \"a\": [1, 2, 3, -1],\n"
56" \"u64\": 1234567890123456789,\n"
57" \"i64\": -1234567890123456789\n"
88 "\t\"hello\": \"world\",\n"
100 "\t\"u64\": 1234567890123456789,\n"
101 "\t\"i64\": -1234567890123456789\n"
115#if RAPIDJSON_HAS_STDSTRING
120 EXPECT_TRUE(writer.String(std::string(
"Hello\n")));
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;
162 std::string actual = ss.str();
168 char filename[L_tmpnam];
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();
343#define T(meth, val, expected) \
345 StringBuffer buffer; \
346 PrettyWriter<StringBuffer> writer(buffer); \
349 EXPECT_STREQ(expected, buffer.GetString()); \
350 EXPECT_TRUE(writer.IsComplete()); \
353 T(
Bool,
false,
"false");
354 T(
Bool,
true,
"true");
360 T(String,
"Hello",
"\"Hello\"");
C-runtime library allocator.
Wrapper of C file stream for output using fwrite().
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
const Ch * GetString() const
OStreamWrapper(std::ostream &os)
Writer with indentation and spacing.
bool EndArray(SizeType memberCount=0)
bool Key(const Ch *str, SizeType length, bool copy=false)
bool RawValue(const Ch *json, size_t length, Type type)
Write a raw JSON value.
bool EndObject(SizeType memberCount=0)
PrettyWriter & SetFormatOptions(PrettyFormatOptions options)
Set pretty writer formatting options.
PrettyWriter & SetIndent(Ch indentChar, unsigned indentCharCount)
Set custom indentation.
bool String(const Ch *str, SizeType length, bool copy=false)
bool IsComplete() const
Checks whether the output is a complete JSON.
#define EXPECT_THROW(statement, expected_exception)
#define EXPECT_TRUE(condition)
#define EXPECT_STREQ(s1, s2)
#define TEST(test_case_name, test_name)
#define ASSERT_TRUE(condition)
#define EXPECT_FALSE(condition)
BasicOStreamWrapper< std::ostream > OStreamWrapper
@ kFormatSingleLineArray
Format arrays on a single line.
#define T(meth, val, expected)
FILE * TempFile(char *filename)
@ kWriteNanAndInfFlag
Allow writing of Infinity, -Infinity and NaN.