2
0
mirror of https://github.com/boostorg/json.git synced 2026-01-19 04:12:14 +00:00
Files
json/test/parse.cpp
Vinnie Falco 3204021a90 parse fixes and tests
fix #305
2020-09-08 17:20:45 -07:00

59 lines
1.0 KiB
C++

//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/json
//
// Test that header file is self-contained.
#include <boost/json/parse.hpp>
#include <boost/json/serialize.hpp>
#include "test_suite.hpp"
BOOST_JSON_NS_BEGIN
class parse_test
{
public:
void
good(string_view s)
{
error_code ec;
auto jv = parse(s, ec);
if(! BOOST_TEST(! ec))
return;
BOOST_TEST(
serialize(jv) == s);
}
void
bad(string_view s)
{
error_code ec;
auto jv = parse(s, ec);
BOOST_TEST(ec);
}
void
testParse()
{
good("null");
good("[1,2,3]");
bad ("[1,2,3] #");
}
void
run()
{
testParse();
}
};
TEST_SUITE(parse_test, "boost.json.parse");
BOOST_JSON_NS_END