1 | |
---|
2 | // Copyright Aleksey Gurtovoy 2001-2004 |
---|
3 | // |
---|
4 | // Distributed under the Boost Software License, Version 1.0. |
---|
5 | // (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | // |
---|
8 | // See http://www.boost.org/libs/mpl for documentation. |
---|
9 | |
---|
10 | // $Source: /cvsroot/boost/boost/libs/mpl/test/arithmetic.cpp,v $ |
---|
11 | // $Date: 2004/09/02 15:41:35 $ |
---|
12 | // $Revision: 1.5 $ |
---|
13 | |
---|
14 | #include <boost/mpl/arithmetic.hpp> |
---|
15 | #include <boost/mpl/int.hpp> |
---|
16 | #include <boost/mpl/aux_/test.hpp> |
---|
17 | |
---|
18 | MPL_TEST_CASE() |
---|
19 | { |
---|
20 | typedef int_<0> _0; |
---|
21 | typedef int_<1> _1; |
---|
22 | typedef int_<3> _3; |
---|
23 | typedef int_<10> _10; |
---|
24 | |
---|
25 | MPL_ASSERT_RELATION( (plus<_0,_10>::value), ==, 10 ); |
---|
26 | MPL_ASSERT_RELATION( (plus<_10,_0>::value), ==, 10 ); |
---|
27 | |
---|
28 | MPL_ASSERT_RELATION( (minus<_0,_10>::value), ==, -10 ); |
---|
29 | MPL_ASSERT_RELATION( (minus<_10,_0>::value), ==, 10 ); |
---|
30 | |
---|
31 | MPL_ASSERT_RELATION( (times<_1,_10>::value), ==, 10 ); |
---|
32 | MPL_ASSERT_RELATION( (times<_10,_1>::value), ==, 10 ); |
---|
33 | MPL_ASSERT_RELATION( (multiplies<_1,_10>::value), ==, 10 ); |
---|
34 | MPL_ASSERT_RELATION( (multiplies<_10,_1>::value), ==, 10 ); |
---|
35 | |
---|
36 | MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 ); |
---|
37 | MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 ); |
---|
38 | |
---|
39 | MPL_ASSERT_RELATION( (modulus<_10,_1>::value), ==, 0 ); |
---|
40 | MPL_ASSERT_RELATION( (modulus<_10,_3>::value), ==, 1 ); |
---|
41 | |
---|
42 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
---|
43 | MPL_ASSERT_RELATION( (minus<_10,_1,_10>::value), ==, -1 ); |
---|
44 | MPL_ASSERT_RELATION( (plus<_10,_1,_10>::value), ==, 21 ); |
---|
45 | MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 ); |
---|
46 | MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 ); |
---|
47 | #endif |
---|
48 | |
---|
49 | MPL_ASSERT_RELATION( negate<_10>::value, ==, -10 ); |
---|
50 | } |
---|