• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:  The static data members num and den shall have thcommon
15 //    divisor of the absolute values of N and D:
16 
17 #include <boost/ratio/ratio.hpp>
18 
19 #if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
20 #define NOTHING ""
21 #endif
22 
23 template <long long N, long long D, long long eN, long long eD>
test()24 void test()
25 {
26     BOOST_RATIO_STATIC_ASSERT((boost::ratio<N, D>::num == eN),  NOTHING, (boost::mpl::integral_c<boost::intmax_t,boost::ratio<N, D>::num>));
27     BOOST_RATIO_STATIC_ASSERT((boost::ratio<N, D>::den == eD), NOTHING, (boost::mpl::integral_c<boost::intmax_t,boost::ratio<N, D>::den>));
28 }
29 
main()30 int main()
31 {
32     test<1, 1, 1, 1>();
33     test<1, 10, 1, 10>();
34     test<10, 10, 1, 1>();
35     test<10, 1, 10, 1>();
36     test<12, 4, 3, 1>();
37     test<12, -4, -3, 1>();
38     test<-12, 4, -3, 1>();
39     test<-12, -4, 3, 1>();
40     test<4, 12, 1, 3>();
41     test<4, -12, -1, 3>();
42     test<-4, 12, -1, 3>();
43     test<-4, -12, 1, 3>();
44     test<222, 333, 2, 3>();
45     test<222, -333, -2, 3>();
46     test<-222, 333, -2, 3>();
47     test<-222, -333, 2, 3>();
48     //test<BOOST_RATIO_INTMAX_T_MAX, 127, 72624976668147841LL, 1>();
49     //test<-BOOST_RATIO_INTMAX_T_MAX, 127, -72624976668147841LL, 1>();
50     //test<BOOST_RATIO_INTMAX_T_MAX, -127, -72624976668147841LL, 1>();
51     //test<-BOOST_RATIO_INTMAX_T_MAX, -127, 72624976668147841LL, 1>();
52     //~ test<BOOST_RATIO_INTMAX_T_MAX, 127, BOOST_RATIO_INTMAX_T_MAX, 127>();
53     //~ test<-BOOST_RATIO_INTMAX_T_MAX, 127, -BOOST_RATIO_INTMAX_T_MAX, 127>();
54     //~ test<BOOST_RATIO_INTMAX_T_MAX, -127, -BOOST_RATIO_INTMAX_T_MAX, 127>();
55     //~ test<-BOOST_RATIO_INTMAX_T_MAX, -127, BOOST_RATIO_INTMAX_T_MAX, 127>();
56 }
57