mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-09 14:20:06 +00:00
Factor redundant test boilerplate out into unit_test.hpp helper
This commit is contained in:
parent
b10348c576
commit
d7c04ed5ee
@ -1,9 +1,5 @@
|
||||
#define BOOST_TEST_MODULE "test_comments"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_datetime"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/datetime.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_local_date)
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_error_detection"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_expect"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_extended_conversions"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
|
@ -1,10 +1,5 @@
|
||||
#define BOOST_TEST_MODULE "test_find"
|
||||
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_find_or"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_find_or_recursive"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_format_error"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_get"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_get_or"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_lex_boolean"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/lexer.hpp>
|
||||
#include "test_lex_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_lex_datetime"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/lexer.hpp>
|
||||
#include "test_lex_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_lex_floating"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/lexer.hpp>
|
||||
#include <limits>
|
||||
#include "test_lex_aux.hpp"
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_lex_integer"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/lexer.hpp>
|
||||
#include "test_lex_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "lex_key_comment_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/lexer.hpp>
|
||||
#include "test_lex_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_lex_string"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/lexer.hpp>
|
||||
#include "test_lex_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_literals"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_array<toml::value>_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_parse_boolean"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_datetime_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,26 +1,11 @@
|
||||
#define BOOST_TEST_MODULE "test_parse_file"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <deque>
|
||||
#include <cstdlib>
|
||||
|
||||
static auto testinput(const std::string& basename) -> std::string
|
||||
{
|
||||
const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; };
|
||||
std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml");
|
||||
if (!directory.empty() && directory.back() != '/')
|
||||
{
|
||||
directory.push_back('/');
|
||||
}
|
||||
return directory.append("tests/").append(basename);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_example)
|
||||
{
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_floating_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include <cmath>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_inline_table_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_integer_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_key_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_string_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_table_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include <toml/get.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "parse_table_key_test"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/parser.hpp>
|
||||
#include "test_parse_aux.hpp"
|
||||
|
||||
|
@ -1,24 +1,9 @@
|
||||
#define BOOST_TEST_MODULE "test_parse_unicode"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
|
||||
static auto testinput(const std::string& basename) -> std::string
|
||||
{
|
||||
const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; };
|
||||
std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml");
|
||||
if (!directory.empty() && directory.back() != '/')
|
||||
{
|
||||
directory.push_back('/');
|
||||
}
|
||||
return directory.append("tests/").append(basename);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_hard_example_unicode)
|
||||
{
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_result"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <toml/result.hpp>
|
||||
|
||||
|
@ -1,11 +1,7 @@
|
||||
#define BOOST_TEST_MODULE "test_serialize_file"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <cstdlib>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
@ -45,17 +41,6 @@ bool has_comment_inside(const toml::basic_value<Comment, Table, Array>& v)
|
||||
return true;
|
||||
}
|
||||
|
||||
static auto testinput(const std::string& basename) -> std::string
|
||||
{
|
||||
const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; };
|
||||
std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml");
|
||||
if (!directory.empty() && directory.back() != '/')
|
||||
{
|
||||
directory.push_back('/');
|
||||
}
|
||||
return directory.append("tests/").append(basename);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_example)
|
||||
{
|
||||
const auto data = toml::parse(testinput("example.toml"));
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_string"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_basic_string)
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_traits"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/types.hpp>
|
||||
|
||||
#include <list>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_acceptor"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml/utility.hpp>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
@ -1,9 +1,6 @@
|
||||
#define BOOST_TEST_MODULE "test_value"
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
#include "unit_test.hpp"
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
23
tests/unit_test.hpp
Normal file
23
tests/unit_test.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef BOOST_TEST_MODULE
|
||||
# error "Please #define BOOST_TEST_MODULE before you #include <unit_test.hpp>"
|
||||
#endif
|
||||
|
||||
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
|
||||
# include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
# include <boost/test/included/unit_test.hpp>
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
static inline auto testinput(const std::string& basename) -> std::string
|
||||
{
|
||||
const auto this_or_that = [](const char *const s, const char *const t) { return s ? s : t; };
|
||||
std::string directory = this_or_that(std::getenv("TOMLDIR"), "toml");
|
||||
if (!directory.empty() && directory.back() != '/')
|
||||
{
|
||||
directory.push_back('/');
|
||||
}
|
||||
return directory.append("tests/").append(basename);
|
||||
}
|
Loading…
Reference in New Issue
Block a user