/* Copyright (C) 2013 Tom Bachmann This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See . */ #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; }