2018-12-11 12:51:39 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <algorithm>
|
2019-06-21 06:22:46 +00:00
|
|
|
#include <toml.hpp>
|
2018-12-11 12:51:39 +00:00
|
|
|
|
|
|
|
// some of the parsers returns not only a value but also a region.
|
|
|
|
#define TOML11_TEST_PARSE_EQUAL(psr, tkn, expct) \
|
|
|
|
do { \
|
|
|
|
const std::string token(tkn); \
|
|
|
|
toml::detail::location<std::string> loc("test", token); \
|
|
|
|
const auto result = psr(loc); \
|
2019-06-21 06:22:46 +00:00
|
|
|
BOOST_TEST(result.is_ok()); \
|
2018-12-11 12:51:39 +00:00
|
|
|
if(result.is_ok()){ \
|
2019-06-21 06:22:46 +00:00
|
|
|
BOOST_TEST(result.unwrap().first == expct); \
|
2018-12-11 12:51:39 +00:00
|
|
|
} else { \
|
2019-06-21 06:22:46 +00:00
|
|
|
std::cerr << "parser " << #psr << " failed with input `"; \
|
|
|
|
std::cerr << token << "`.\n"; \
|
|
|
|
std::cerr << "reason: " << result.unwrap_err() << '\n'; \
|
2018-12-11 12:51:39 +00:00
|
|
|
} \
|
|
|
|
} while(false); \
|
|
|
|
/**/
|
|
|
|
|
2018-12-11 14:25:23 +00:00
|
|
|
#define TOML11_TEST_PARSE_EQUAL_VALUE(psr, tkn, expct) \
|
2018-12-11 12:51:39 +00:00
|
|
|
do { \
|
|
|
|
const std::string token(tkn); \
|
|
|
|
toml::detail::location<std::string> loc("test", token); \
|
2018-12-11 14:25:23 +00:00
|
|
|
const auto result = psr(loc); \
|
2019-06-21 06:22:46 +00:00
|
|
|
BOOST_TEST(result.is_ok()); \
|
2018-12-11 12:51:39 +00:00
|
|
|
if(result.is_ok()){ \
|
2019-06-21 06:22:46 +00:00
|
|
|
BOOST_TEST(result.unwrap() == expct); \
|
2018-12-11 12:51:39 +00:00
|
|
|
} else { \
|
2019-06-21 06:22:46 +00:00
|
|
|
std::cerr << "parse_value failed with input `"; \
|
|
|
|
std::cerr << token << "`.\n"; \
|
|
|
|
std::cerr << "reason: " << result.unwrap_err() << '\n'; \
|
2018-12-11 12:51:39 +00:00
|
|
|
} \
|
|
|
|
} while(false); \
|
|
|
|
/**/
|