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 | |
---|
18 | BEGIN BOOST_PP_ADD(2, 3) == 5 END |
---|
19 | |
---|
20 | BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), 2) == 6 END |
---|
21 | BEGIN BOOST_PP_ADD(2, BOOST_PP_ADD(1, 4)) == 7 END |
---|
22 | BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), BOOST_PP_ADD(2, 2)) == 8 END |
---|
23 | |
---|
24 | // subtraction |
---|
25 | |
---|
26 | BEGIN BOOST_PP_SUB(11, 0) == 11 END |
---|
27 | BEGIN BOOST_PP_SUB(12, 1) == 11 END |
---|
28 | BEGIN BOOST_PP_SUB(3, 4) == 0 END |
---|
29 | |
---|
30 | BEGIN BOOST_PP_SUB(5, BOOST_PP_SUB(3, 2)) == 4 END |
---|
31 | BEGIN BOOST_PP_SUB(BOOST_PP_SUB(10, 5), 2) == 3 END |
---|
32 | BEGIN BOOST_PP_SUB(BOOST_PP_SUB(7, 3), BOOST_PP_SUB(10, 8)) == 2 END |
---|
33 | |
---|
34 | // multiplication |
---|
35 | |
---|
36 | BEGIN BOOST_PP_MUL(0, 1) == 0 END |
---|
37 | BEGIN BOOST_PP_MUL(1, 0) == 0 END |
---|
38 | BEGIN BOOST_PP_MUL(1, 1) == 1 END |
---|
39 | BEGIN BOOST_PP_MUL(4, 3) == 12 END |
---|
40 | |
---|
41 | BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), 2) == 8 END |
---|
42 | BEGIN BOOST_PP_MUL(2, BOOST_PP_MUL(2, 2)) == 8 END |
---|
43 | BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), BOOST_PP_MUL(2, 2)) == 16 END |
---|
44 | |
---|
45 | // division |
---|
46 | |
---|
47 | BEGIN BOOST_PP_DIV(2, 1) == 2 END |
---|
48 | BEGIN BOOST_PP_DIV(0, 5) == 0 END |
---|
49 | BEGIN BOOST_PP_DIV(7, 3) == 2 END |
---|
50 | |
---|
51 | BEGIN BOOST_PP_DIV(BOOST_PP_DIV(4, 2), 2) == 1 END |
---|
52 | BEGIN BOOST_PP_DIV(10, BOOST_PP_DIV(10, 2)) == 2 END |
---|
53 | BEGIN BOOST_PP_DIV(BOOST_PP_DIV(10, 2), BOOST_PP_DIV(4, 2)) == 2 END |
---|
54 | |
---|
55 | // modulus |
---|
56 | |
---|
57 | BEGIN BOOST_PP_MOD(5, 5) == 0 END |
---|
58 | BEGIN BOOST_PP_MOD(9, 5) == 4 END |
---|
59 | BEGIN BOOST_PP_MOD(7, 4) == 3 END |
---|
60 | |
---|
61 | BEGIN BOOST_PP_MOD(BOOST_PP_MOD(5, 3), 3) == 2 END |
---|
62 | BEGIN BOOST_PP_MOD(5, BOOST_PP_MOD(4, 3)) == 0 END |
---|