Commit ef283e0c authored by Jonathan Dumaresq's avatar Jonathan Dumaresq

add tests to cover the new input adapter

parent 3335da62
...@@ -52,18 +52,18 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us ...@@ -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 class file_input_adapter : public input_adapter_protocol
{ {
public: public:
explicit file_input_adapter(const FILE *file) noexcept explicit file_input_adapter(const FILE* file) noexcept
: file(file) : file(file)
{} {}
std::char_traits<char>::int_type get_character() noexcept override 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 /// the file pointer to read from
const FILE * file; const FILE* file;
}; };
...@@ -309,8 +309,8 @@ class input_adapter ...@@ -309,8 +309,8 @@ class input_adapter
{ {
public: public:
// native support // native support
input_adapter(FILE * file) input_adapter(FILE* file)
: ia(std::make_shared<file_input_adapter>(file)) {} : ia(std::make_shared<file_input_adapter>(file)) {}
/// input adapter for input stream /// input adapter for input stream
input_adapter(std::istream& i) input_adapter(std::istream& i)
: ia(std::make_shared<input_stream_adapter>(i)) {} : ia(std::make_shared<input_stream_adapter>(i)) {}
......
...@@ -384,6 +384,46 @@ TEST_CASE("json.org examples") ...@@ -384,6 +384,46 @@ TEST_CASE("json.org examples")
json j; json j;
CHECK_NOTHROW(f >> 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") TEST_CASE("RFC 7159 examples")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment