From 0260a13f1c6b79298b10de72b8122aeb66ec9c92 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 19 Apr 2017 22:47:24 +0900 Subject: [PATCH] make tests/ and toml/ dir and move codes --- test.cpp => tests/test.cpp | 0 tests/test_traits.cpp | 89 ++++++++++++++++++++++++++++++++++++++ toml.hpp => toml/toml.hpp | 48 +++----------------- 3 files changed, 94 insertions(+), 43 deletions(-) rename test.cpp => tests/test.cpp (100%) create mode 100644 tests/test_traits.cpp rename toml.hpp => toml/toml.hpp (95%) diff --git a/test.cpp b/tests/test.cpp similarity index 100% rename from test.cpp rename to tests/test.cpp diff --git a/tests/test_traits.cpp b/tests/test_traits.cpp new file mode 100644 index 0000000..58083b8 --- /dev/null +++ b/tests/test_traits.cpp @@ -0,0 +1,89 @@ +#define BOOST_TEST_MODULE "test_traits" +#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST +#include +#else +#define BOOST_TEST_NO_LIB +#include +#endif +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct dummy_type{}; + +template +struct dummy_container +{ + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef value_type const* const_pointer; + typedef value_type const& const_reference; + typedef pointer iterator; + typedef const_pointer const_iterator; +}; + +typedef std::array std_array_type; +typedef std::map std_map_type; +typedef std::unordered_map std_unordered_map_type; + +BOOST_AUTO_TEST_CASE(test_has_xxx) +{ + BOOST_CHECK(toml::detail::has_iterator>::value); + BOOST_CHECK(toml::detail::has_iterator>::value); + BOOST_CHECK(toml::detail::has_iterator>::value); + BOOST_CHECK(toml::detail::has_iterator>::value); + BOOST_CHECK(toml::detail::has_iterator>::value); + BOOST_CHECK(toml::detail::has_iterator>::value); + BOOST_CHECK(toml::detail::has_iterator::value); + BOOST_CHECK(toml::detail::has_iterator::value); + BOOST_CHECK(toml::detail::has_iterator::value); + BOOST_CHECK(toml::detail::has_iterator>::value); + + BOOST_CHECK(toml::detail::has_value_type>::value); + BOOST_CHECK(toml::detail::has_value_type>::value); + BOOST_CHECK(toml::detail::has_value_type>::value); + BOOST_CHECK(toml::detail::has_value_type>::value); + BOOST_CHECK(toml::detail::has_value_type::value); + BOOST_CHECK(toml::detail::has_value_type>::value); + BOOST_CHECK(toml::detail::has_value_type>::value); + BOOST_CHECK(toml::detail::has_value_type::value); + BOOST_CHECK(toml::detail::has_value_type::value); + BOOST_CHECK(toml::detail::has_value_type>::value); + + BOOST_CHECK(toml::detail::has_key_type::value); + BOOST_CHECK(toml::detail::has_key_type::value); + BOOST_CHECK(toml::detail::has_mapped_type::value); + BOOST_CHECK(toml::detail::has_mapped_type::value); +} + +BOOST_AUTO_TEST_CASE(test_is_xxx) +{ + BOOST_CHECK(toml::detail::is_container>::value); + BOOST_CHECK(toml::detail::is_container>::value); + BOOST_CHECK(toml::detail::is_container>::value); + BOOST_CHECK(toml::detail::is_container>::value); + BOOST_CHECK(toml::detail::is_container::value); + BOOST_CHECK(toml::detail::is_container>::value); + BOOST_CHECK(toml::detail::is_container>::value); + BOOST_CHECK(toml::detail::is_container::value); + BOOST_CHECK(toml::detail::is_container::value); + BOOST_CHECK(toml::detail::is_container>::value); + + BOOST_CHECK(toml::detail::is_map::value); + BOOST_CHECK(toml::detail::is_map::value); + + BOOST_CHECK(toml::detail::is_key_convertible::value); + BOOST_CHECK(toml::detail::is_key_convertible::value); +} + + + diff --git a/toml.hpp b/toml/toml.hpp similarity index 95% rename from toml.hpp rename to toml/toml.hpp index 2a5c24e..a389e9b 100644 --- a/toml.hpp +++ b/toml/toml.hpp @@ -751,50 +751,12 @@ value::cast() /* -------------------------------------------------------------------------- */ -namespace detail -{ -template -struct to_toml_impl -{ - typedef T result_type; - static_assert(toml::is_castable::value, - "type is not castable to any toml value type"); - - static toml::value invoke(const T& v) - { - return toml::value(v); - } - static toml::value invoke(T&& v) - { - return toml::value(std::move(v)); - } -}; - -template -struct to_toml_impl -{ - typedef T result_type; - - static toml::value invoke(const T& v) - { - return toml::is_same::value ? v : - toml::is_castable::value ? invoke_table(v) : - toml::is_castable::value ? invoke_array(v) : - toml::value(); - } - static toml::value invoke(T&& v) - { - } -}; - -} - -template()> -inline toml::value to_toml(T&& x) -{ - return detail::to_toml_impl::invoke(std::forward(x)); -} +// template()> +// inline toml::value to_toml(T&& x) +// { +// return detail::to_toml_impl::invoke(std::forward(x)); +// }