summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/ratio/test/ratio_arithmetic
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/ratio/test/ratio_arithmetic')
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_abs_pass.cpp51
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_2_fail.cpp28
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_3_fail.cpp36
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp27
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp95
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp20
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_pass.cpp65
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp20
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_pass.cpp65
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_negate_pass.cpp51
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_power_pass.cpp60
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_sign_pass.cpp51
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_fail.cpp20
-rw-r--r--src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_pass.cpp72
14 files changed, 661 insertions, 0 deletions
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_abs_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_abs_pass.cpp
new file mode 100644
index 000000000..4ff23677a
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_abs_pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_abs
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::ratio_abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio_abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio_abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio_abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio_abs<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+}
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_2_fail.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_2_fail.cpp
new file mode 100644
index 000000000..3d6eb1b9a
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_2_fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+
+
+template <typename R>
+struct numerator;
+
+template <boost::intmax_t N, boost::intmax_t D>
+struct numerator<boost::ratio<N,D> > {
+ static const boost::intmax_t value = N;
+};
+
+
+BOOST_RATIO_STATIC_ASSERT((
+ numerator<boost::ratio_add<boost::ratio<1,2>,boost::ratio<1,3> > >::value == 1)
+ , NOTHING, ());
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_3_fail.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_3_fail.cpp
new file mode 100644
index 000000000..6a64668df
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_3_fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+
+template <typename T, typename R>
+struct S {
+ T val;
+};
+
+boost::intmax_t func(S<int, boost::ratio<5,6> > const& s) {
+ return s.val*3;
+}
+
+
+boost::intmax_t test() {
+ return func(
+ S<int, boost::ratio_add<
+ boost::ratio<1,2>,
+ boost::ratio<1,3>
+ >
+ //~ ::type
+ >()
+ );
+}
+
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp
new file mode 100644
index 000000000..57ec0d45e
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/ratio/ratio.hpp>
+#include <boost/integer_traits.hpp>
+
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+
+typedef boost::ratio<boost::integer_traits<boost::intmax_t>::const_max, 1> R1;
+typedef boost::ratio<1, 1> R2;
+typedef boost::ratio_add<R1, R2>::type RT;
+
+BOOST_RATIO_STATIC_ASSERT(RT::num==boost::integer_traits<boost::intmax_t>::const_max+1, NOTHING, (RT));
+BOOST_RATIO_STATIC_ASSERT(RT::den==1, NOTHING, (RT));
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp
new file mode 100644
index 000000000..e13c45795
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_add
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::ratio<0> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 2 && R::den == 1, NOTHING, ());
+ typedef boost::ratio_add<R, R2> RR;
+ BOOST_RATIO_STATIC_ASSERT(RR::num == 3 && RR::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_add<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 127970191639601LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_add<R1, R2>::type RT;
+ }
+
+}
+
+boost::intmax_t func(boost::ratio<5,6> s) {
+ return s.num;
+}
+
+
+boost::intmax_t test_conversion() {
+ return func(
+ boost::ratio_add<
+ boost::ratio<1,2>,
+ boost::ratio<1,3>
+ >
+ ()
+ );
+}
+
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp
new file mode 100644
index 000000000..1ac95512f
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_divide
+
+#include <boost/ratio/ratio.hpp>
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+typedef boost::ratio<1,2> R2;
+typedef boost::ratio_divide<R1, R2>::type RT;
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_pass.cpp
new file mode 100644
index 000000000..5eedc4b91
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_divide_pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_divide
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_divide<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 630992477165LL && R::den == 127339199162436LL, NOTHING, ());
+ }
+}
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp
new file mode 100644
index 000000000..61afafa3b
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_multiply
+
+#include <boost/ratio/ratio.hpp>
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+typedef boost::ratio<2,1> R2;
+typedef boost::ratio_multiply<R1, R2>::type RT;
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_pass.cpp
new file mode 100644
index 000000000..42083b813
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_multiply_pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_multiply
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_multiply<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 15519594064236LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+}
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_negate_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_negate_pass.cpp
new file mode 100644
index 000000000..9954fc27a
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_negate_pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_negate
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::ratio_negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio_negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio_negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio_negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio_negate<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+}
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_power_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_power_pass.cpp
new file mode 100644
index 000000000..8bfe41aea
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_power_pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_power
+
+#define BOOST_RATIO_EXTENSIONS
+#include <boost/ratio/ratio.hpp>
+
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio_power<R1, 1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio_power<R1, -1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 2 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio_power<R1, 0> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio_power<R1, 2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 4, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio_power<R1, 2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 4, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<2, 3> R1;
+ typedef boost::ratio_power<R1, 2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 4 && R::den == 9, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<2, 3> R1;
+ typedef boost::ratio_power<R1, -2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 9 && R::den == 4, NOTHING, ());
+ }
+}
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_sign_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_sign_pass.cpp
new file mode 100644
index 000000000..0cc09a119
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_sign_pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_sign
+
+#define BOOST_RATIO_EXTENSIONS
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::ratio_sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == 0, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio_sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio_sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio_sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == -1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio_sign<R1> R;
+ BOOST_RATIO_STATIC_ASSERT(R::value == -1, NOTHING, ());
+ }
+}
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_fail.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_fail.cpp
new file mode 100644
index 000000000..087d7b280
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_fail.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_subtract
+
+#include <boost/ratio/ratio.hpp>
+
+typedef boost::ratio<BOOST_RATIO_INTMAX_C(-0x7FFFFFFFFFFFFFFF), 1> R1;
+typedef boost::ratio<1,1> R2;
+typedef boost::ratio_subtract<R1, R2>::type RT;
diff --git a/src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_pass.cpp b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_pass.cpp
new file mode 100644
index 000000000..7fa344e5c
--- /dev/null
+++ b/src/boost/libs/ratio/test/ratio_arithmetic/ratio_subtract_pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Adaptation to Boost of the libcxx
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test ratio_subtract
+
+#include <boost/ratio/ratio.hpp>
+#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+void test()
+{
+
+ {
+ typedef boost::ratio<0> R1;
+ typedef boost::ratio<0> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 1> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<-1, 2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, -2> R1;
+ typedef boost::ratio<1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<-1, 1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<1, 2> R1;
+ typedef boost::ratio<1, -1> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
+ }
+ {
+ typedef boost::ratio<56987354, 467584654> R1;
+ typedef boost::ratio<544668, 22145> R2;
+ typedef boost::ratio_subtract<R1, R2> R;
+ BOOST_RATIO_STATIC_ASSERT(R::num == -126708206685271LL && R::den == 5177331081415LL, NOTHING, ());
+ }
+}