use FetchContent to retrieve TOML test data

This commit is contained in:
Jordan Williams
2020-02-18 19:37:28 -06:00
parent ac1130f9f4
commit 4c34986db0
7 changed files with 74 additions and 26 deletions

View File

@@ -10,6 +10,7 @@
#include <map>
#include <iostream>
#include <fstream>
#include <toml11/test/files.hpp>
template<typename Comment,
template<typename ...> class Table,
@@ -46,7 +47,7 @@ bool has_comment_inside(const toml::basic_value<Comment, Table, Array>& v)
BOOST_AUTO_TEST_CASE(test_example)
{
const auto data = toml::parse("toml/tests/example.toml");
const auto data = toml::parse(toml::test::file::example);
{
std::ofstream ofs("tmp1.toml");
ofs << std::setw(80) << data;
@@ -68,7 +69,7 @@ BOOST_AUTO_TEST_CASE(test_example)
BOOST_AUTO_TEST_CASE(test_example_map_dq)
{
const auto data = toml::parse<toml::discard_comments, std::map, std::deque>(
"toml/tests/example.toml");
toml::test::file::example);
{
std::ofstream ofs("tmp1_map_dq.toml");
ofs << std::setw(80) << data;
@@ -90,7 +91,7 @@ BOOST_AUTO_TEST_CASE(test_example_map_dq)
BOOST_AUTO_TEST_CASE(test_example_with_comment)
{
const auto data = toml::parse<toml::preserve_comments>("toml/tests/example.toml");
const auto data = toml::parse<toml::preserve_comments>(toml::test::file::example);
{
std::ofstream ofs("tmp1_com.toml");
ofs << std::setw(80) << data;
@@ -116,7 +117,7 @@ BOOST_AUTO_TEST_CASE(test_example_with_comment)
BOOST_AUTO_TEST_CASE(test_example_with_comment_nocomment)
{
{
const auto data = toml::parse<toml::preserve_comments>("toml/tests/example.toml");
const auto data = toml::parse<toml::preserve_comments>(toml::test::file::example);
{
std::ofstream ofs("tmp1_com_nocomment.toml");
ofs << std::setw(80) << toml::nocomment << data;
@@ -126,7 +127,7 @@ BOOST_AUTO_TEST_CASE(test_example_with_comment_nocomment)
BOOST_TEST(!has_comment_inside(serialized));
}
{
const auto data_nocomment = toml::parse("toml/tests/example.toml");
const auto data_nocomment = toml::parse(toml::test::file::example);
auto serialized = toml::parse("tmp1_com_nocomment.toml");
{
auto& owner = toml::find(serialized, "owner");
@@ -145,7 +146,7 @@ BOOST_AUTO_TEST_CASE(test_example_with_comment_nocomment)
BOOST_AUTO_TEST_CASE(test_example_with_comment_map_dq)
{
const auto data = toml::parse<toml::preserve_comments, std::map, std::deque>(
"toml/tests/example.toml");
toml::test::file::example);
{
std::ofstream ofs("tmp1_com_map_dq.toml");
ofs << std::setw(80) << data;
@@ -172,7 +173,8 @@ BOOST_AUTO_TEST_CASE(test_example_with_comment_map_dq)
BOOST_AUTO_TEST_CASE(test_example_with_comment_map_dq_nocomment)
{
{
const auto data = toml::parse<toml::preserve_comments, std::map, std::deque>("toml/tests/example.toml");
const auto data = toml::parse<toml::preserve_comments, std::map, std::deque>(
toml::test::file::example);
{
std::ofstream ofs("tmp1_com_map_dq_nocomment.toml");
ofs << std::setw(80) << toml::nocomment << data;
@@ -181,7 +183,7 @@ BOOST_AUTO_TEST_CASE(test_example_with_comment_map_dq_nocomment)
BOOST_TEST(!has_comment_inside(serialized));
}
{
const auto data_nocomment = toml::parse("toml/tests/example.toml");
const auto data_nocomment = toml::parse(toml::test::file::example);
auto serialized = toml::parse("tmp1_com_map_dq_nocomment.toml");
{
auto& owner = toml::find(serialized, "owner");
@@ -198,7 +200,7 @@ BOOST_AUTO_TEST_CASE(test_example_with_comment_map_dq_nocomment)
BOOST_AUTO_TEST_CASE(test_fruit)
{
const auto data = toml::parse("toml/tests/fruit.toml");
const auto data = toml::parse(toml::test::file::fruit);
{
std::ofstream ofs("tmp2.toml");
ofs << std::setw(80) << data;
@@ -210,7 +212,7 @@ BOOST_AUTO_TEST_CASE(test_fruit)
BOOST_AUTO_TEST_CASE(test_fruit_map_dq)
{
const auto data = toml::parse<toml::discard_comments, std::map, std::deque>(
"toml/tests/fruit.toml");
toml::test::file::fruit);
{
std::ofstream ofs("tmp2.toml");
ofs << std::setw(80) << data;
@@ -222,7 +224,7 @@ BOOST_AUTO_TEST_CASE(test_fruit_map_dq)
BOOST_AUTO_TEST_CASE(test_fruit_with_comments)
{
const auto data = toml::parse<toml::preserve_comments>("toml/tests/fruit.toml");
const auto data = toml::parse<toml::preserve_comments>(toml::test::file::fruit);
{
std::ofstream ofs("tmp2_com.toml");
ofs << std::setw(80) << data;
@@ -234,7 +236,7 @@ BOOST_AUTO_TEST_CASE(test_fruit_with_comments)
BOOST_AUTO_TEST_CASE(test_fruit_with_comments_map_dq)
{
const auto data = toml::parse<toml::preserve_comments, std::map, std::deque>(
"toml/tests/fruit.toml");
toml::test::file::fruit);
{
std::ofstream ofs("tmp2_com.toml");
ofs << std::setw(80) << data;
@@ -245,7 +247,7 @@ BOOST_AUTO_TEST_CASE(test_fruit_with_comments_map_dq)
BOOST_AUTO_TEST_CASE(test_hard_example)
{
const auto data = toml::parse("toml/tests/hard_example.toml");
const auto data = toml::parse(toml::test::file::hard_example);
{
std::ofstream ofs("tmp3.toml");
ofs << std::setw(80) << data;
@@ -257,7 +259,7 @@ BOOST_AUTO_TEST_CASE(test_hard_example)
BOOST_AUTO_TEST_CASE(test_hard_example_map_dq)
{
const auto data = toml::parse<toml::discard_comments, std::map, std::deque>(
"toml/tests/hard_example.toml");
toml::test::file::hard_example);
{
std::ofstream ofs("tmp3.toml");
ofs << std::setw(80) << data;
@@ -270,7 +272,7 @@ BOOST_AUTO_TEST_CASE(test_hard_example_map_dq)
BOOST_AUTO_TEST_CASE(test_hard_example_with_comment)
{
const auto data = toml::parse<toml::preserve_comments, std::map, std::deque>(
"toml/tests/hard_example.toml");
toml::test::file::hard_example);
{
std::ofstream ofs("tmp3_com.toml");
ofs << std::setw(80) << data;