test: add basic_value type to serialization tests

This commit is contained in:
ToruNiina
2019-06-21 15:22:46 +09:00
parent dd9b04ae3b
commit 90918b6d76
7 changed files with 1040 additions and 930 deletions

View File

@@ -1,8 +1,7 @@
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <toml/region.hpp>
#include <toml/result.hpp>
#include <toml.hpp>
// some of the parsers returns not only a value but also a region.
#define TOML11_TEST_PARSE_EQUAL(psr, tkn, expct) \
@@ -10,13 +9,13 @@ do { \
const std::string token(tkn); \
toml::detail::location<std::string> loc("test", token); \
const auto result = psr(loc); \
BOOST_CHECK(result.is_ok()); \
BOOST_TEST(result.is_ok()); \
if(result.is_ok()){ \
BOOST_CHECK(result.unwrap().first == expct); \
BOOST_TEST(result.unwrap().first == expct); \
} else { \
std::cerr << "parser " << #psr << " failed with input `"; \
std::cerr << token << "`.\n"; \
std::cerr << "reason: " << result.unwrap_err() << '\n'; \
std::cerr << "parser " << #psr << " failed with input `"; \
std::cerr << token << "`.\n"; \
std::cerr << "reason: " << result.unwrap_err() << '\n'; \
} \
} while(false); \
/**/
@@ -26,13 +25,13 @@ do { \
const std::string token(tkn); \
toml::detail::location<std::string> loc("test", token); \
const auto result = psr(loc); \
BOOST_CHECK(result.is_ok()); \
BOOST_TEST(result.is_ok()); \
if(result.is_ok()){ \
BOOST_CHECK(result.unwrap() == expct); \
BOOST_TEST(result.unwrap() == expct); \
} else { \
std::cerr << "parse_value failed with input `"; \
std::cerr << token << "`.\n"; \
std::cerr << "reason: " << result.unwrap_err() << '\n'; \
std::cerr << "parse_value failed with input `"; \
std::cerr << token << "`.\n"; \
std::cerr << "reason: " << result.unwrap_err() << '\n'; \
} \
} while(false); \
/**/