summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/testsuite/ext
diff options
context:
space:
mode:
authoremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-21 12:27:02 +0000
committeremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-21 12:27:02 +0000
commit94612be7a540d99c1996776706c2d3c45f5f8e62 (patch)
tree87279389735f7bac55d97f4929c8b474962aa641 /libstdc++-v3/testsuite/ext
parentdbf51ba1248a78c1a74cde573b0ad16ca5946517 (diff)
downloadppe42-gcc-94612be7a540d99c1996776706c2d3c45f5f8e62.tar.gz
ppe42-gcc-94612be7a540d99c1996776706c2d3c45f5f8e62.zip
2013-11-21 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement __gnu_cxx::hypergeometric_distribution. * include/ext/random: Add hypergeometric_distribution. * include/ext/random.tcc: Add hypergeometric_distribution. * testsuite/util/testsuite_random.h (hypergeometric_pdf): New pdf for the hypergeometric discreet distribution; (lbincoef): New supporting function for binomial coefficients. * testsuite/ext/random/hypergeometric_distribution/operators/ serialize.cc: New. * testsuite/ext/random/hypergeometric_distribution/operators/ equal.cc: New. * testsuite/ext/random/hypergeometric_distribution/operators/ inequal.cc: New. * testsuite/ext/random/hypergeometric_distribution/operators/ values.cc: New. * testsuite/ext/random/hypergeometric_distribution/cons/parms.cc: New. * testsuite/ext/random/hypergeometric_distribution/cons/default.cc: New. * testsuite/ext/random/hypergeometric_distribution/requirements/ explicit_instantiation/1.cc: New. * testsuite/ext/random/hypergeometric_distribution/requirements/ typedefs.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205212 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/ext')
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/default.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/cons/parms.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/equal.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/inequal.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/serialize.cc50
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/values.cc57
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/explicit_instantiation/1.cc27
-rw-r--r--libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/requirements/typedefs.cc36
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;
+}
OpenPOWER on IntegriCloud