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
bdfa0447
Commit
bdfa0447
authored
Apr 16, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test cases for ScanCopyUnescapedString
parent
a6f9cb85
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
2 deletions
+29
-2
simdtest.cpp
test/unittest/simdtest.cpp
+29
-2
No files found.
test/unittest/simdtest.cpp
View file @
bdfa0447
...
...
@@ -100,13 +100,15 @@ struct ScanCopyUnescapedStringHandler : BaseReaderHandler<UTF8<>, ScanCopyUnesca
memcpy
(
buffer
,
str
,
length
+
1
);
return
true
;
}
char
buffer
[
1024
+
5
];
char
buffer
[
1024
+
5
+
32
];
};
template
<
unsigned
parseFlags
,
typename
StreamType
>
void
TestScanCopyUnescapedString
()
{
char
buffer
[
1024
+
5
+
32
];
char
backup
[
1024
+
5
+
32
];
// Test "ABCDABCD...\\"
for
(
size_t
offset
=
0
;
offset
<
32
;
offset
++
)
{
for
(
size_t
step
=
0
;
step
<
1024
;
step
++
)
{
char
*
json
=
buffer
+
offset
;
...
...
@@ -118,16 +120,41 @@ void TestScanCopyUnescapedString() {
*
p
++
=
'\\'
;
*
p
++
=
'\"'
;
*
p
++
=
'\0'
;
strcpy
(
backup
,
json
);
// insitu parsing will overwrite buffer, so need to backup first
StreamType
s
(
json
);
Reader
reader
;
ScanCopyUnescapedStringHandler
h
;
reader
.
Parse
<
parseFlags
>
(
s
,
h
);
EXPECT_TRUE
(
memcmp
(
h
.
buffer
,
json
+
1
,
step
)
==
0
);
EXPECT_TRUE
(
memcmp
(
h
.
buffer
,
backup
+
1
,
step
)
==
0
);
EXPECT_EQ
(
'\\'
,
h
.
buffer
[
step
]);
// escaped
EXPECT_EQ
(
'\0'
,
h
.
buffer
[
step
+
1
]);
}
}
// Test "\\ABCDABCD..."
for
(
size_t
offset
=
0
;
offset
<
32
;
offset
++
)
{
for
(
size_t
step
=
0
;
step
<
1024
;
step
++
)
{
char
*
json
=
buffer
+
offset
;
char
*
p
=
json
;
*
p
++
=
'\"'
;
*
p
++
=
'\\'
;
*
p
++
=
'\\'
;
for
(
size_t
i
=
0
;
i
<
step
;
i
++
)
*
p
++
=
"ABCD"
[
i
%
4
];
*
p
++
=
'\"'
;
*
p
++
=
'\0'
;
strcpy
(
backup
,
json
);
// insitu parsing will overwrite buffer, so need to backup first
StreamType
s
(
json
);
Reader
reader
;
ScanCopyUnescapedStringHandler
h
;
reader
.
Parse
<
parseFlags
>
(
s
,
h
);
EXPECT_TRUE
(
memcmp
(
h
.
buffer
+
1
,
backup
+
3
,
step
)
==
0
);
EXPECT_EQ
(
'\\'
,
h
.
buffer
[
0
]);
// escaped
EXPECT_EQ
(
'\0'
,
h
.
buffer
[
step
+
1
]);
}
}
}
TEST
(
SIMD
,
SIMD_SUFFIX
(
ScanCopyUnescapedString
))
{
...
...
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