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
89fa7822
Commit
89fa7822
authored
Oct 23, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #166 from spl/fix-memorystream-peek
Fix MemoryStream::Peek() and add test for fix
parents
a58559f1
0e715872
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
memorystream.h
include/rapidjson/memorystream.h
+1
-1
readertest.cpp
test/unittest/readertest.cpp
+10
-0
No files found.
include/rapidjson/memorystream.h
View file @
89fa7822
...
@@ -42,7 +42,7 @@ struct MemoryStream {
...
@@ -42,7 +42,7 @@ struct MemoryStream {
MemoryStream
(
const
Ch
*
src
,
size_t
size
)
:
src_
(
src
),
begin_
(
src
),
end_
(
src
+
size
),
size_
(
size
)
{}
MemoryStream
(
const
Ch
*
src
,
size_t
size
)
:
src_
(
src
),
begin_
(
src
),
end_
(
src
+
size
),
size_
(
size
)
{}
Ch
Peek
()
const
{
return
*
src_
;
}
Ch
Peek
()
const
{
return
(
src_
==
end_
)
?
'\0'
:
*
src_
;
}
Ch
Take
()
{
return
(
src_
==
end_
)
?
'\0'
:
*
src_
++
;
}
Ch
Take
()
{
return
(
src_
==
end_
)
?
'\0'
:
*
src_
++
;
}
size_t
Tell
()
const
{
return
static_cast
<
size_t
>
(
src_
-
begin_
);
}
size_t
Tell
()
const
{
return
static_cast
<
size_t
>
(
src_
-
begin_
);
}
...
...
test/unittest/readertest.cpp
View file @
89fa7822
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "unittest.h"
#include "unittest.h"
#include "rapidjson/reader.h"
#include "rapidjson/reader.h"
#include "rapidjson/memorystream.h"
using
namespace
rapidjson
;
using
namespace
rapidjson
;
...
@@ -674,6 +675,15 @@ TEST(Reader, ParseObject_Error) {
...
@@ -674,6 +675,15 @@ TEST(Reader, ParseObject_Error) {
// Must be a comma or '}' after an object member
// Must be a comma or '}' after an object member
TEST_ERROR
(
kParseErrorObjectMissCommaOrCurlyBracket
,
"{
\"
a
\"
:1]"
);
TEST_ERROR
(
kParseErrorObjectMissCommaOrCurlyBracket
,
"{
\"
a
\"
:1]"
);
// This tests that MemoryStream is checking the length in Peek().
{
MemoryStream
ms
(
"{
\"
a
\"
"
,
1
);
BaseReaderHandler
<>
h
;
Reader
reader
;
EXPECT_FALSE
(
reader
.
Parse
<
kParseStopWhenDoneFlag
>
(
ms
,
h
));
EXPECT_EQ
(
kParseErrorObjectMissName
,
reader
.
GetParseErrorCode
());
}
}
}
#undef TEST_ERROR
#undef TEST_ERROR
...
...
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