28 #define SIMD_SUFFIX(name) name##_SSE2 29 #elif defined(RAPIDJSON_SSE42) 30 #define SIMD_SUFFIX(name) name##_SSE42 31 #elif defined(RAPIDJSON_NEON) 32 #define SIMD_SUFFIX(name) name##_NEON 34 #define SIMD_SUFFIX(name) name 47 temp_ = (
char *)malloc(length_ + 1);
50 EXPECT_FALSE(doc_.Parse(json_).HasParseError());
52 for (
size_t i = 0; i < 7; i++)
53 EXPECT_FALSE(typesDoc_[i].Parse(types_[i]).HasParseError());
72 for (
size_t i = 0; i < kTrialCount; i++) {
73 memcpy(temp_, json_, length_ + 1);
82 for (
size_t i = 0; i < kTrialCount; i++) {
83 memcpy(temp_, json_, length_ + 1);
92 for (
size_t i = 0; i < kTrialCount; i++) {
96 EXPECT_TRUE(reader.
Parse(s, h));
100 #define TEST_TYPED(index, Name)\ 101 TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_##Name)) {\ 102 for (size_t i = 0; i < kTrialCount * 10; i++) {\ 103 StringStream s(types_[index]);\ 104 BaseReaderHandler<> h;\ 106 EXPECT_TRUE(reader.Parse(s, h));\ 109 TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler_##Name)) {\ 110 for (size_t i = 0; i < kTrialCount * 10; i++) {\ 111 memcpy(temp_, types_[index], typesLength_[index] + 1);\ 112 InsituStringStream s(temp_);\ 113 BaseReaderHandler<> h;\ 115 EXPECT_TRUE(reader.Parse<kParseInsituFlag>(s, h));\ 130 for (
size_t i = 0; i < kTrialCount; i++) {
139 for (
size_t i = 0; i < kTrialCount; i++) {
148 for (
size_t i = 0; i < kTrialCount; i++) {
149 memcpy(temp_, json_, length_ + 1);
158 for (
size_t i = 0; i < kTrialCount; i++) {
172 for (
size_t i = 0; i < kTrialCount; i++) {
173 memcpy(temp_, json_, length_ + 1);
187 for (
size_t i = 0; i < kTrialCount; i++) {
196 for (
size_t i = 0; i < kTrialCount; i++) {
197 memcpy(temp_, json_, length_ + 1);
200 ASSERT_TRUE(doc.IsObject());
205 for (
size_t i = 0; i < kTrialCount; i++) {
206 memcpy(temp_, json_, length_ + 1);
209 ASSERT_TRUE(doc.IsObject());
214 for (
size_t i = 0; i < kTrialCount; i++) {
217 ASSERT_TRUE(doc.IsObject());
222 for (
size_t i = 0; i < kTrialCount; i++) {
224 doc.
Parse(json_, length_);
225 ASSERT_TRUE(doc.IsObject());
229 #if RAPIDJSON_HAS_STDSTRING 231 const std::string
s(json_, length_);
232 for (
size_t i = 0; i < kTrialCount; i++) {
235 ASSERT_TRUE(doc.IsObject());
241 for (
size_t i = 0; i < kTrialCount; i++) {
244 ASSERT_TRUE(doc.IsObject());
249 for (
size_t i = 0; i < kTrialCount; i++) {
250 memcpy(temp_, json_, length_ + 1);
253 ASSERT_TRUE(doc.IsObject());
258 for (
size_t i = 0; i < kTrialCount; i++) {
263 ASSERT_TRUE(doc.IsObject());
268 for (
size_t i = 0; i < kTrialCount; i++) {
273 ASSERT_TRUE(doc.IsObject());
280 switch(value.GetType()) {
282 for (
typename T::ConstMemberIterator itr = value.MemberBegin(); itr != value.MemberEnd(); ++itr) {
289 for (
typename T::ConstValueIterator itr = value.Begin(); itr != value.End(); ++itr)
301 for (
size_t i = 0; i < kTrialCount; i++) {
303 EXPECT_EQ(4339u, count);
311 RAPIDJSON_DIAG_OFF(effc++)
328 for (
size_t i = 0; i < kTrialCount; i++) {
330 doc_.Accept(counter);
331 EXPECT_EQ(4339u, counter.
count_);
345 for (
size_t i = 0; i < kTrialCount; i++) {
355 for (
size_t i = 0; i < kTrialCount; i++) {
366 #define TEST_TYPED(index, Name)\ 367 TEST_F(RapidJson, SIMD_SUFFIX(Writer_StringBuffer_##Name)) {\ 368 for (size_t i = 0; i < kTrialCount * 10; i++) {\ 369 StringBuffer s(0, 1024 * 1024);\ 370 Writer<StringBuffer> writer(s);\ 371 typesDoc_[index].Accept(writer);\ 372 const char* str = s.GetString();\ 380 TEST_TYPED(3, Integers)
383 TEST_TYPED(6, Paragraphs)
388 for (
size_t i = 0; i < kTrialCount; i++) {
402 for (
size_t i = 0; i < kTrialCount * kTrialCount; i++)
408 for (
size_t i = 0; i < kTrialCount; i++) {
410 while (s.Peek() ==
' ' || s.Peek() ==
'\n' || s.Peek() ==
'\r' || s.Peek() ==
'\t')
412 ASSERT_EQ(
'[', s.Peek());
417 for (
size_t i = 0; i < kTrialCount; i++) {
420 ASSERT_EQ(
'[', s.Peek());
425 for (
size_t i = 0; i < kTrialCount; i++) {
426 const char*
s = whitespace_ + std::strspn(whitespace_,
" \t\r\n");
434 for (
size_t i = 0; i < kTrialCount; i++) {
437 while (is.
Peek() !=
'\0')
444 for (
size_t i = 0; i < kTrialCount; i++) {
445 FILE *fp = fopen(filename_,
"rb");
448 while (s.
Take() !=
'\0')
455 for (
size_t i = 0; i < kTrialCount; i++) {
456 FILE *fp = fopen(filename_,
"rb");
468 for (
int i = 0; i < 32 * 1024 * 1024; i++)
472 #endif // TEST_RAPIDJSON
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Iterative(constant complexity in terms of function call stack size) parsing.
Represents an in-memory input byte stream.
const Ch * GetString() const
PrettyWriter & SetIndent(Ch indentChar, unsigned indentCharCount)
Set custom indentation.
RAPIDJSON_FORCEINLINE bool IterativeParseComplete()
Check if token-by-token parsing JSON text is complete.
bool EndObject(SizeType memberCount)
Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS. ...
Parse number in full precision (but slower).
bool HasParseError() const
Whether a parse error has occured in the last parsing.
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
bool IterativeParseNext(InputStream &is, Handler &handler)
Parse one token from JSON text.
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
GenericStringStream< UTF8< char > > StringStream
size_t Traverse(const T &value)
C-runtime library allocator.
void SkipWhitespace(InputStream &is)
Skip the JSON white spaces in a stream.
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler))
double Pow10(int n)
Computes integer powers of 10 in double (10.0^n).
File byte stream for input using fread().
const GenericPointer< typename T::ValueType > T2 value
Validate encoding of JSON strings.
bool EndArray(SizeType elementCount)
common definitions and configuration
void IterativeParseInit()
Initialize JSON text token-by-token parsing.
#define TEST_TYPED(index, Name)
#define SIMD_SUFFIX(name)
In-situ(destructive) parsing.
Writer with indentation and spacing.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)