mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-12-24 02:11:03 +00:00
test: add test_serialize_file
This commit is contained in:
parent
5bdc022627
commit
4bbe42d105
@ -25,6 +25,7 @@ set(TEST_NAMES
|
||||
test_to_toml
|
||||
test_from_toml
|
||||
test_parse_file
|
||||
test_serialize_file
|
||||
test_parse_unicode
|
||||
test_error_detection
|
||||
)
|
||||
|
44
tests/test_serialize_file.cpp
Normal file
44
tests/test_serialize_file.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#define BOOST_TEST_MODULE "test_serialize_file"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#define BOOST_TEST_NO_LIB
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include <toml.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_example)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/example.toml");
|
||||
{
|
||||
std::ofstream ofs("tmp1.toml");
|
||||
ofs << data;
|
||||
}
|
||||
const auto serialized = toml::parse("tmp1.toml");
|
||||
BOOST_CHECK(data == serialized);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_fruit)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/fruit.toml");
|
||||
{
|
||||
std::ofstream ofs("tmp2.toml");
|
||||
ofs << data;
|
||||
}
|
||||
const auto serialized = toml::parse("tmp2.toml");
|
||||
BOOST_CHECK(data == serialized);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_hard_example)
|
||||
{
|
||||
const auto data = toml::parse("toml/tests/hard_example.toml");
|
||||
{
|
||||
std::ofstream ofs("tmp3.toml");
|
||||
ofs << data;
|
||||
}
|
||||
const auto serialized = toml::parse("tmp3.toml");
|
||||
BOOST_CHECK(data == serialized);
|
||||
}
|
Loading…
Reference in New Issue
Block a user