diff options
Diffstat (limited to 'libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int')
18 files changed, 1057 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp new file mode 100644 index 00000000000..0e04ea455e7 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// uniform_int_distribution& operator=(const uniform_int_distribution&); + +#include <random> +#include <cassert> + +void +test1() +{ + typedef std::uniform_int_distribution<long> D; + D d1(2, 5); + D d2; + assert(d1 != d2); + d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp new file mode 100644 index 00000000000..c09830c6277 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// uniform_int_distribution(const uniform_int_distribution&); + +#include <random> +#include <cassert> + +void +test1() +{ + typedef std::uniform_int_distribution<long> D; + D d1(2, 5); + D d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp new file mode 100644 index 00000000000..68f2ec0975a --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// explicit uniform_int_distribution(IntType a = 0, +// IntType b = numeric_limits<IntType>::max()); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + D d; + assert(d.a() == 0); + assert(d.b() == std::numeric_limits<int>::max()); + } + { + typedef std::uniform_int_distribution<> D; + D d(-6); + assert(d.a() == -6); + assert(d.b() == std::numeric_limits<int>::max()); + } + { + typedef std::uniform_int_distribution<> D; + D d(-6, 106); + assert(d.a() == -6); + assert(d.b() == 106); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp new file mode 100644 index 00000000000..cc3e86a42bd --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// explicit uniform_int_distribution(const param_type& parm); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + typedef D::param_type P; + P p(3, 8); + D d(p); + assert(d.a() == 3); + assert(d.b() == 8); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp new file mode 100644 index 00000000000..b7a5cffbe56 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// bool operator=(const uniform_int_distribution& x, +// const uniform_int_distribution& y); +// bool operator!(const uniform_int_distribution& x, +// const uniform_int_distribution& y); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + D d1(3, 8); + D d2(3, 8); + assert(d1 == d2); + } + { + typedef std::uniform_int_distribution<> D; + D d1(3, 8); + D d2(3, 9); + assert(d1 != d2); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp new file mode 100644 index 00000000000..66693a8da55 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp @@ -0,0 +1,455 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// REQUIRES: long_tests + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// template<class _URNG> result_type operator()(_URNG& g); + +#include <random> +#include <cassert> +#include <vector> +#include <numeric> + +template <class T> +inline +T +sqr(T x) +{ + return x * x; +} + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + typedef std::minstd_rand0 G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::minstd_rand G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::mt19937 G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::mt19937_64 G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::ranlux24_base G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::ranlux48_base G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::ranlux24 G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::ranlux48 G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::knuth_b G; + G g; + D d; + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } + { + typedef std::uniform_int_distribution<> D; + typedef std::minstd_rand0 G; + G g; + D d(-6, 106); + for (int i = 0; i < 10000; ++i) + { + int u = d(g); + assert(-6 <= u && u <= 106); + } + } + { + typedef std::uniform_int_distribution<> D; + typedef std::minstd_rand G; + G g; + D d(5, 100); + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.a() <= v && v <= d.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)d.a() + d.b()) / 2; + double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) / + (5. * (sqr((double)d.b() - d.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp new file mode 100644 index 00000000000..d83d48cac1e --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm); + +#include <random> +#include <cassert> +#include <vector> +#include <numeric> + +template <class T> +inline +T +sqr(T x) +{ + return x * x; +} + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + typedef std::minstd_rand G; + typedef D::param_type P; + G g; + D d(5, 100); + P p(-10, 20); + const int N = 100000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g, p); + assert(p.a() <= v && v <= p.b()); + u.push_back(v); + } + double mean = std::accumulate(u.begin(), u.end(), + double(0)) / u.size(); + double var = 0; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = ((double)p.a() + p.b()) / 2; + double x_var = (sqr((double)p.b() - p.a() + 1) - 1) / 12; + double x_skew = 0; + double x_kurtosis = -6. * (sqr((double)p.b() - p.a() + 1) + 1) / + (5. * (sqr((double)p.b() - p.a() + 1) - 1)); + assert(std::abs((mean - x_mean) / x_mean) < 0.01); + assert(std::abs((var - x_var) / x_var) < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp new file mode 100644 index 00000000000..ab8fa6c9836 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// param_type param() const; + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + typedef D::param_type P; + P p(3, 8); + D d(p); + assert(d.param() == p); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp new file mode 100644 index 00000000000..0220a5aa957 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// template <class charT, class traits> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>& os, +// const uniform_int_distribution& x); +// +// template <class charT, class traits> +// basic_istream<charT, traits>& +// operator>>(basic_istream<charT, traits>& is, +// uniform_int_distribution& x); + +#include <random> +#include <sstream> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + D d1(3, 8); + std::ostringstream os; + os << d1; + std::istringstream is(os.str()); + D d2; + is >> d2; + assert(d1 == d2); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp new file mode 100644 index 00000000000..c0a262f8a88 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// result_type max() const; + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + D d(3, 8); + assert(d.max() == 8); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp new file mode 100644 index 00000000000..3a0d3b2d94b --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// result_type min() const; + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + D d(3, 8); + assert(d.min() == 3); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp new file mode 100644 index 00000000000..09c56097142 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + param_type p0(5, 10); + param_type p; + p = p0; + assert(p.a() == 5); + assert(p.b() == 10); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp new file mode 100644 index 00000000000..1f01e9858c3 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + param_type p0(5, 10); + param_type p = p0; + assert(p.a() == 5); + assert(p.b() == 10); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp new file mode 100644 index 00000000000..eba933c0191 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + param_type p; + assert(p.a() == 0); + assert(p.b() == std::numeric_limits<long>::max()); + } + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + param_type p(5); + assert(p.a() == 5); + assert(p.b() == std::numeric_limits<long>::max()); + } + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + param_type p(5, 10); + assert(p.a() == 5); + assert(p.b() == 10); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp new file mode 100644 index 00000000000..5831f96b6b3 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + param_type p1(5, 10); + param_type p2(5, 10); + assert(p1 == p2); + } + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + param_type p1(5, 10); + param_type p2(6, 10); + assert(p1 != p2); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp new file mode 100644 index 00000000000..4022cfb6102 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution +// { +// class param_type; + +#include <random> +#include <type_traits> + +int main() +{ + { + typedef std::uniform_int_distribution<long> D; + typedef D::param_type param_type; + typedef param_type::distribution_type distribution_type; + static_assert((std::is_same<D, distribution_type>::value), ""); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp new file mode 100644 index 00000000000..823837ba68e --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution + +// void param(const param_type& parm); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + typedef D::param_type P; + P p(3, 8); + D d(6, 7); + d.param(p); + assert(d.param() == p); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp new file mode 100644 index 00000000000..65c01d03788 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class _IntType = int> +// class uniform_int_distribution +// { +// typedef IntType result_type; + +#include <random> +#include <type_traits> + +int main() +{ + { + typedef std::uniform_int_distribution<long> D; + typedef D::result_type result_type; + static_assert((std::is_same<result_type, long>::value), ""); + } +} |