Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
10bbb774
Commit
10bbb774
authored
May 03, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test case for filter function
parent
1143094e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
test/unit.cpp
test/unit.cpp
+37
-5
No files found.
test/unit.cpp
View file @
10bbb774
...
...
@@ -7687,8 +7687,8 @@ TEST_CASE("parser class")
{
auto
s_object
=
R"(
{
"foo":
true
,
"bar":
false
"foo":
1
,
"bar":
2
}
)"
;
...
...
@@ -7696,14 +7696,14 @@ TEST_CASE("parser class")
[1,2,3,4,5]
)"
;
SECTION
(
"
true-filter
"
)
SECTION
(
"
filter nothing
"
)
{
json
j_object
=
json
::
parse
(
s_object
,
[](
int
,
json
::
parse_event_t
,
const
json
&
)
{
return
true
;
});
CHECK
(
j_object
==
json
({{
"foo"
,
true
},
{
"bar"
,
false
}}));
CHECK
(
j_object
==
json
({{
"foo"
,
1
},
{
"bar"
,
2
}}));
json
j_array
=
json
::
parse
(
s_array
,
[](
int
,
json
::
parse_event_t
,
const
json
&
)
{
...
...
@@ -7713,7 +7713,7 @@ TEST_CASE("parser class")
CHECK
(
j_array
==
json
({
1
,
2
,
3
,
4
,
5
}));
}
SECTION
(
"f
alse-filter
"
)
SECTION
(
"f
ilter everything
"
)
{
json
j_object
=
json
::
parse
(
s_object
,
[](
int
,
json
::
parse_event_t
,
const
json
&
)
{
...
...
@@ -7729,6 +7729,38 @@ TEST_CASE("parser class")
CHECK
(
j_array
.
is_discarded
());
}
SECTION
(
"filter specific element"
)
{
json
j_object
=
json
::
parse
(
s_object
,
[](
int
,
json
::
parse_event_t
,
const
json
&
j
)
{
// filter all number(2) elements
if
(
j
==
json
(
2
))
{
return
false
;
}
else
{
return
true
;
}
});
CHECK
(
j_object
==
json
({{
"foo"
,
1
}}));
json
j_array
=
json
::
parse
(
s_array
,
[](
int
,
json
::
parse_event_t
,
const
json
&
j
)
{
if
(
j
==
json
(
2
))
{
return
false
;
}
else
{
return
true
;
}
});
CHECK
(
j_array
==
json
({
1
,
3
,
4
,
5
}));
}
}
}
...
...
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