Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
2afbd334
Unverified
Commit
2afbd334
authored
May 10, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
working on #367
Test cases succeed as expected, but the example in #367 is not fully realized yet.
parent
962da001
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
4 deletions
+54
-4
json.hpp
src/json.hpp
+2
-2
unit-testsuites.cpp
test/src/unit-testsuites.cpp
+52
-2
No files found.
src/json.hpp
View file @
2afbd334
...
@@ -7618,7 +7618,7 @@ class basic_json
...
@@ -7618,7 +7618,7 @@ class basic_json
JSON_DEPRECATED
JSON_DEPRECATED
friend
std
::
istream
&
operator
<<
(
basic_json
&
j
,
std
::
istream
&
i
)
friend
std
::
istream
&
operator
<<
(
basic_json
&
j
,
std
::
istream
&
i
)
{
{
j
=
parser
(
input_adapter
::
create
(
i
)).
parse
(
tru
e
);
j
=
parser
(
input_adapter
::
create
(
i
)).
parse
(
fals
e
);
return
i
;
return
i
;
}
}
...
@@ -7650,7 +7650,7 @@ class basic_json
...
@@ -7650,7 +7650,7 @@ class basic_json
*/
*/
friend
std
::
istream
&
operator
>>
(
std
::
istream
&
i
,
basic_json
&
j
)
friend
std
::
istream
&
operator
>>
(
std
::
istream
&
i
,
basic_json
&
j
)
{
{
j
=
parser
(
input_adapter
::
create
(
i
)).
parse
(
tru
e
);
j
=
parser
(
input_adapter
::
create
(
i
)).
parse
(
fals
e
);
return
i
;
return
i
;
}
}
...
...
test/src/unit-testsuites.cpp
View file @
2afbd334
...
@@ -78,8 +78,26 @@ TEST_CASE("compliance tests from json.org")
...
@@ -78,8 +78,26 @@ TEST_CASE("compliance tests from json.org")
{
{
CAPTURE
(
filename
);
CAPTURE
(
filename
);
std
::
ifstream
f
(
filename
);
std
::
ifstream
f
(
filename
);
CHECK_THROWS_AS
(
json
::
parse
(
f
),
json
::
parse_error
);
}
}
SECTION
(
"no failures with trailing literals (relaxed)"
)
{
// these tests fail above, because the parser does not end on EOF;
// they succeed when the operator>> is used, because it does not
// have this constraint
for
(
auto
filename
:
{
"test/data/json_tests/fail7.json"
,
"test/data/json_tests/fail8.json"
,
"test/data/json_tests/fail10.json"
,
})
{
CAPTURE
(
filename
);
std
::
ifstream
f
(
filename
);
json
j
;
json
j
;
CHECK_
THROWS_AS
(
f
>>
j
,
json
::
parse_error
);
CHECK_
NOTHROW
(
f
>>
j
);
}
}
}
}
...
@@ -754,8 +772,40 @@ TEST_CASE("nst's JSONTestSuite")
...
@@ -754,8 +772,40 @@ TEST_CASE("nst's JSONTestSuite")
{
{
CAPTURE
(
filename
);
CAPTURE
(
filename
);
std
::
ifstream
f
(
filename
);
std
::
ifstream
f
(
filename
);
CHECK_THROWS_AS
(
json
::
parse
(
f
),
json
::
parse_error
);
}
}
SECTION
(
"n -> y (relaxed)"
)
{
// these tests fail above, because the parser does not end on EOF;
// they succeed when the operator>> is used, because it does not
// have this constraint
for
(
auto
filename
:
{
"test/data/nst_json_testsuite/test_parsing/n_array_comma_after_close.json"
,
"test/data/nst_json_testsuite/test_parsing/n_array_extra_close.json"
,
"test/data/nst_json_testsuite/test_parsing/n_object_trailing_comment.json"
,
"test/data/nst_json_testsuite/test_parsing/n_object_trailing_comment_open.json"
,
"test/data/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open.json"
,
"test/data/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open_incomplete.json"
,
"test/data/nst_json_testsuite/test_parsing/n_object_with_trailing_garbage.json"
,
"test/data/nst_json_testsuite/test_parsing/n_string_with_trailing_garbage.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_array_trailing_garbage.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_array_with_extra_array_close.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_close_unopened_array.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_double_array.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_number_with_trailing_garbage.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_object_followed_by_closing_object.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_object_with_trailing_garbage.json"
,
"test/data/nst_json_testsuite/test_parsing/n_structure_trailing_#.json"
}
)
{
CAPTURE
(
filename
);
std
::
ifstream
f
(
filename
);
json
j
;
json
j
;
CHECK_
THROWS_AS
(
f
>>
j
,
json
::
parse_error
);
CHECK_
NOTHROW
(
f
>>
j
);
}
}
}
}
...
...
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