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/add.hpp> |
---|
13 | # include <boost/preprocessor/arithmetic/sub.hpp> |
---|
14 | # include <boost/preprocessor/comparison/less.hpp> |
---|
15 | # include <boost/preprocessor/seq.hpp> |
---|
16 | # include <boost/preprocessor/tuple/elem.hpp> |
---|
17 | # include <libs/preprocessor/test/test.h> |
---|
18 | |
---|
19 | # define SEQ (4)(1)(5)(2) |
---|
20 | |
---|
21 | # define REVERSAL(s, x, y) BOOST_PP_SUB(y, x) |
---|
22 | # define SUB_S(s, x, y) BOOST_PP_SUB(x, y) |
---|
23 | # define ADD_S(s, x, y) BOOST_PP_ADD(x, y) |
---|
24 | |
---|
25 | BEGIN BOOST_PP_SEQ_FOLD_LEFT(SUB_S, 22, SEQ) == 10 END |
---|
26 | BEGIN BOOST_PP_SEQ_FOLD_RIGHT(ADD_S, 0, SEQ) == 12 END |
---|
27 | BEGIN BOOST_PP_SEQ_FOLD_RIGHT(REVERSAL, 0, SEQ) == 4 END |
---|
28 | |
---|
29 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REVERSE(SEQ)) == 2514 END |
---|
30 | |
---|
31 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REST_N(2, SEQ)) == 52 END |
---|
32 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_FIRST_N(2, SEQ)) == 41 END |
---|
33 | |
---|
34 | BEGIN BOOST_PP_SEQ_ELEM(2, SEQ) == 5 END |
---|
35 | BEGIN BOOST_PP_SEQ_SIZE(SEQ) == 4 END |
---|
36 | |
---|
37 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_TRANSFORM(ADD_S, 2, SEQ)) == 6374 END |
---|
38 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_TAIL(SEQ) SEQ) == 1524152 END |
---|
39 | |
---|
40 | # define F1(r, state, x) + x + state |
---|
41 | BEGIN BOOST_PP_SEQ_FOR_EACH(F1, 1, SEQ) == 16 END |
---|
42 | |
---|
43 | BEGIN BOOST_PP_TUPLE_ELEM(4, 3, BOOST_PP_SEQ_TO_TUPLE(SEQ)) == 2 END |
---|
44 | |
---|
45 | # define LESS_S(s, x, y) BOOST_PP_LESS(x, y) |
---|
46 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_FILTER(LESS_S, 3, SEQ)) == 45 END |
---|
47 | |
---|
48 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_INSERT(SEQ, 0, 3)) == 34152 END |
---|
49 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_INSERT(SEQ, 2, 3)) == 41352 END |
---|
50 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_INSERT(SEQ, 4, 3)) == 41523 END |
---|
51 | |
---|
52 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_POP_BACK(SEQ)) == 415 END |
---|
53 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_POP_FRONT(SEQ)) == 152 END |
---|
54 | |
---|
55 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_PUSH_FRONT(SEQ, 3)) == 34152 END |
---|
56 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_PUSH_BACK(SEQ, 3)) == 41523 END |
---|
57 | |
---|
58 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REMOVE(SEQ, 0)) == 152 END |
---|
59 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REMOVE(SEQ, 2)) == 412 END |
---|
60 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REMOVE(SEQ, 3)) == 415 END |
---|
61 | |
---|
62 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REPLACE(SEQ, 0, 3)) == 3152 END |
---|
63 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REPLACE(SEQ, 1, 3)) == 4352 END |
---|
64 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REPLACE(SEQ, 3, 3)) == 4153 END |
---|
65 | |
---|
66 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_SUBSEQ(SEQ, 0, 4)) == 4152 END |
---|
67 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_SUBSEQ(SEQ, 0, 2)) == 41 END |
---|
68 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_SUBSEQ(SEQ, 1, 2)) == 15 END |
---|
69 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_SUBSEQ(SEQ, 2, 2)) == 52 END |
---|
70 | |
---|
71 | # define F2(r, x) + BOOST_PP_SEQ_ELEM(0, x) + 2 - BOOST_PP_SEQ_ELEM(1, x) |
---|
72 | |
---|
73 | #define ADD_NIL(x) x(nil) |
---|
74 | |
---|
75 | BEGIN BOOST_PP_SEQ_FOR_EACH_PRODUCT(F2, ((1)(0)) ((2)(3))) == 0 END |
---|
76 | |
---|
77 | # define L1 (0)(x) |
---|
78 | # define L2 (a)(1)(b)(2) |
---|
79 | # define L3 (c)(3)(d) |
---|
80 | |
---|
81 | # define LL (L1)(L2)(L3) |
---|
82 | |
---|
83 | #define SEQ_APPEND(s, state, elem) state elem |
---|
84 | BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_TAIL(BOOST_PP_SEQ_FOLD_LEFT(SEQ_APPEND, (~), LL))) == 0x0a1b2c3d END |
---|
85 | BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_TAIL(BOOST_PP_SEQ_FOLD_LEFT(SEQ_APPEND, (~), LL))) == 9 END |
---|