diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-03-18 11:48:29 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-03-18 11:48:29 +0000 |
commit | 294eab8c10d448016ed91b705f28b0ec2bcac607 (patch) | |
tree | b3d8eda8f4baf187b2e2539e7d32020774102801 /libstdc++-v3/testsuite/26_numerics | |
parent | 30a49b23edb7a5a6201c5f59c8a5eee9663c3910 (diff) | |
download | gcc-294eab8c10d448016ed91b705f28b0ec2bcac607.zip gcc-294eab8c10d448016ed91b705f28b0ec2bcac607.tar.gz gcc-294eab8c10d448016ed91b705f28b0ec2bcac607.tar.bz2 |
testsuite_random.h: New.
2011-03-18 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/util/testsuite_random.h: New.
* testsuite/lib/libstdc++.exp (check_v3_target_c99_math,
dg-require-c99_math): Add.
* testsuite/26_numerics/random/bernoulli_distribution/
operators/values.cc: New.
* testsuite/26_numerics/random/binomial_distribution/
operators/values.cc: Likewise.
* testsuite/26_numerics/random/geometric_distribution/
operators/values.cc: Likewise.
From-SVN: r171133
Diffstat (limited to 'libstdc++-v3/testsuite/26_numerics')
3 files changed, 153 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc new file mode 100644 index 0000000..513b5a6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 26.5.8.2.1 Class template bernoulli_distribution [rand.dist.bern.bernoulli] + +#include <random> +#include <functional> +#include <testsuite_random.h> + +void test01() +{ + using namespace __gnu_test; + + std::mt19937 eng; + + std::bernoulli_distribution bd1(0.25); + auto bbd1 = std::bind(bd1, eng); + testDiscreteDist(bbd1, [](int n) { return bernoulli_pdf(n, 0.25); } ); + + std::bernoulli_distribution bd2(0.5); + auto bbd2 = std::bind(bd2, eng); + testDiscreteDist(bbd2, [](int n) { return bernoulli_pdf(n, 0.5); } ); + + std::bernoulli_distribution bd3(0.75); + auto bbd3 = std::bind(bd3, eng); + testDiscreteDist(bbd3, [](int n) { return bernoulli_pdf(n, 0.75); } ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/values.cc new file mode 100644 index 0000000..f1f9565 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/values.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-c99_math "" } +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 26.5.8.2.2 Class template binomial_distribution [rand.dist.bern.bin] + +#include <random> +#include <functional> +#include <testsuite_random.h> + +void test01() +{ + using namespace __gnu_test; + + std::mt19937 eng; + + std::binomial_distribution<> bd1(5, 0.3); + auto bbd1 = std::bind(bd1, eng); + testDiscreteDist(bbd1, [](int n) { return binomial_pdf(n, 0.3, 5); } ); + + std::binomial_distribution<> bd2(55, 0.3); + auto bbd2 = std::bind(bd2, eng); + testDiscreteDist(bbd2, [](int n) { return binomial_pdf(n, 0.3, 55); } ); + + // libstdc++/48114 + std::binomial_distribution<> bd3(10, 0.75); + auto bbd3 = std::bind(bd3, eng); + testDiscreteDist(bbd3, [](int n) { return binomial_pdf(n, 0.75, 10); } ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/values.cc new file mode 100644 index 0000000..f6eaaf6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/values.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 26.5.8.2.3 Class template geometric_distribution [rand.dist.bern.geom] + +#include <random> +#include <functional> +#include <testsuite_random.h> + +void test01() +{ + using namespace __gnu_test; + + std::mt19937 eng; + + std::geometric_distribution<> gd1(0.5); + auto bgd1 = std::bind(gd1, eng); + testDiscreteDist(bgd1, [](int n) { return geometric_pdf(n, 0.5); } ); + + std::geometric_distribution<> gd2(0.75); + auto bgd2 = std::bind(gd2, eng); + testDiscreteDist(bgd2, [](int n) { return geometric_pdf(n, 0.75); } ); + + // libstdc++/48114 + std::geometric_distribution<> gd3(0.25); + auto bgd3 = std::bind(gd3, eng); + testDiscreteDist(bgd3, [](int n) { return geometric_pdf(n, 0.25); } ); +} + +int main() +{ + test01(); + return 0; +} |