diff options
author | Edward Smith-Rowland <3dw4rd@verizon.net> | 2012-09-25 03:26:36 +0000 |
---|---|---|
committer | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2012-09-25 03:26:36 +0000 |
commit | 21a8ccc02f643458b82780ac1b884f8454b89871 (patch) | |
tree | 8d6734d639f87cf43341496655f951ebde7ad300 /libstdc++-v3/testsuite | |
parent | 1ab47844f5646b949bf6a2f2a1e591b1a7db41af (diff) | |
download | gcc-21a8ccc02f643458b82780ac1b884f8454b89871.zip gcc-21a8ccc02f643458b82780ac1b884f8454b89871.tar.gz gcc-21a8ccc02f643458b82780ac1b884f8454b89871.tar.bz2 |
Implement the K-distribution as an extension.
From-SVN: r191688
Diffstat (limited to 'libstdc++-v3/testsuite')
7 files changed, 297 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/ext/random/k_distribution/cons/default.cc b/libstdc++-v3/testsuite/ext/random/k_distribution/cons/default.cc new file mode 100644 index 0000000..3a7ade8 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/k_distribution/cons/default.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=c++11" } +// { dg-require-cstdint "" } +// +// 2012-09-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2012 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 k_distribution [rand.dist.ext.k] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::k_distribution<> u; + VERIFY( u.lambda() == 1.0 ); + VERIFY( u.mu() == 1.0 ); + VERIFY( u.nu() == 1.0 ); + VERIFY( u.min() == 0.0 ); + typedef __gnu_cxx::k_distribution<>::result_type result_type; + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/k_distribution/cons/parms.cc b/libstdc++-v3/testsuite/ext/random/k_distribution/cons/parms.cc new file mode 100644 index 0000000..396be38 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/k_distribution/cons/parms.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=c++11" } +// { dg-require-cstdint "" } +// +// 2012-09-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2012 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 k_distribution [rand.dist.ext.k] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::k_distribution<> u(2.0, 1.5, 3.0); + VERIFY( u.lambda() == 2.0 ); + VERIFY( u.mu() == 1.5 ); + VERIFY( u.nu() == 3.0 ); + VERIFY( u.min() == 0.0 ); + typedef __gnu_cxx::k_distribution<>::result_type result_type; + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/k_distribution/operators/equal.cc b/libstdc++-v3/testsuite/ext/random/k_distribution/operators/equal.cc new file mode 100644 index 0000000..51e1081 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/k_distribution/operators/equal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++11" } +// { dg-require-cstdint "" } +// +// 2012-09-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2012 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 k_distribution [rand.dist.ext.k] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::k_distribution<double> u(2.0, 1.5, 3.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/k_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/ext/random/k_distribution/operators/inequal.cc new file mode 100644 index 0000000..082ed28 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/k_distribution/operators/inequal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++11" } +// { dg-require-cstdint "" } +// +// 2012-09-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2012 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 k_distribution [rand.dist.ext.k] + +#include <ext/random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::k_distribution<double> u(2.0, 1.5, 3.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/k_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/ext/random/k_distribution/operators/serialize.cc new file mode 100644 index 0000000..a7647ad --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/k_distribution/operators/serialize.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=c++11" } +// { dg-require-cstdint "" } +// +// 2012-09-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2012 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 k_distribution [rand.dist.ext.k] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::stringstream str; + __gnu_cxx::k_distribution<double> u(2.0, 1.5, 3.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; + VERIFY( u == v ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/random/k_distribution/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/ext/random/k_distribution/requirements/explicit_instantiation/1.cc new file mode 100644 index 0000000..539c774 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/k_distribution/requirements/explicit_instantiation/1.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=c++11" } +// { dg-require-cstdint "" } +// +// Copyright (C) 2012 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::k_distribution<float>; +template class __gnu_cxx::k_distribution<double>; +template class __gnu_cxx::k_distribution<long double>; diff --git a/libstdc++-v3/testsuite/ext/random/k_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/ext/random/k_distribution/requirements/typedefs.cc new file mode 100644 index 0000000..2286fbb --- /dev/null +++ b/libstdc++-v3/testsuite/ext/random/k_distribution/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=c++11" } +// { dg-require-cstdint "" } +// +// 2012-09-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2012 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 k_distribution [rand.dist.ext.k] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <ext/random> + +void +test01() +{ + typedef __gnu_cxx::k_distribution<double> test_type; + + typedef test_type::result_type result_type; + typedef test_type::param_type param_type; +} |