1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // Adaptation to Boost of the libcxx
10 // Copyright 2010 Vicente J. Botet Escriba
11 // Distributed under the Boost Software License, Version 1.0.
12 // See http://www.boost.org/LICENSE_1_0.txt
13
14 // test ratio_divide
15
16 #include <boost/ratio/ratio.hpp>
17 #if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
18 #define NOTHING ""
19 #endif
20
test()21 void test()
22 {
23 {
24 typedef boost::ratio<1, 1> R1;
25 typedef boost::ratio<1, 1> R2;
26 typedef boost::ratio_divide<R1, R2> R;
27 BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
28 }
29 {
30 typedef boost::ratio<1, 2> R1;
31 typedef boost::ratio<1, 1> R2;
32 typedef boost::ratio_divide<R1, R2> R;
33 BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
34 }
35 {
36 typedef boost::ratio<-1, 2> R1;
37 typedef boost::ratio<1, 1> R2;
38 typedef boost::ratio_divide<R1, R2> R;
39 BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
40 }
41 {
42 typedef boost::ratio<1, -2> R1;
43 typedef boost::ratio<1, 1> R2;
44 typedef boost::ratio_divide<R1, R2> R;
45 BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
46 }
47 {
48 typedef boost::ratio<1, 2> R1;
49 typedef boost::ratio<-1, 1> R2;
50 typedef boost::ratio_divide<R1, R2> R;
51 BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
52 }
53 {
54 typedef boost::ratio<1, 2> R1;
55 typedef boost::ratio<1, -1> R2;
56 typedef boost::ratio_divide<R1, R2> R;
57 BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
58 }
59 {
60 typedef boost::ratio<56987354, 467584654> R1;
61 typedef boost::ratio<544668, 22145> R2;
62 typedef boost::ratio_divide<R1, R2> R;
63 BOOST_RATIO_STATIC_ASSERT(R::num == 630992477165LL && R::den == 127339199162436LL, NOTHING, ());
64 }
65 }
66