/*============================================================================= 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/traits.h" #include "flintxx/mp.h" using namespace flint; using namespace traits; struct newtype { }; void test_integrality() { tassert(is_signed_integer::val == true); tassert(is_signed_integer::val == true); tassert(is_signed_integer::val == true); tassert(is_signed_integer::val == false); tassert(is_signed_integer::val == false); tassert(is_signed_integer::val == false); tassert(is_signed_integer::val == false); tassert(is_unsigned_integer::val == true); tassert(is_unsigned_integer::val == true); tassert(is_unsigned_integer::val == true); tassert(is_unsigned_integer::val == false); tassert(is_unsigned_integer::val == false); tassert(is_unsigned_integer::val == false); tassert(is_unsigned_integer::val == false); tassert(is_integer::val == true); tassert(is_integer::val == true); tassert(is_integer::val == true); tassert(is_integer::val == true); tassert(is_integer::val == true); tassert(is_integer::val == true); tassert(is_integer::val == false); tassert(is_string::val == false); tassert(is_string::val == true); tassert(is_string::val == true); tassert(is_string::val == true); tassert(fits_into_slong::val == true); tassert(fits_into_slong::val == true); tassert(fits_into_slong::val == false); tassert(fits_into_slong::val == true); tassert(fits_into_slong::val == true); tassert(fits_into_slong::val == true); tassert(fits_into_slong::val == true); tassert(fits_into_slong::val == false); typedef void function_type(int, int); tassert(fits_into_slong::val == false); } void test_manipulation() { using mp::equal_types; tassert((equal_types::type, int>::val)); tassert((equal_types::type, newtype&>::val)); tassert((equal_types::type, const newtype&>::val)); tassert((equal_types::type, const newtype&>::val)); tassert((equal_types::type, int&>::val)); tassert((equal_types::type, newtype&>::val)); tassert((equal_types::type, const slong&>::val)); tassert((equal_types::type, const int&>::val)); tassert((equal_types::type, const int>::val)); tassert((equal_types::type, const newtype&>::val)); tassert((equal_types::type, const slong>::val)); tassert((equal_types::type, const int&>::val)); tassert((equal_types::type, int>::val)); tassert((equal_types::type, newtype>::val)); tassert((equal_types::type, slong>::val)); tassert((equal_types::type, int>::val)); tassert((equal_types::type, int*>::val)); } class super { }; class sub : public super { }; void test_convertibility() { tassert((_is_convertible::val == true)); tassert((_is_convertible::val == false)); tassert((_is_convertible::val == false)); tassert((_is_convertible::val == true)); tassert((_is_convertible::val == true)); // Test the HACK. tassert((_is_convertible::val == false)); } int main() { std::cout << "traits...."; test_integrality(); test_manipulation(); test_convertibility(); std::cout << "PASS" << std::endl; return 0; }