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
ef283e0c
Commit
ef283e0c
authored
Dec 12, 2018
by
Jonathan Dumaresq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests to cover the new input adapter
parent
3335da62
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
6 deletions
+46
-6
input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+6
-6
unit-testsuites.cpp
test/src/unit-testsuites.cpp
+40
-0
No files found.
include/nlohmann/detail/input/input_adapters.hpp
View file @
ef283e0c
...
...
@@ -52,18 +52,18 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us
*/
class
file_input_adapter
:
public
input_adapter_protocol
{
public
:
explicit
file_input_adapter
(
const
FILE
*
file
)
noexcept
public
:
explicit
file_input_adapter
(
const
FILE
*
file
)
noexcept
:
file
(
file
)
{}
std
::
char_traits
<
char
>::
int_type
get_character
()
noexcept
override
{
return
fgetc
(
const_cast
<
FILE
*>
(
file
));
return
fgetc
(
const_cast
<
FILE
*>
(
file
));
}
private
:
private
:
/// the file pointer to read from
const
FILE
*
file
;
const
FILE
*
file
;
};
...
...
@@ -309,7 +309,7 @@ class input_adapter
{
public
:
// native support
input_adapter
(
FILE
*
file
)
input_adapter
(
FILE
*
file
)
:
ia
(
std
::
make_shared
<
file_input_adapter
>
(
file
))
{}
/// input adapter for input stream
input_adapter
(
std
::
istream
&
i
)
...
...
test/src/unit-testsuites.cpp
View file @
ef283e0c
...
...
@@ -384,6 +384,46 @@ TEST_CASE("json.org examples")
json
j
;
CHECK_NOTHROW
(
f
>>
j
);
}
SECTION
(
"FILE 1.json"
)
{
auto
f
=
fopen
(
"test/data/json.org/1.json"
,
"r"
);
json
j
;
CHECK_NOTHROW
(
j
.
parse
(
f
));
fclose
(
f
);
}
SECTION
(
"FILE 2.json"
)
{
auto
f
=
fopen
(
"test/data/json.org/2.json"
,
"r"
);
json
j
;
CHECK_NOTHROW
(
j
.
parse
(
f
));
fclose
(
f
);
}
SECTION
(
"FILE 3.json"
)
{
auto
f
=
fopen
(
"test/data/json.org/3.json"
,
"r"
);
json
j
;
CHECK_NOTHROW
(
j
.
parse
(
f
));
fclose
(
f
);
}
SECTION
(
"FILE 4.json"
)
{
auto
f
=
fopen
(
"test/data/json.org/4.json"
,
"r"
);
json
j
;
CHECK_NOTHROW
(
j
.
parse
(
f
));
fclose
(
f
);
}
SECTION
(
"FILE 5.json"
)
{
auto
f
=
fopen
(
"test/data/json.org/5.json"
,
"r"
);
json
j
;
CHECK_NOTHROW
(
j
.
parse
(
f
));
fclose
(
f
);
}
}
TEST_CASE
(
"RFC 7159 examples"
)
...
...
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