diff options
Diffstat (limited to 'libstdc++-v3/testsuite/ext/random/hypergeometric_distribution')
8 files changed, 352 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/default.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/default.cc new file mode 100644 index 00000000000..34978075d71 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/default.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// 2013-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2013 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.4.8.3.* Class template hypergeometric_distribution [rand.dist.ext.hypergeometric] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test [[gnu::unused]] = true; + + __gnu_cxx::hypergeometric_distribution<> u; + VERIFY( u.total_size() == 10 ); + VERIFY( u.successful_size() == 5 ); + VERIFY( u.total_draws() == 1 ); + VERIFY( u.min() == 0 ); + VERIFY( u.max() == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/parms.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/parms.cc new file mode 100644 index 00000000000..09aec0f1451 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/parms.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// 2013-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2013 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.4.8.3.* Class template hypergeometric_distribution [rand.dist.ext.hypergeometric] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test [[gnu::unused]] = true; + + __gnu_cxx::hypergeometric_distribution<> u(15, 3, 2); + VERIFY( u.total_size() == 15 ); + VERIFY( u.successful_size() == 3 ); + VERIFY( u.total_draws() == 2 ); + VERIFY( u.min() == 0 ); + VERIFY( u.max() == 2 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/equal.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/equal.cc new file mode 100644 index 00000000000..1887457a727 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/equal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// 2013-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2013 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.4.5 Class template rice_distribution [rand.dist.ext.hypergeometric] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test [[gnu::unused]] = true; + + __gnu_cxx::hypergeometric_distribution<unsigned int> u(20, 3, 2), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/inequal.cc new file mode 100644 index 00000000000..4b56f4dc817 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/inequal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// 2013-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2013 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.4.5 Class template rice_distribution [rand.dist.ext.hypergeometric] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test [[gnu::unused]] = true; + + __gnu_cxx::hypergeometric_distribution<unsigned int> u(20, 3, 5), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/serialize.cc new file mode 100644 index 00000000000..583993a951c --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/serialize.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// 2013-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2013 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.4.8.3.* Class template hypergeometric_distribution [rand.dist.ext.hypergeometric] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test [[gnu::unused]] = true; + + std::stringstream str; + __gnu_cxx::hypergeometric_distribution<unsigned int> u(15, 3, 6), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/values.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/values.cc new file mode 100644 index 00000000000..78c0475c935 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/values.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// 2013-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2013 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.4.8.3.* Class template hypergeometric_distribution [rand.dist.ext.hypergeometric] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> +#include <testsuite_random.h> + +void +test01() +{ + using namespace __gnu_test; + + std::mt19937 eng; + + __gnu_cxx::hypergeometric_distribution hd1{15, 3, 2}; + auto bhd1 = std::bind(hd1, eng); + testDiscreteDist(bhd1, [](int k) + { return hypergeometric_pdf(k, 15, 3, 2); }); + + __gnu_cxx::hypergeometric_distribution hd2{500, 50, 30}; + auto bhd2 = std::bind(hd2, eng); + testDiscreteDist(bhd2, [](int k) + { return hypergeometric_pdf(k, 500, 50, 30); }); + + __gnu_cxx::hypergeometric_distribution hd3{100, 20, 5}; + auto bhd3 = std::bind(hd3, eng); + testDiscreteDist(bhd3, [](int k) + { return hypergeometric_pdf(k, 100, 20, 5); }); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..016adb0837f --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/explicit_instantiation/1.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// Copyright (C) 2013 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/>. + +#include <ext/random> + +template class __gnu_cxx::hypergeometric_distribution<unsigned short>; +template class __gnu_cxx::hypergeometric_distribution<unsigned int>; +template class __gnu_cxx::hypergeometric_distribution<unsigned long>; +template class __gnu_cxx::hypergeometric_distribution<unsigned long long>; diff --git a/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/typedefs.cc new file mode 100644 index 00000000000..779aad784e6 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// 2013-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2013 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.4.8.3.* Class template hypergeometric_distribution [rand.dist.ext.hypergeometric] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> + +void +test01() +{ + typedef __gnu_cxx::hypergeometric_distribution<unsigned int> test_type; + + typedef test_type::result_type result_type; + typedef test_type::param_type param_type; +} |