diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/utilities/ratio | |
parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) |
Notes
Diffstat (limited to 'test/std/utilities/ratio')
21 files changed, 874 insertions, 0 deletions
diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp new file mode 100644 index 0000000000000..e4ced3213293d --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_add + +#include <ratio> + +int main() +{ + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_add<R1, R2>::type R; +} diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp new file mode 100644 index 0000000000000..a537f0215ca80 --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_add + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == 2 && R::den == 1, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == 3 && R::den == 2, ""); + } + { + typedef std::ratio<-1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 2, ""); + } + { + typedef std::ratio<1, -2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<-1, 1> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, -1> R2; + typedef std::ratio_add<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<56987354, 467584654> R1; + typedef std::ratio<544668, 22145> R2; + 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/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp new file mode 100644 index 0000000000000..bdbcda36fabc9 --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_divide + +#include <ratio> + +int main() +{ + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<1, 2> R2; + typedef std::ratio_divide<R1, R2>::type R; +} diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp new file mode 100644 index 0000000000000..49b55e7a6ca8a --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_divide + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_divide<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 1, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_divide<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 2, ""); + } + { + typedef std::ratio<-1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_divide<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<1, -2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_divide<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<-1, 1> R2; + typedef std::ratio_divide<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, -1> R2; + typedef std::ratio_divide<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<56987354, 467584654> R1; + typedef std::ratio<544668, 22145> R2; + typedef std::ratio_divide<R1, R2>::type R; + static_assert(R::num == 630992477165LL && R::den == 127339199162436LL, ""); + } +} diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp new file mode 100644 index 0000000000000..81acc14be14c6 --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_multiply + +#include <ratio> + +int main() +{ + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<2, 1> R2; + typedef std::ratio_multiply<R1, R2>::type R; +} diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp new file mode 100644 index 0000000000000..ccf15e07aed5b --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_multiply + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_multiply<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 1, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_multiply<R1, R2>::type R; + static_assert(R::num == 1 && R::den == 2, ""); + } + { + typedef std::ratio<-1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_multiply<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<1, -2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_multiply<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<-1, 1> R2; + typedef std::ratio_multiply<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, -1> R2; + typedef std::ratio_multiply<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<56987354, 467584654> R1; + typedef std::ratio<544668, 22145> R2; + typedef std::ratio_multiply<R1, R2>::type R; + static_assert(R::num == 15519594064236LL && R::den == 5177331081415LL, ""); + } +} diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp new file mode 100644 index 0000000000000..b88314388333b --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_subtract + +#include <ratio> + +int main() +{ + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_subtract<R1, R2>::type R; +} diff --git a/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp new file mode 100644 index 0000000000000..33efd90f5555b --- /dev/null +++ b/test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_subtract + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == 0 && R::den == 1, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == -1 && R::den == 2, ""); + } + { + typedef std::ratio<-1, 2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == -3 && R::den == 2, ""); + } + { + typedef std::ratio<1, -2> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == -3 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<-1, 1> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == 3 && R::den == 2, ""); + } + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, -1> R2; + typedef std::ratio_subtract<R1, R2>::type R; + static_assert(R::num == 3 && R::den == 2, ""); + } + { + typedef std::ratio<56987354, 467584654> R1; + typedef std::ratio<544668, 22145> R2; + 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, ""); + } +} diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp new file mode 100644 index 0000000000000..78027f7e48b83 --- /dev/null +++ b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_equal + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((std::ratio_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((!std::ratio_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_equal<R1, R2>::value), ""); + } +} diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp new file mode 100644 index 0000000000000..9182a9ec503ca --- /dev/null +++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_greater + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((!std::ratio_greater<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_greater<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((std::ratio_greater<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_greater<R1, R2>::value), ""); + } +} diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp new file mode 100644 index 0000000000000..a1f5a185e6211 --- /dev/null +++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_greater_equal + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((std::ratio_greater_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_greater_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((std::ratio_greater_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_greater_equal<R1, R2>::value), ""); + } +} diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp new file mode 100644 index 0000000000000..db53ab0ad448b --- /dev/null +++ b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_less + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2; + static_assert((std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; + static_assert((std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2; + static_assert((std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<641981, 1339063> R1; + typedef std::ratio<1291640, 2694141LL> R2; + static_assert((!std::ratio_less<R1, R2>::value), ""); + } + { + typedef std::ratio<1291640, 2694141LL> R1; + typedef std::ratio<641981, 1339063> R2; + static_assert((std::ratio_less<R1, R2>::value), ""); + } +} diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp new file mode 100644 index 0000000000000..5b148f0e14359 --- /dev/null +++ b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_less_equal + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((std::ratio_less_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_less_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((!std::ratio_less_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_less_equal<R1, R2>::value), ""); + } +} diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp new file mode 100644 index 0000000000000..ebf9307465857 --- /dev/null +++ b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio_not_equal + +#include <ratio> + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((!std::ratio_not_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_not_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_not_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_not_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((std::ratio_not_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_not_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_not_equal<R1, R2>::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_not_equal<R1, R2>::value), ""); + } +} diff --git a/test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp b/test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp new file mode 100644 index 0000000000000..a7326162f40a6 --- /dev/null +++ b/test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio: The static data members num and den shall have the common +// divisor of the absolute values of N and D: + +#include <ratio> + +template <long long N, long long D, long long eN, long long eD> +void test() +{ + static_assert((std::ratio<N, D>::num == eN), ""); + static_assert((std::ratio<N, D>::den == eD), ""); +} + +int main() +{ + test<1, 1, 1, 1>(); + test<1, 10, 1, 10>(); + test<10, 10, 1, 1>(); + test<10, 1, 10, 1>(); + test<12, 4, 3, 1>(); + test<12, -4, -3, 1>(); + test<-12, 4, -3, 1>(); + test<-12, -4, 3, 1>(); + test<4, 12, 1, 3>(); + test<4, -12, -1, 3>(); + test<-4, 12, -1, 3>(); + test<-4, -12, 1, 3>(); + test<222, 333, 2, 3>(); + test<222, -333, -2, 3>(); + test<-222, 333, -2, 3>(); + test<-222, -333, 2, 3>(); + test<0x7FFFFFFFFFFFFFFFLL, 127, 72624976668147841LL, 1>(); + test<-0x7FFFFFFFFFFFFFFFLL, 127, -72624976668147841LL, 1>(); + test<0x7FFFFFFFFFFFFFFFLL, -127, -72624976668147841LL, 1>(); + test<-0x7FFFFFFFFFFFFFFFLL, -127, 72624976668147841LL, 1>(); +} diff --git a/test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp b/test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp new file mode 100644 index 0000000000000..e6dbf710b71a7 --- /dev/null +++ b/test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio: The template argument D shall not be zero + +#include <ratio> +#include <cstdint> + +int main() +{ + const std::intmax_t t1 = std::ratio<1, 0>::num; +} diff --git a/test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp b/test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp new file mode 100644 index 0000000000000..753e79af6d0d7 --- /dev/null +++ b/test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio: the absolute values of the template arguments N and D +// shall be representable by type intmax_t. + +#include <ratio> +#include <cstdint> + +int main() +{ + const std::intmax_t t1 = std::ratio<0x8000000000000000ULL, 1>::num; +} diff --git a/test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp b/test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp new file mode 100644 index 0000000000000..f4b4ab9500166 --- /dev/null +++ b/test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio: the absolute values of the template arguments N and D +// shall be representable by type intmax_t. + +#include <ratio> +#include <cstdint> + +int main() +{ + const std::intmax_t t1 = std::ratio<1, 0x8000000000000000ULL>::num; +} diff --git a/test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp b/test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..b58f5c55b643a --- /dev/null +++ b/test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/utilities/ratio/typedefs.pass.cpp b/test/std/utilities/ratio/typedefs.pass.cpp new file mode 100644 index 0000000000000..5ab4c740ddb63 --- /dev/null +++ b/test/std/utilities/ratio/typedefs.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test ratio typedef's + +#include <ratio> + +int main() +{ + static_assert(std::atto::num == 1 && std::atto::den == 1000000000000000000ULL, ""); + static_assert(std::femto::num == 1 && std::femto::den == 1000000000000000ULL, ""); + static_assert(std::pico::num == 1 && std::pico::den == 1000000000000ULL, ""); + static_assert(std::nano::num == 1 && std::nano::den == 1000000000ULL, ""); + static_assert(std::micro::num == 1 && std::micro::den == 1000000ULL, ""); + static_assert(std::milli::num == 1 && std::milli::den == 1000ULL, ""); + static_assert(std::centi::num == 1 && std::centi::den == 100ULL, ""); + static_assert(std::deci::num == 1 && std::deci::den == 10ULL, ""); + static_assert(std::deca::num == 10ULL && std::deca::den == 1, ""); + static_assert(std::hecto::num == 100ULL && std::hecto::den == 1, ""); + static_assert(std::kilo::num == 1000ULL && std::kilo::den == 1, ""); + static_assert(std::mega::num == 1000000ULL && std::mega::den == 1, ""); + static_assert(std::giga::num == 1000000000ULL && std::giga::den == 1, ""); + static_assert(std::tera::num == 1000000000000ULL && std::tera::den == 1, ""); + static_assert(std::peta::num == 1000000000000000ULL && std::peta::den == 1, ""); + static_assert(std::exa::num == 1000000000000000000ULL && std::exa::den == 1, ""); +} diff --git a/test/std/utilities/ratio/version.pass.cpp b/test/std/utilities/ratio/version.pass.cpp new file mode 100644 index 0000000000000..26c455fb0a9ab --- /dev/null +++ b/test/std/utilities/ratio/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ratio> + +#include <ratio> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |