Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/preprocessor/test/arithmetic.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 2.0 KB
Line 
1# /* **************************************************************************
2#  *                                                                          *
3#  *     (C) Copyright Paul Mensonides 2002.
4#  *     Distributed under the Boost Software License, Version 1.0. (See
5#  *     accompanying file LICENSE_1_0.txt or copy at
6#  *     http://www.boost.org/LICENSE_1_0.txt)
7#  *                                                                          *
8#  ************************************************************************** */
9#
10# /* See http://www.boost.org for most recent version. */
11#
12# include <boost/preprocessor/arithmetic.hpp>
13# include <boost/preprocessor/config/limits.hpp>
14# include <libs/preprocessor/test/test.h>
15
16// addition
17
18BEGIN BOOST_PP_ADD(2, 3) == 5 END
19
20BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), 2) == 6 END
21BEGIN BOOST_PP_ADD(2, BOOST_PP_ADD(1, 4)) == 7 END
22BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), BOOST_PP_ADD(2, 2)) == 8 END
23
24// subtraction
25
26BEGIN BOOST_PP_SUB(11, 0) == 11 END
27BEGIN BOOST_PP_SUB(12, 1) == 11 END
28BEGIN BOOST_PP_SUB(3, 4) == 0 END
29
30BEGIN BOOST_PP_SUB(5, BOOST_PP_SUB(3, 2)) == 4 END
31BEGIN BOOST_PP_SUB(BOOST_PP_SUB(10, 5), 2) == 3 END
32BEGIN BOOST_PP_SUB(BOOST_PP_SUB(7, 3), BOOST_PP_SUB(10, 8)) == 2 END
33
34// multiplication
35
36BEGIN BOOST_PP_MUL(0, 1) == 0 END
37BEGIN BOOST_PP_MUL(1, 0) == 0 END
38BEGIN BOOST_PP_MUL(1, 1) == 1 END
39BEGIN BOOST_PP_MUL(4, 3) == 12 END
40
41BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), 2) == 8 END
42BEGIN BOOST_PP_MUL(2, BOOST_PP_MUL(2, 2)) == 8 END
43BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), BOOST_PP_MUL(2, 2)) == 16 END
44
45// division
46
47BEGIN BOOST_PP_DIV(2, 1) == 2 END
48BEGIN BOOST_PP_DIV(0, 5) == 0 END
49BEGIN BOOST_PP_DIV(7, 3) == 2 END
50
51BEGIN BOOST_PP_DIV(BOOST_PP_DIV(4, 2), 2) == 1 END
52BEGIN BOOST_PP_DIV(10, BOOST_PP_DIV(10, 2)) == 2 END
53BEGIN BOOST_PP_DIV(BOOST_PP_DIV(10, 2), BOOST_PP_DIV(4, 2)) == 2 END
54
55// modulus
56
57BEGIN BOOST_PP_MOD(5, 5) == 0 END
58BEGIN BOOST_PP_MOD(9, 5) == 4 END
59BEGIN BOOST_PP_MOD(7, 4) == 3 END
60
61BEGIN BOOST_PP_MOD(BOOST_PP_MOD(5, 3), 3) == 2 END
62BEGIN BOOST_PP_MOD(5, BOOST_PP_MOD(4, 3)) == 0 END
Note: See TracBrowser for help on using the repository browser.