diff options
Diffstat (limited to 'libcxx/test')
20 files changed, 965 insertions, 4 deletions
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp index 7ff25d54670..71bbf198b5e 100644 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp @@ -14,8 +14,6 @@ // template<class _URNG> result_type operator()(_URNG& g); -#include <iostream> - #include <random> #include <numeric> #include <vector> diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp new file mode 100644 index 00000000000..edf7436c132 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// negative_binomial_distribution& operator=(const negative_binomial_distribution&); + +#include <random> +#include <cassert> + +void +test1() +{ + typedef std::negative_binomial_distribution<> D; + D d1(2, 0.75); + D d2; + assert(d1 != d2); + d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp new file mode 100644 index 00000000000..d1dadb908b9 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// negative_binomial_distribution(const negative_binomial_distribution&); + +#include <random> +#include <cassert> + +void +test1() +{ + typedef std::negative_binomial_distribution<> D; + D d1(2, 0.75); + D d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp new file mode 100644 index 00000000000..601d575148c --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// explicit negative_binomial_distribution(IntType t = 1, double p = 0.5); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + D d; + assert(d.k() == 1); + assert(d.p() == 0.5); + } + { + typedef std::negative_binomial_distribution<> D; + D d(3); + assert(d.k() == 3); + assert(d.p() == 0.5); + } + { + typedef std::negative_binomial_distribution<> D; + D d(3, 0.75); + assert(d.k() == 3); + assert(d.p() == 0.75); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp new file mode 100644 index 00000000000..37bd125e8b5 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// explicit negative_binomial_distribution(const param_type& parm); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type P; + P p(5, 0.25); + D d(p); + assert(d.k() == 5); + assert(d.p() == 0.25); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp new file mode 100644 index 00000000000..9c264cf76e6 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// bool operator=(const negative_binomial_distribution& x, +// const negative_binomial_distribution& y); +// bool operator!(const negative_binomial_distribution& x, +// const negative_binomial_distribution& y); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + D d1(3, .25); + D d2(3, .25); + assert(d1 == d2); + } + { + typedef std::negative_binomial_distribution<> D; + D d1(3, .28); + D d2(3, .25); + assert(d1 != d2); + } + { + typedef std::negative_binomial_distribution<> D; + D d1(3, .25); + D d2(4, .25); + assert(d1 != d2); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp new file mode 100644 index 00000000000..96b4c180261 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp @@ -0,0 +1,270 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// template<class _URNG> result_type operator()(_URNG& g); + +#include <random> +#include <numeric> +#include <vector> +#include <cassert> + +template <class T> +inline +T +sqr(T x) +{ + return x * x; +} + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef std::minstd_rand G; + G g; + D d(5, .25); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.min() <= v && v <= d.max()); + 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 = d.k() * (1 - d.p()) / d.p(); + double x_var = x_mean / d.p(); + double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p())); + double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p())); + 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) / x_skew < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01); + } + { + typedef std::negative_binomial_distribution<> D; + typedef std::mt19937 G; + G g; + D d(30, .03125); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.min() <= v && v <= d.max()); + 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 = d.k() * (1 - d.p()) / d.p(); + double x_var = x_mean / d.p(); + double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p())); + double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p())); + 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) / x_skew < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01); + } + { + typedef std::negative_binomial_distribution<> D; + typedef std::mt19937 G; + G g; + D d(40, .25); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.min() <= v && v <= d.max()); + 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 = d.k() * (1 - d.p()) / d.p(); + double x_var = x_mean / d.p(); + double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p())); + double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p())); + 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) / x_skew < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.03); + } + { + typedef std::negative_binomial_distribution<> D; + typedef std::mt19937 G; + G g; + D d(40, 1); + const int N = 1000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.min() <= v && v <= d.max()); + 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 = d.k() * (1 - d.p()) / d.p(); + double x_var = x_mean / d.p(); + double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p())); + double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p())); + assert(mean == x_mean); + assert(var == x_var); + } + { + typedef std::negative_binomial_distribution<> D; + typedef std::mt19937 G; + G g; + D d(400, 0.5); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.min() <= v && v <= d.max()); + 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 = d.k() * (1 - d.p()) / d.p(); + double x_var = x_mean / d.p(); + double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p())); + double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p())); + 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) / x_skew < 0.04); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.05); + } + { + typedef std::negative_binomial_distribution<> D; + typedef std::mt19937 G; + G g; + D d(1, 0.05); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g); + assert(d.min() <= v && v <= d.max()); + 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 = d.k() * (1 - d.p()) / d.p(); + double x_var = x_mean / d.p(); + double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p())); + double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p())); + 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) / x_skew < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.02); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp new file mode 100644 index 00000000000..b8906721e61 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm); + +#include <random> +#include <numeric> +#include <vector> +#include <cassert> + +template <class T> +inline +T +sqr(T x) +{ + return x * x; +} + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d(16, .75); + P p(5, .75); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g, p); + assert(d.min() <= v && v <= d.max()); + 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 = p.k() * (1 - p.p()) / p.p(); + double x_var = x_mean / p.p(); + double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p())); + double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p())); + 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) / x_skew < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01); + } + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type P; + typedef std::mt19937 G; + G g; + D d(16, .75); + P p(30, .03125); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g, p); + assert(d.min() <= v && v <= d.max()); + 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 = p.k() * (1 - p.p()) / p.p(); + double x_var = x_mean / p.p(); + double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p())); + double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p())); + 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) / x_skew < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01); + } + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type P; + typedef std::mt19937 G; + G g; + D d(16, .75); + P p(40, .25); + const int N = 1000000; + std::vector<D::result_type> u; + for (int i = 0; i < N; ++i) + { + D::result_type v = d(g, p); + assert(d.min() <= v && v <= d.max()); + 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 = p.k() * (1 - p.p()) / p.p(); + double x_var = x_mean / p.p(); + double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p())); + double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p())); + 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) / x_skew < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.03); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp new file mode 100644 index 00000000000..8ea47709575 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// param_type param() const; + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type P; + P p(5, .125); + D d(p); + assert(d.param() == p); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp new file mode 100644 index 00000000000..ed72ff12a48 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// template <class charT, class traits> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>& os, +// const negative_binomial_distribution& x); +// +// template <class charT, class traits> +// basic_istream<charT, traits>& +// operator>>(basic_istream<charT, traits>& is, +// negative_binomial_distribution& x); + +#include <random> +#include <sstream> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + D d1(7, .25); + std::ostringstream os; + os << d1; + std::istringstream is(os.str()); + D d2; + is >> d2; + assert(d1 == d2); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp new file mode 100644 index 00000000000..558ea8d77ce --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// result_type max() const; + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + D d(4, .25); + assert(d.max() == std::numeric_limits<int>::max()); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp new file mode 100644 index 00000000000..139c51cd1ea --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// result_type min() const; + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + D d(4, .5); + assert(d.min() == 0); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp new file mode 100644 index 00000000000..f01485284fa --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type param_type; + param_type p0(6, .7); + param_type p; + p = p0; + assert(p.k() == 6); + assert(p.p() == .7); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp new file mode 100644 index 00000000000..a4af47b8337 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type param_type; + param_type p0(10, .125); + param_type p = p0; + assert(p.k() == 10); + assert(p.p() == .125); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp new file mode 100644 index 00000000000..9b657b4d607 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type param_type; + param_type p; + assert(p.k() == 1); + assert(p.p() == 0.5); + } + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type param_type; + param_type p(10); + assert(p.k() == 10); + assert(p.p() == 0.5); + } + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type param_type; + param_type p(10, 0.25); + assert(p.k() == 10); + assert(p.p() == 0.25); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp new file mode 100644 index 00000000000..0d1fe9fd19f --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution +// { +// class param_type; + +#include <random> +#include <limits> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type param_type; + param_type p1(3, 0.75); + param_type p2(3, 0.75); + assert(p1 == p2); + } + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type param_type; + param_type p1(3, 0.75); + param_type p2(3, 0.5); + assert(p1 != p2); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp new file mode 100644 index 00000000000..85ab987e818 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution +// { +// class param_type; + +#include <random> +#include <type_traits> + +int main() +{ + { + typedef std::negative_binomial_distribution<> 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/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp new file mode 100644 index 00000000000..fec8aeace21 --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution + +// void param(const param_type& parm); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::param_type P; + P p(10, 0.25); + D d(8, 0.75); + d.param(p); + assert(d.param() == p); + } +} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp new file mode 100644 index 00000000000..fc4062f251b --- /dev/null +++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class IntType = int> +// class negative_binomial_distribution +// { +// typedef bool result_type; + +#include <random> +#include <type_traits> + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same<result_type, int>::value), ""); + } + { + typedef std::negative_binomial_distribution<long> D; + typedef D::result_type result_type; + static_assert((std::is_same<result_type, long>::value), ""); + } +} diff --git a/libcxx/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp b/libcxx/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp index afeeeb242cc..44cf901d007 100644 --- a/libcxx/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp +++ b/libcxx/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp @@ -15,8 +15,6 @@ #include <random> #include <cassert> -#include <iostream> - int main() { { |