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_subtract
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 {
25 typedef boost::ratio<0> R1;
26 typedef boost::ratio<0> R2;
27 typedef boost::ratio_subtract<R1, R2> R;
28 BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
29 }
30 {
31 typedef boost::ratio<1, 1> R1;
32 typedef boost::ratio<1, 1> R2;
33 typedef boost::ratio_subtract<R1, R2> R;
34 BOOST_RATIO_STATIC_ASSERT(R::num == 0 && R::den == 1, NOTHING, ());
35 }
36 {
37 typedef boost::ratio<1, 2> R1;
38 typedef boost::ratio<1, 1> R2;
39 typedef boost::ratio_subtract<R1, R2> R;
40 BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
41 }
42 {
43 typedef boost::ratio<-1, 2> R1;
44 typedef boost::ratio<1, 1> R2;
45 typedef boost::ratio_subtract<R1, R2> R;
46 BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
47 }
48 {
49 typedef boost::ratio<1, -2> R1;
50 typedef boost::ratio<1, 1> R2;
51 typedef boost::ratio_subtract<R1, R2> R;
52 BOOST_RATIO_STATIC_ASSERT(R::num == -3 && R::den == 2, NOTHING, ());
53 }
54 {
55 typedef boost::ratio<1, 2> R1;
56 typedef boost::ratio<-1, 1> R2;
57 typedef boost::ratio_subtract<R1, R2> R;
58 BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
59 }
60 {
61 typedef boost::ratio<1, 2> R1;
62 typedef boost::ratio<1, -1> R2;
63 typedef boost::ratio_subtract<R1, R2> R;
64 BOOST_RATIO_STATIC_ASSERT(R::num == 3 && R::den == 2, NOTHING, ());
65 }
66 {
67 typedef boost::ratio<56987354, 467584654> R1;
68 typedef boost::ratio<544668, 22145> R2;
69 typedef boost::ratio_subtract<R1, R2> R;
70 BOOST_RATIO_STATIC_ASSERT(R::num == -126708206685271LL && R::den == 5177331081415LL, NOTHING, ());
71 }
72 }
73