/*============================================================================= This file is part of FLINT. FLINT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. FLINT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FLINT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =============================================================================*/ /****************************************************************************** Copyright (C) 2013 Tom Bachmann ******************************************************************************/ #include "flintxx/test/helpers.h" #include "flintxx/mp.h" using namespace flint; using namespace mp; void test_equal_types() { tassert((equal_types::val)); tassert((!equal_types::val)); } void test_logic() { tassert(not_::val == false); tassert(not_::val == true); tassert((and_::val == true)); tassert((and_::val == false)); tassert((and_::val == false)); tassert((and_v::val == true)); tassert((and_v::val == false)); tassert((and_v::val == false)); tassert((or_::val == true)); tassert((or_::val == true)); tassert((or_::val == false)); tassert((and_::val == true)); tassert((and_::val == false)); tassert((and_::val == false)); tassert((and_::val == false)); } template typename enable_if, int>::type test_enable_if_1(T) { return 0; } template typename disable_if, int>::type test_enable_if_1(T) { return 1; } template int test_enable_if_2(T, typename enable_if >::type* = 0) { return 0; } template int test_enable_if_2(T, typename disable_if >::type* = 0) { return 1; } void test_enable_if() { tassert(test_enable_if_1(int(1)) == 0); tassert(test_enable_if_1(unsigned(1)) == 1); tassert(test_enable_if_2(int(1)) == 0); tassert(test_enable_if_2(unsigned(1)) == 1); } void test_if() { tassert((equal_types::type, int>::val)); tassert((equal_types::type, slong>::val)); typedef mp::select s1; tassert((equal_types::val)); typedef mp::select s2; tassert((equal_types::val)); typedef mp::select s3; tassert((equal_types::val)); typedef mp::select s4; tassert((equal_types::val)); typedef mp::select s5; tassert((equal_types::val)); typedef mp::select s6; tassert((equal_types::val)); typedef mp::select s7; tassert((equal_types::val)); } int main() { std::cout << "mp...."; test_equal_types(); test_logic(); test_enable_if(); test_if(); std::cout << "PASS" << std::endl; return 0; }