Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
f349456b
Commit
f349456b
authored
Feb 28, 2017
by
StilesCrisis
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'miloyip/master' into issue845_native_strlen
parents
26e089b9
e6b192a7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
5 deletions
+87
-5
prettywriter.h
include/rapidjson/prettywriter.h
+4
-2
schema.h
include/rapidjson/schema.h
+1
-1
writer.h
include/rapidjson/writer.h
+3
-2
prettywritertest.cpp
test/unittest/prettywritertest.cpp
+51
-0
schematest.cpp
test/unittest/schematest.cpp
+6
-0
writertest.cpp
test/unittest/writertest.cpp
+22
-0
No files found.
include/rapidjson/prettywriter.h
View file @
f349456b
...
...
@@ -136,8 +136,10 @@ public:
bool
EndObject
(
SizeType
memberCount
=
0
)
{
(
void
)
memberCount
;
RAPIDJSON_ASSERT
(
Base
::
level_stack_
.
GetSize
()
>=
sizeof
(
typename
Base
::
Level
));
RAPIDJSON_ASSERT
(
!
Base
::
level_stack_
.
template
Top
<
typename
Base
::
Level
>
()
->
inArray
);
RAPIDJSON_ASSERT
(
Base
::
level_stack_
.
GetSize
()
>=
sizeof
(
typename
Base
::
Level
));
// not inside an Object
RAPIDJSON_ASSERT
(
!
Base
::
level_stack_
.
template
Top
<
typename
Base
::
Level
>
()
->
inArray
);
// currently inside an Array, not Object
RAPIDJSON_ASSERT
(
0
==
Base
::
level_stack_
.
template
Top
<
typename
Base
::
Level
>
()
->
valueCount
%
2
);
// Object has a Key without a Value
bool
empty
=
Base
::
level_stack_
.
template
Pop
<
typename
Base
::
Level
>
(
1
)
->
valueCount
==
0
;
if
(
!
empty
)
{
...
...
include/rapidjson/schema.h
View file @
f349456b
...
...
@@ -1928,7 +1928,7 @@ private:
const
Context
&
CurrentContext
()
const
{
return
*
schemaStack_
.
template
Top
<
Context
>
();
}
OutputHandler
&
CreateNullHandler
()
{
return
*
(
nullHandler_
=
static_cast
<
OutputHandler
*>
(
GetStateAllocator
().
Malloc
(
sizeof
(
OutputHandler
)))
);
return
*
(
nullHandler_
=
new
(
GetStateAllocator
().
Malloc
(
sizeof
(
OutputHandler
)))
OutputHandler
);
}
static
const
size_t
kDefaultSchemaStackCapacity
=
1024
;
...
...
include/rapidjson/writer.h
View file @
f349456b
...
...
@@ -221,8 +221,9 @@ public:
bool
EndObject
(
SizeType
memberCount
=
0
)
{
(
void
)
memberCount
;
RAPIDJSON_ASSERT
(
level_stack_
.
GetSize
()
>=
sizeof
(
Level
));
RAPIDJSON_ASSERT
(
!
level_stack_
.
template
Top
<
Level
>
()
->
inArray
);
RAPIDJSON_ASSERT
(
level_stack_
.
GetSize
()
>=
sizeof
(
Level
));
// not inside an Object
RAPIDJSON_ASSERT
(
!
level_stack_
.
template
Top
<
Level
>
()
->
inArray
);
// currently inside an Array, not Object
RAPIDJSON_ASSERT
(
0
==
level_stack_
.
template
Top
<
Level
>
()
->
valueCount
%
2
);
// Object has a Key without a Value
level_stack_
.
template
Pop
<
Level
>
(
1
);
return
EndValue
(
WriteEndObject
());
}
...
...
test/unittest/prettywritertest.cpp
View file @
f349456b
...
...
@@ -207,6 +207,57 @@ TEST(PrettyWriter, RawValue) {
buffer
.
GetString
());
}
TEST
(
PrettyWriter
,
InvalidEventSequence
)
{
// {]
{
StringBuffer
buffer
;
PrettyWriter
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
EXPECT_THROW
(
writer
.
EndArray
(),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
// [}
{
StringBuffer
buffer
;
PrettyWriter
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartArray
();
EXPECT_THROW
(
writer
.
EndObject
(),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
// { 1:
{
StringBuffer
buffer
;
PrettyWriter
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
EXPECT_THROW
(
writer
.
Int
(
1
),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
// { 'a' }
{
StringBuffer
buffer
;
PrettyWriter
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
Key
(
"a"
);
EXPECT_THROW
(
writer
.
EndObject
(),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
// { 'a':'b','c' }
{
StringBuffer
buffer
;
PrettyWriter
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
Key
(
"a"
);
writer
.
String
(
"b"
);
writer
.
Key
(
"c"
);
EXPECT_THROW
(
writer
.
EndObject
(),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
static
PrettyWriter
<
StringBuffer
>
WriterGen
(
StringBuffer
&
target
)
{
...
...
test/unittest/schematest.cpp
View file @
f349456b
...
...
@@ -1281,6 +1281,12 @@ TEST(SchemaValidatingWriter, Simple) {
EXPECT_TRUE
(
validator
.
GetInvalidDocumentPointer
()
==
SchemaDocument
::
PointerType
(
""
));
}
TEST
(
Schema
,
Issue848
)
{
rapidjson
::
Document
d
;
rapidjson
::
SchemaDocument
s
(
d
);
rapidjson
::
GenericSchemaValidator
<
rapidjson
::
SchemaDocument
,
rapidjson
::
Document
>
v
(
s
);
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
static
SchemaDocument
ReturnSchemaDocument
()
{
...
...
test/unittest/writertest.cpp
View file @
f349456b
...
...
@@ -442,6 +442,28 @@ TEST(Writer, InvalidEventSequence) {
EXPECT_THROW
(
writer
.
Int
(
1
),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
// { 'a' }
{
StringBuffer
buffer
;
Writer
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
Key
(
"a"
);
EXPECT_THROW
(
writer
.
EndObject
(),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
// { 'a':'b','c' }
{
StringBuffer
buffer
;
Writer
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
Key
(
"a"
);
writer
.
String
(
"b"
);
writer
.
Key
(
"c"
);
EXPECT_THROW
(
writer
.
EndObject
(),
AssertException
);
EXPECT_FALSE
(
writer
.
IsComplete
());
}
}
TEST
(
Writer
,
NaN
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment