/*-----------------------------------------------------------------------------+ 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::casual unit test #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 using namespace std; using namespace boost; using namespace unit_test; using namespace boost::icl; templateclass IsCombinable, class LeftT, class RightT> void check_combinable(bool expected, const char* type_combi, const char* combi_text) { std::string type_combination = type_combi; std::string is_combi_text = combi_text; bool is_combinable = IsCombinable::value; std::string combination_result = is_combinable ? (is_combinable == expected ? type_combination : "expected: NOT "+is_combi_text+"<"+type_combination+">") : (is_combinable == expected ? type_combination : "expected: IS "+is_combi_text+"<"+type_combination+">"); //BOOST_CHECK_EQUAL(expected, is_combinable); BOOST_CHECK_EQUAL(type_combination, combination_result); } templateclass IsCombinable> void check_combine_pattern(const char* text, bool jS_e, bool jS_i, bool jS_b, bool jS_p, bool jS_jS, bool jS_zS, bool jS_sS, bool jS_jM, bool jS_sM, bool zS_e, bool zS_i, bool zS_b, bool zS_p, bool zS_jS, bool zS_zS, bool zS_sS, bool zS_jM, bool zS_sM, bool sS_e, bool sS_i, bool sS_b, bool sS_p, bool sS_jS, bool sS_zS, bool sS_sS, bool sS_jM, bool sS_sM, bool jM_e, bool jM_i, bool jM_b, bool jM_p, bool jM_jS, bool jM_zS, bool jM_sS, bool jM_jM, bool jM_sM, bool sM_e, bool sM_i, bool sM_b, bool sM_p, bool sM_jS, bool sM_zS, bool sM_sS, bool sM_jM, bool sM_sM, bool check_base_class = true ) { typedef interval_set jS; typedef separate_interval_set zS; typedef split_interval_set sS; typedef interval_map jM; typedef split_interval_map sM; typedef interval_base_set jT; typedef interval_base_set zT; typedef interval_base_set sT; typedef interval_base_map jN; typedef interval_base_map sN; typedef interval_set::element_type S_e; typedef interval_set::segment_type S_i; typedef interval_map::element_type M_b; typedef interval_map::segment_type M_p; //-------------------------------------------------------------------------- check_combinable(jS_e , "jS_e ", text); check_combinable(jS_i , "jS_i ", text); check_combinable(jS_b , "jS_b ", text); check_combinable(jS_p , "jS_p ", text); check_combinable(jS_jS, "jS_jS", text); check_combinable(jS_zS, "jS_zS", text); check_combinable(jS_sS, "jS_sS", text); check_combinable(jS_jM, "jS_jM", text); check_combinable(jS_sM, "jS_sM", text); //-------------------------------------------------------------------------- check_combinable(zS_e , "zS_e ", text); check_combinable(zS_i , "zS_i ", text); check_combinable(zS_b , "zS_b ", text); check_combinable(zS_p , "zS_p ", text); check_combinable(zS_jS, "zS_jS", text); check_combinable(zS_zS, "zS_zS", text); check_combinable(zS_sS, "zS_sS", text); check_combinable(zS_jM, "zS_jM", text); check_combinable(zS_sM, "zS_sM", text); //-------------------------------------------------------------------------- check_combinable(sS_e , "sS_e ", text); check_combinable(sS_i , "sS_i ", text); check_combinable(sS_b , "sS_b ", text); check_combinable(sS_p , "sS_p ", text); check_combinable(sS_jS, "sS_jS", text); check_combinable(sS_zS, "sS_zS", text); check_combinable(sS_sS, "sS_sS", text); check_combinable(sS_jM, "sS_jM", text); check_combinable(sS_sM, "sS_sM", text); //-------------------------------------------------------------------------- check_combinable(jM_e , "jM_e ", text); check_combinable(jM_i , "jM_i ", text); check_combinable(jM_b , "jM_b ", text); check_combinable(jM_p , "jM_p ", text); check_combinable(jM_jS, "jM_jS", text); check_combinable(jM_zS, "jM_zS", text); check_combinable(jM_sS, "jM_sS", text); check_combinable(jM_jM, "jM_jM", text); check_combinable(jM_sM, "jM_sM", text); //-------------------------------------------------------------------------- check_combinable(sM_e , "sM_e ", text); check_combinable(sM_i , "sM_i ", text); check_combinable(sM_b , "sM_b ", text); check_combinable(sM_p , "sM_p ", text); check_combinable(sM_jS, "sM_jS", text); check_combinable(sM_zS, "sM_zS", text); check_combinable(sM_sS, "sM_sS", text); check_combinable(sM_jM, "sM_jM", text); check_combinable(sM_sM, "sM_sM", text); //-------------------------------------------------------------------------- if(check_base_class) { //-------------------------------------------------------------------------- check_combinable(jS_e , "jT_e ", text); check_combinable(jS_i , "jT_i ", text); check_combinable(jS_b , "jT_b ", text); check_combinable(jS_p , "jT_p ", text); check_combinable(jS_jS, "jT_jS", text); check_combinable(jS_zS, "jT_zS", text); check_combinable(jS_sS, "jT_sS", text); check_combinable(jS_jM, "jT_jM", text); check_combinable(jS_sM, "jT_sM", text); check_combinable(jS_jS, "jT_jT", text); check_combinable(jS_zS, "jT_zT", text); check_combinable(jS_sS, "jT_sT", text); check_combinable(jS_jM, "jT_jN", text); check_combinable(jS_sM, "jT_sN", text); //-------------------------------------------------------------------------- check_combinable(zS_e , "zT_e ", text); check_combinable(zS_i , "zT_i ", text); check_combinable(zS_b , "zT_b ", text); check_combinable(zS_p , "zT_p ", text); check_combinable(zS_jS, "zT_jS", text); check_combinable(zS_zS, "zT_zS", text); check_combinable(zS_sS, "zT_sS", text); check_combinable(zS_jM, "zT_jM", text); check_combinable(zS_sM, "zT_sM", text); check_combinable(zS_jS, "zT_jT", text); check_combinable(zS_zS, "zT_zT", text); check_combinable(zS_sS, "zT_sT", text); check_combinable(zS_jM, "zT_jN", text); check_combinable(zS_sM, "zT_sN", text); //-------------------------------------------------------------------------- check_combinable(sS_e , "sT_e ", text); check_combinable(sS_i , "sT_i ", text); check_combinable(sS_b , "sT_b ", text); check_combinable(sS_p , "sT_p ", text); check_combinable(sS_jS, "sT_jS", text); check_combinable(sS_zS, "sT_zS", text); check_combinable(sS_sS, "sT_sS", text); check_combinable(sS_jM, "sT_jM", text); check_combinable(sS_sM, "sT_sM", text); check_combinable(sS_jS, "sT_jT", text); check_combinable(sS_zS, "sT_zT", text); check_combinable(sS_sS, "sT_sT", text); check_combinable(sS_jM, "sT_jN", text); check_combinable(sS_sM, "sT_sN", text); //-------------------------------------------------------------------------- check_combinable(jM_e , "jN_e ", text); check_combinable(jM_i , "jN_i ", text); check_combinable(jM_b , "jN_b ", text); check_combinable(jM_p , "jN_p ", text); check_combinable(jM_jS, "jN_jS", text); check_combinable(jM_zS, "jN_zS", text); check_combinable(jM_sS, "jN_sS", text); check_combinable(jM_jM, "jN_jM", text);// check_combinable(jM_sM, "jN_sM", text);// check_combinable(jM_jS, "jN_jT", text); check_combinable(jM_zS, "jN_zT", text); check_combinable(jM_sS, "jN_sT", text); check_combinable(jM_jM, "jN_jN", text);// check_combinable(jM_sM, "jN_sN", text);// //-------------------------------------------------------------------------- check_combinable(sM_e , "sN_e ", text); check_combinable(sM_i , "sN_i ", text); check_combinable(sM_b , "sN_b ", text); check_combinable(sM_p , "sN_p ", text); check_combinable(sM_jS, "sN_jS", text); check_combinable(sM_zS, "sN_zS", text); check_combinable(sM_sS, "sN_sS", text); check_combinable(sM_jM, "sN_jM", text); check_combinable(sM_sM, "sN_sM", text); check_combinable(sM_jS, "sN_jT", text); check_combinable(sM_zS, "sN_zT", text); check_combinable(sM_sS, "sN_sT", text); check_combinable(sM_jM, "sN_jN", text); check_combinable(sM_sM, "sN_sN", text); } } BOOST_AUTO_TEST_CASE(test_icl_is_derivative) { //-------------------------------------------------------------------------- // 1.1 check_combine_pattern( "is_intra_derivative", // e i b p jS zS sS jM sM 1, 1, 0, 0, 0, 0, 0, 0, 0, // jS 1, 1, 0, 0, 0, 0, 0, 0, 0, // zS 1, 1, 0, 0, 0, 0, 0, 0, 0, // sS 0, 0, 1, 1, 0, 0, 0, 0, 0, // jM 0, 0, 1, 1, 0, 0, 0, 0, 0 // sM ); //-------------------------------------------------------------------------- // 1.2 check_combine_pattern( "is_cross_derivative", // e i b p jS zS sS jM sM 0, 0, 0, 0, 0, 0, 0, 0, 0, // jS 0, 0, 0, 0, 0, 0, 0, 0, 0, // zS 0, 0, 0, 0, 0, 0, 0, 0, 0, // sS 1, 1, 0, 0, 0, 0, 0, 0, 0, // jM 1, 1, 0, 0, 0, 0, 0, 0, 0 // sM ); //-------------------------------------------------------------------------- // 1.3 check_combine_pattern( "is_inter_derivative", // e i b p jS zS sS jM sM 1, 1, 0, 0, 0, 0, 0, 0, 0, // jS 1, 1, 0, 0, 0, 0, 0, 0, 0, // zS 1, 1, 0, 0, 0, 0, 0, 0, 0, // sS 1, 1, 1, 1, 0, 0, 0, 0, 0, // jM 1, 1, 1, 1, 0, 0, 0, 0, 0 // sM ); } BOOST_AUTO_TEST_CASE(test_icl_is_combinable) { //-------------------------------------------------------------------------- // 2.1 check_combine_pattern( "is_intra_combinable", // e i b p jS zS sS jM sM 0, 0, 0, 0, 1, 1, 1, 0, 0, // jS 0, 0, 0, 0, 1, 1, 1, 0, 0, // zS 0, 0, 0, 0, 1, 1, 1, 0, 0, // sS 0, 0, 0, 0, 0, 0, 0, 1, 1, // jM 0, 0, 0, 0, 0, 0, 0, 1, 1 // sM ); //-------------------------------------------------------------------------- // 2.2 check_combine_pattern( "is_cross_combinable", // e i b p jS zS sS jM sM 0, 0, 0, 0, 0, 0, 0, 1, 1, // jS 0, 0, 0, 0, 0, 0, 0, 1, 1, // zS 0, 0, 0, 0, 0, 0, 0, 1, 1, // sS 0, 0, 0, 0, 1, 1, 1, 0, 0, // jM 0, 0, 0, 0, 1, 1, 1, 0, 0 // sM ); //-------------------------------------------------------------------------- // 2.3 check_combine_pattern( "is_inter_combinable", // e i b p jS zS sS jM sM 0, 0, 0, 0, 1, 1, 1, 1, 1, // jS 0, 0, 0, 0, 1, 1, 1, 1, 1, // zS 0, 0, 0, 0, 1, 1, 1, 1, 1, // sS 0, 0, 0, 0, 1, 1, 1, 1, 1, // jM 0, 0, 0, 0, 1, 1, 1, 1, 1 // sM ); } BOOST_AUTO_TEST_CASE(test_icl_is_container_right_combinable) { //-------------------------------------------------------------------------- // 3.1 // LeftT is an interval_set: // is_interval_set_right_combinable determines what can // be combined as RightT argument type. check_combine_pattern( "is_interval_set_right_combinable", // e i b p jS zS sS jM sM 1, 1, 0, 0, 1, 1, 1, 0, 0, // jS 1, 1, 0, 0, 1, 1, 1, 0, 0, // zS 1, 1, 0, 0, 1, 1, 1, 0, 0, // sS 0, 0, 0, 0, 0, 0, 0, 0, 0, // jM 0, 0, 0, 0, 0, 0, 0, 0, 0 // sM ); //-------------------------------------------------------------------------- // 3.2 check_combine_pattern( "is_interval_map_right_intra_combinable", // e i b p jS zS sS jM sM 0, 0, 0, 0, 0, 0, 0, 0, 0, // jS 0, 0, 0, 0, 0, 0, 0, 0, 0, // zS 0, 0, 0, 0, 0, 0, 0, 0, 0, // sS 0, 0, 1, 1, 0, 0, 0, 1, 1, // jM 0, 0, 1, 1, 0, 0, 0, 1, 1 // sM ); //-------------------------------------------------------------------------- // 3.3 check_combine_pattern( "is_interval_map_right_cross_combinable", // e i b p jS zS sS jM sM 0, 0, 0, 0, 0, 0, 0, 0, 0, // jS 0, 0, 0, 0, 0, 0, 0, 0, 0, // zS 0, 0, 0, 0, 0, 0, 0, 0, 0, // sS 1, 1, 0, 0, 1, 1, 1, 0, 0, // jM 1, 1, 0, 0, 1, 1, 1, 0, 0 // sM ); //-------------------------------------------------------------------------- // 3.4 check_combine_pattern( "is_interval_map_right_inter_combinable", // e i b p jS zS sS jM sM 0, 0, 0, 0, 0, 0, 0, 0, 0, // jS 0, 0, 0, 0, 0, 0, 0, 0, 0, // zS 0, 0, 0, 0, 0, 0, 0, 0, 0, // sS 1, 1, 1, 1, 1, 1, 1, 1, 1, // jM 1, 1, 1, 1, 1, 1, 1, 1, 1 // sM ); } BOOST_AUTO_TEST_CASE(test_icl_is_right_combinable) { //-------------------------------------------------------------------------- // 4.1 check_combine_pattern( "is_right_intra_combinable", // e i b p jS zS sS jM sM 1, 1, 0, 0, 1, 1, 1, 0, 0, // jS 1, 1, 0, 0, 1, 1, 1, 0, 0, // zS 1, 1, 0, 0, 1, 1, 1, 0, 0, // sS 0, 0, 1, 1, 0, 0, 0, 1, 1, // jM 0, 0, 1, 1, 0, 0, 0, 1, 1 // sM ); //-------------------------------------------------------------------------- // 4.2 check_combine_pattern( "is_right_inter_combinable", // e i b p jS zS sS jM sM 1, 1, 0, 0, 1, 1, 1, 0, 0, // jS 1, 1, 0, 0, 1, 1, 1, 0, 0, // zS 1, 1, 0, 0, 1, 1, 1, 0, 0, // sS 1, 1, 1, 1, 1, 1, 1, 1, 1, // jM 1, 1, 1, 1, 1, 1, 1, 1, 1 // sM ); } BOOST_AUTO_TEST_CASE(test_icl_combines_right_to) { //-------------------------------------------------------------------------- // 5.1 check_combine_pattern( "combines_right_to_interval_set", // e i b p jS zS sS jM sM 0, 0, 0, 0, 1, 1, 1, 0, 0, // jS 0, 0, 0, 0, 1, 1, 1, 0, 0, // zS 0, 0, 0, 0, 1, 1, 1, 0, 0, // sS 0, 0, 0, 0, 1, 1, 1, 0, 0, // jM 0, 0, 0, 0, 1, 1, 1, 0, 0 // sM ); //-------------------------------------------------------------------------- // 5.2 check_combine_pattern( "combines_right_to_interval_map", // e i b p jS zS sS jM sM 0, 0, 0, 0, 0, 0, 0, 0, 0, // jS 0, 0, 0, 0, 0, 0, 0, 0, 0, // zS 0, 0, 0, 0, 0, 0, 0, 0, 0, // sS 0, 0, 0, 0, 0, 0, 0, 1, 1, // jM 0, 0, 0, 0, 0, 0, 0, 1, 1 // sM ); //-------------------------------------------------------------------------- // 5.3 check_combine_pattern( "combines_right_to_interval_container", // e i b p jS zS sS jM sM 0, 0, 0, 0, 1, 1, 1, 0, 0, // jS 0, 0, 0, 0, 1, 1, 1, 0, 0, // zS 0, 0, 0, 0, 1, 1, 1, 0, 0, // sS 0, 0, 0, 0, 1, 1, 1, 1, 1, // jM 0, 0, 0, 0, 1, 1, 1, 1, 1 // sM ); } BOOST_AUTO_TEST_CASE(test_icl_is_companion) { //-------------------------------------------------------------------------- // 6.1 check_combine_pattern( "is_interval_set_companion", // e i b p jS zS sS jM sM 1, 1, 0, 0, 1, 1, 1, 0, 0, // jS 1, 1, 0, 0, 1, 1, 1, 0, 0, // zS 1, 1, 0, 0, 1, 1, 1, 0, 0, // sS 1, 1, 0, 0, 1, 1, 1, 0, 0, // jM 1, 1, 0, 0, 1, 1, 1, 0, 0 // sM ); //-------------------------------------------------------------------------- // 6.2 check_combine_pattern( "is_interval_map_companion", // e i b p jS zS sS jM sM 0, 1, 0, 0, 0, 0, 0, 0, 0, // jS 0, 1, 0, 0, 0, 0, 0, 0, 0, // zS 0, 1, 0, 0, 0, 0, 0, 0, 0, // sS 0, 0, 1, 1, 0, 0, 0, 1, 1, // jM 0, 0, 1, 1, 0, 0, 0, 1, 1 // sM ); } BOOST_AUTO_TEST_CASE(test_icl_is_coarser_combinable) { //-------------------------------------------------------------------------- // 7.1 check_combine_pattern( "is_coarser_interval_set_companion", // e i b p jS zS sS jM sM 1, 1, 0, 0, 0, 0, 0, 0, 0, // jS 1, 1, 0, 0, 1, 0, 0, 0, 0, // zS 1, 1, 0, 0, 1, 1, 0, 0, 0, // sS 1, 1, 0, 0, 0, 0, 0, 0, 0, // jM 1, 1, 0, 0, 1, 1, 0, 0, 0, // sM false ); //-------------------------------------------------------------------------- // 7.2 check_combine_pattern( "is_coarser_interval_map_companion", // e i b p jS zS sS jM sM 0, 1, 0, 0, 0, 0, 0, 0, 0, // jS 0, 1, 0, 0, 0, 0, 0, 0, 0, // zS 0, 1, 0, 0, 0, 0, 0, 0, 0, // sS 0, 0, 1, 1, 0, 0, 0, 0, 0, // jM 0, 0, 1, 1, 0, 0, 0, 1, 0, // sM false ); //-------------------------------------------------------------------------- // 8.1 check_combine_pattern( "is_binary_interval_set_combinable", // e i b p jS zS sS jM sM 1, 1, 0, 0, 0, 0, 0, 0, 0, // jS 1, 1, 0, 0, 1, 0, 0, 0, 0, // zS 1, 1, 0, 0, 1, 1, 0, 0, 0, // sS 0, 0, 0, 0, 0, 0, 0, 0, 0, // jM 0, 0, 0, 0, 0, 0, 0, 0, 0, // sM false ); //-------------------------------------------------------------------------- // 8.2 check_combine_pattern( "is_binary_interval_map_combinable", // e i b p jS zS sS jM sM 0, 0, 0, 0, 0, 0, 0, 0, 0, // jS 0, 0, 0, 0, 0, 0, 0, 0, 0, // zS 0, 0, 0, 0, 0, 0, 0, 0, 0, // sS 0, 0, 1, 1, 0, 0, 0, 0, 0, // jM 0, 0, 1, 1, 0, 0, 0, 1, 0, // sM false ); } BOOST_AUTO_TEST_CASE(test_icl_is_binary_combinable) { //-------------------------------------------------------------------------- // 9.1 check_combine_pattern( "is_binary_intra_combinable", // e i b p jS zS sS jM sM 1, 1, 0, 0, 0, 0, 0, 0, 0, // jS 1, 1, 0, 0, 1, 0, 0, 0, 0, // zS 1, 1, 0, 0, 1, 1, 0, 0, 0, // sS 0, 0, 1, 1, 0, 0, 0, 0, 0, // jM 0, 0, 1, 1, 0, 0, 0, 1, 0, // sM false ); //-------------------------------------------------------------------------- // 9.2 check_combine_pattern( "is_binary_inter_combinable", // e i b p jS zS sS jM sM 1, 1, 0, 0, 0, 0, 0, 0, 0, // jS 1, 1, 0, 0, 1, 0, 0, 0, 0, // zS 1, 1, 0, 0, 1, 1, 0, 0, 0, // sS 1, 1, 1, 1, 1, 1, 1, 0, 0, // jM 1, 1, 1, 1, 1, 1, 1, 1, 0, // sM false ); }