diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-06 08:58:27 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-06 08:58:27 +0000 |
commit | f455051dd07798d0f77f4c231e9345db3f4c3e2a (patch) | |
tree | 857b8d6248d007126b20d033165a50c38c343781 /libstdc++-v3/testsuite | |
parent | 3220fb876e23d6b3d087e7c5c6a9f5d13f479cd1 (diff) | |
download | gcc-f455051dd07798d0f77f4c231e9345db3f4c3e2a.tar.gz |
2010-08-06 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/ratio (ratio_less): Improve, use ratio_divide to avoid
more overflows.
* testsuite/20_util/ratio/comparisons/comp1.cc: Extend.
* testsuite/20_util/ratio/comparisons/comp2.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162941 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc | 9 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc | 9 |
2 files changed, 15 insertions, 3 deletions
diff --git a/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc index f4354fe96bf..eb1bd212f5a 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-require-cstdint "" } -// Copyright (C) 2008, 2009 Free Software Foundation +// Copyright (C) 2008, 2009, 2010 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -45,7 +45,12 @@ test02() VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<1,4>>::value == 0) ); VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<-1,3>>::value == 0) ); - + + VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<-1,4>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<0,4>, std::ratio<0,3>>::value == 0) ); + VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<0,3>>::value == 0) ); + VERIFY( (std::ratio_less<std::ratio<0,3>, std::ratio<-1,4>>::value == 0) ); + VERIFY( (std::ratio_less_equal<std::ratio<-1,3>, std::ratio<-1,3>>::value == 1) ); VERIFY( ( std::ratio_less_equal<std::ratio<1,4>, diff --git a/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc index e741c143510..151dc64450e 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-require-cstdint "" } -// Copyright (C) 2008, 2009 Free Software Foundation +// Copyright (C) 2008, 2009, 2010 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -41,6 +41,13 @@ test01() VERIFY( (std::ratio_less<std::ratio<M - 1, M - 2>, std::ratio<-M, M - 1>>::value == 0) ); + + // No overflow + VERIFY( (std::ratio_less<std::ratio<M, M - 1>, + std::ratio<M, M - 2>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<-M, M - 1>, + std::ratio<-M, M - 2>>::value == 0) ); } int main() |