Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
capnproto
Commits
e9fa0685
Commit
e9fa0685
authored
Mar 04, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaks.
parent
64a0ca66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
18 deletions
+9
-18
wire-format-test.c++
c++/src/capnproto/wire-format-test.c++
+8
-17
wire-format.c++
c++/src/capnproto/wire-format.c++
+1
-1
No files found.
c++/src/capnproto/wire-format-test.c++
View file @
e9fa0685
...
...
@@ -234,9 +234,11 @@ TEST(WireFormat, StructRoundTrip) {
EXPECT_EQ
(
34
*
WORDS
,
segment
->
getSize
());
checkStruct
(
builder
.
asReader
());
checkStruct
(
StructReader
::
readRootTrusted
(
segment
->
getStartPtr
(),
nullptr
));
checkStruct
(
StructReader
::
readRoot
(
segment
->
getStartPtr
(),
nullptr
,
segment
,
4
));
}
TEST
(
WireFormat
,
StructRoundTrip_
FarPointer
s
)
{
TEST
(
WireFormat
,
StructRoundTrip_
MultipleSegment
s
)
{
std
::
unique_ptr
<
MessageBuilder
>
message
=
newMallocMessage
(
1
*
WORDS
);
SegmentBuilder
*
segment
=
message
->
getSegmentWithAvailable
(
1
*
WORDS
);
word
*
rootLocation
=
segment
->
allocate
(
1
*
WORDS
);
...
...
@@ -245,23 +247,12 @@ TEST(WireFormat, StructRoundTrip_FarPointers) {
StructBuilder
::
initRoot
(
segment
,
rootLocation
,
FieldNumber
(
16
),
2
*
WORDS
,
4
*
REFERENCES
);
setupStruct
(
builder
);
// word count:
// 1 root reference
// 6 root struct
// 1 sub message
// 2 3-element int32 list
// 13 struct list
// 1 tag
// 12 4x struct
// 1 data segment
// 1 reference segment
// 1 sub-struct
// 11 list list
// 5 references to sub-lists
// 6 sub-lists (4x 1 word, 1x 2 words)
// -----
// 34
// Verify that we made 15 segments.
ASSERT_TRUE
(
message
->
tryGetSegment
(
SegmentId
(
14
))
!=
nullptr
);
EXPECT_EQ
(
nullptr
,
message
->
tryGetSegment
(
SegmentId
(
15
)));
// Check that each segment has the expected size. Recall that the first word of each segment will
// actually be a reference to the first thing allocated within that segment.
EXPECT_EQ
(
1
*
WORDS
,
message
->
getSegment
(
SegmentId
(
0
))
->
getSize
());
// root ref
EXPECT_EQ
(
7
*
WORDS
,
message
->
getSegment
(
SegmentId
(
1
))
->
getSize
());
// root struct
EXPECT_EQ
(
2
*
WORDS
,
message
->
getSegment
(
SegmentId
(
2
))
->
getSize
());
// sub-struct
...
...
c++/src/capnproto/wire-format.c++
View file @
e9fa0685
...
...
@@ -567,7 +567,7 @@ StructReader StructReader::readRootTrusted(const word* location, const word* def
StructReader
StructReader
::
readRoot
(
const
word
*
location
,
const
word
*
defaultValue
,
SegmentReader
*
segment
,
int
recursionLimit
)
{
if
(
segment
->
containsInterval
(
location
,
location
+
1
*
REFERENCES
*
WORDS_PER_REFERENCE
))
{
if
(
!
segment
->
containsInterval
(
location
,
location
+
1
*
REFERENCES
*
WORDS_PER_REFERENCE
))
{
segment
->
getMessage
()
->
reportInvalidData
(
"Root location out-of-bounds."
);
location
=
nullptr
;
}
...
...
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