diff options
author | Howard Hinnant <hhinnant@apple.com> | 2011-11-01 23:13:37 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2011-11-01 23:13:37 +0000 |
commit | 05e485879c1b21553799a5a321b78e4dd412494f (patch) | |
tree | 906976e2219c18c88a3d820ddb7560143e66c206 /libcxx/test | |
parent | 3018b950936ab83b4ea035c6edf6d94212eeb855 (diff) | |
download | bcm5719-llvm-05e485879c1b21553799a5a321b78e4dd412494f.tar.gz bcm5719-llvm-05e485879c1b21553799a5a321b78e4dd412494f.zip |
Fix ratio arithmetic with zero
llvm-svn: 143519
Diffstat (limited to 'libcxx/test')
-rw-r--r-- | libcxx/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp | 18 | ||||
-rw-r--r-- | libcxx/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp b/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp index 3d43fc04845..a537f0215ca 100644 --- a/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp +++ b/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp @@ -55,4 +55,22 @@ int main() typedef std::ratio_add<R1, R2>::type R; static_assert(R::num == 127970191639601LL && R::den == 5177331081415LL, ""); } + { + typedef std::ratio<0> R1; + typedef std::ratio<0> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == 0 && R::den == 1, ""); + } + { + typedef std::ratio<1> R1; + typedef std::ratio<0> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 1, ""); + } + { + typedef std::ratio<0> R1; + typedef std::ratio<1> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 1, ""); + } } diff --git a/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp b/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp index 5c77fffae24..33efd90f555 100644 --- a/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp +++ b/libcxx/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp @@ -55,4 +55,22 @@ int main() typedef std::ratio_subtract<R1, R2>::type R; static_assert(R::num == -126708206685271LL && R::den == 5177331081415LL, ""); } + { + typedef std::ratio<0> R1; + typedef std::ratio<0> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == 0 && R::den == 1, ""); + } + { + typedef std::ratio<1> R1; + typedef std::ratio<0> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 1, ""); + } + { + typedef std::ratio<0> R1; + typedef std::ratio<1> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 1, ""); + } } |