]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc
struct-layout-1_generate.c (vector_types): Add v32qi, v16hi, v8si, v4di, v8sf, v4df...
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / ratio / operations / ops3.cc
CommitLineData
4acedca1
CF
1// { dg-options "-std=gnu++0x" }
2
3// 2008-07-03 Chris Fairles <chris.fairles@gmail.com>
4
5// Copyright (C) 2008 Free Software Foundation
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 2, or (at your option)
11// any later version.
12
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License
19// along with this library; see the file COPYING. If not, write to
20// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21// Boston, MA 02110-1301, USA.
22
23#include <ratio>
24#include <testsuite_hooks.h>
25
26#ifdef _GLIBCXX_USE_C99_STDINT_TR1
27
28void
29test01()
30{
31 bool test __attribute__((unused)) = true;
32
33 std::ratio_multiply<
34 std::ratio<2, INTMAX_MAX>,
35 std::ratio<INTMAX_MAX, 2>>::type r1;
36
37 VERIFY( r1.num == 1);
38 VERIFY( r1.den == 1);
39
40 std::ratio_multiply<
41 std::ratio<INTMAX_MAX, 2>,
42 std::ratio<2 , INTMAX_MAX - 1>>::type r2;
43
44 VERIFY( r2.num == INTMAX_MAX);
45 VERIFY( r2.den == INTMAX_MAX - 1);
46}
47
48void
49test02()
50{
51 bool test __attribute__((unused)) = true;
52
53 std::ratio_divide<
54 std::ratio<INTMAX_MAX, 2>,
55 std::ratio<INTMAX_MAX, 2>>::type r1;
56
57 VERIFY( r1.num == 1);
58 VERIFY( r1.den == 1);
59
60 std::ratio_divide<
61 std::ratio<INTMAX_MAX-1, 2>,
62 std::ratio<INTMAX_MAX, 2>>::type r2;
63
64 VERIFY( r2.num == INTMAX_MAX - 1);
65 VERIFY( r2.den == INTMAX_MAX);
66}
67
68#endif //_GLIBCXX_USE_C99_STDINT_TR1
69
70int main()
71{
72#ifdef _GLIBCXX_USE_C99_STDINT_TR1
73 test01();
74 test02();
75#endif //_GLIBCXX_USE_C99_STDINT_TR1
76 return 0;
77}