summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/preprocessor/test/arithmetic.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/preprocessor/test/arithmetic.cxx')
-rw-r--r--src/boost/libs/preprocessor/test/arithmetic.cxx82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/boost/libs/preprocessor/test/arithmetic.cxx b/src/boost/libs/preprocessor/test/arithmetic.cxx
new file mode 100644
index 00000000..5d48928f
--- /dev/null
+++ b/src/boost/libs/preprocessor/test/arithmetic.cxx
@@ -0,0 +1,82 @@
+# /* **************************************************************************
+# * *
+# * (C) Copyright Paul Mensonides 2002.
+# * Distributed under the Boost Software License, Version 1.0. (See
+# * accompanying file LICENSE_1_0.txt or copy at
+# * http://www.boost.org/LICENSE_1_0.txt)
+# * *
+# ************************************************************************** */
+#
+# /* See http://www.boost.org for most recent version. */
+#
+# include <boost/preprocessor/arithmetic.hpp>
+# include <boost/preprocessor/config/limits.hpp>
+# include <libs/preprocessor/test/test.h>
+
+/* addition */
+
+BEGIN BOOST_PP_ADD(2, 3) == 5 END
+
+BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), 2) == 6 END
+BEGIN BOOST_PP_ADD(2, BOOST_PP_ADD(1, 4)) == 7 END
+BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), BOOST_PP_ADD(2, 2)) == 8 END
+
+/* subtraction */
+
+BEGIN BOOST_PP_SUB(11, 0) == 11 END
+BEGIN BOOST_PP_SUB(12, 1) == 11 END
+BEGIN BOOST_PP_SUB(3, 4) == 0 END
+
+BEGIN BOOST_PP_SUB(5, BOOST_PP_SUB(3, 2)) == 4 END
+BEGIN BOOST_PP_SUB(BOOST_PP_SUB(10, 5), 2) == 3 END
+BEGIN BOOST_PP_SUB(BOOST_PP_SUB(7, 3), BOOST_PP_SUB(10, 8)) == 2 END
+
+/* multiplication */
+
+BEGIN BOOST_PP_MUL(0, 1) == 0 END
+BEGIN BOOST_PP_MUL(1, 0) == 0 END
+BEGIN BOOST_PP_MUL(1, 1) == 1 END
+BEGIN BOOST_PP_MUL(4, 3) == 12 END
+
+BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), 2) == 8 END
+BEGIN BOOST_PP_MUL(2, BOOST_PP_MUL(2, 2)) == 8 END
+BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), BOOST_PP_MUL(2, 2)) == 16 END
+
+/* division */
+
+BEGIN BOOST_PP_DIV(2, 1) == 2 END
+BEGIN BOOST_PP_DIV(0, 5) == 0 END
+BEGIN BOOST_PP_DIV(7, 3) == 2 END
+
+BEGIN BOOST_PP_DIV(BOOST_PP_DIV(4, 2), 2) == 1 END
+BEGIN BOOST_PP_DIV(10, BOOST_PP_DIV(10, 2)) == 2 END
+BEGIN BOOST_PP_DIV(BOOST_PP_DIV(10, 2), BOOST_PP_DIV(4, 2)) == 2 END
+
+/* modulus */
+
+BEGIN BOOST_PP_MOD(5, 5) == 0 END
+BEGIN BOOST_PP_MOD(9, 5) == 4 END
+BEGIN BOOST_PP_MOD(7, 4) == 3 END
+
+BEGIN BOOST_PP_MOD(BOOST_PP_MOD(5, 3), 3) == 2 END
+BEGIN BOOST_PP_MOD(5, BOOST_PP_MOD(4, 3)) == 0 END
+
+/* increment */
+
+BEGIN BOOST_PP_INC(0) == 1 END
+BEGIN BOOST_PP_INC(22) == 23 END
+BEGIN BOOST_PP_INC(256) == 256 END
+
+BEGIN BOOST_PP_INC(BOOST_PP_INC(0)) == 2 END
+BEGIN BOOST_PP_INC(BOOST_PP_INC(17)) == 19 END
+BEGIN BOOST_PP_INC(BOOST_PP_INC(255)) == 256 END
+
+/* decrement */
+
+BEGIN BOOST_PP_DEC(256) == 255 END
+BEGIN BOOST_PP_DEC(47) == 46 END
+BEGIN BOOST_PP_DEC(0) == 0 END
+
+BEGIN BOOST_PP_DEC(BOOST_PP_DEC(256)) == 254 END
+BEGIN BOOST_PP_DEC(BOOST_PP_DEC(85)) == 83 END
+BEGIN BOOST_PP_DEC(BOOST_PP_DEC(1)) == 0 END