/*-----------------------------------------------------------------------------+ Copyright (c) 2008-2009: Joachim Faulhaber +------------------------------------------------------------------------------+ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENCE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +-----------------------------------------------------------------------------*/ #define BOOST_TEST_MODULE icl::test_type_traits unit test #include #include #include #include #include #include #include #include "../unit_test_unwarned.hpp" // interval instance types #include "../test_type_lists.hpp" #include "../test_value_maker.hpp" #include #include #include #include #include "../test_laws.hpp" using namespace std; using namespace boost; using namespace unit_test; using namespace boost::icl; void digits_of_numeric_types() { cout << "--- limits ---\n"; cout << "max = " << (std::numeric_limits::max)() << endl; cout << "max = " << static_cast((std::numeric_limits::max)()) << endl; cout << "-----------------------------------\n"; cout << "digits = " << std::numeric_limits::digits << endl; cout << "digits = " << std::numeric_limits::digits << endl; cout << "digits = " << std::numeric_limits::digits << endl; cout << "digits = " << std::numeric_limits::digits << endl; cout << "digits> = " << std::numeric_limits >::digits << endl; cout << "digits = " << std::numeric_limits::digits << endl; } BOOST_AUTO_TEST_CASE(test_icl_infinity) { BOOST_CHECK_EQUAL(icl::infinity::value(), (std::numeric_limits::max)()); BOOST_CHECK(0 != icl::infinity::value()); } BOOST_AUTO_TEST_CASE_TEMPLATE(test_is_continuous_type_T, T, continuous_types) { BOOST_CHECK(is_continuous::value); BOOST_CHECK(!is_discrete::value); } BOOST_AUTO_TEST_CASE(test_is_continuous_type) { BOOST_CHECK(is_continuous >::value); BOOST_CHECK(!is_discrete >::value); } BOOST_AUTO_TEST_CASE_TEMPLATE(test_is_discrete_type_T, T, discrete_types) { BOOST_CHECK(is_discrete::value); BOOST_CHECK(!is_continuous::value); } BOOST_AUTO_TEST_CASE(test_is_discrete_type) { BOOST_CHECK(is_discrete::value); BOOST_CHECK(!is_continuous::value); } BOOST_AUTO_TEST_CASE(test_is_key_container_of) { BOOST_CHECK((!is_key_container_of >::value)); BOOST_CHECK((!is_key_container_of , icl::map >::value)); BOOST_CHECK(( is_key_container_of, std::set >::value)); BOOST_CHECK(( is_key_container_of, icl::map >::value)); BOOST_CHECK(( is_key_container_of, icl::map >::value)); } BOOST_AUTO_TEST_CASE(test_is_set_4_std_set) { BOOST_CHECK( (is_set >::value) ); BOOST_CHECK( (is_element_set >::value) ); BOOST_CHECK( (!is_map >::value) ); BOOST_CHECK( (is_set >::value) ); BOOST_CHECK( (is_element_set >::value) ); BOOST_CHECK( (!is_map >::value) ); } BOOST_AUTO_TEST_CASE(test_miscellaneous_type_traits) { typedef interval_set IntervalSetT; typedef icl::map MapII; BOOST_CHECK(has_codomain_type::value); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((is_map::value)); BOOST_CHECK((is_icl_container::value)); BOOST_CHECK((is_fragment_of::value)); BOOST_CHECK((is_fragment_of::value)); BOOST_CHECK((!is_fragment_of::value)); BOOST_CHECK((boost::detail::is_incrementable::value)); BOOST_CHECK((boost::detail::is_incrementable::value)); BOOST_CHECK((!boost::detail::is_incrementable::value)); BOOST_CHECK((boost::is_floating_point::value)); BOOST_CHECK((boost::is_floating_point::value)); BOOST_CHECK((boost::is_floating_point::value)); BOOST_CHECK( (boost::is_same >::type, int>::value) ); BOOST_CHECK( (boost::is_same >::type, int>::value) ); BOOST_CHECK( is_std_set >::value); BOOST_CHECK( !is_std_set >::value); BOOST_CHECK((!is_std_set >::value)); BOOST_CHECK( is_element_set >::value); BOOST_CHECK( !is_interval_set >::value); BOOST_CHECK( !is_interval_set >::value); }