diff options
Diffstat (limited to 'libstdc++-v3/testsuite/26_numerics')
315 files changed, 14595 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/26_numerics/accumulate/1.cc b/libstdc++-v3/testsuite/26_numerics/accumulate/1.cc new file mode 100644 index 000000000..a5cbe71b4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/accumulate/1.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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.1 [lib.accumulate] + +#include <numeric> +#include <testsuite_hooks.h> + +int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +const int NA = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int res = std::accumulate(A, A + NA, 11); + VERIFY( res == 66 ); +} + +bool B[] = {true, false, true, true, false, true, false, true, true, false}; +const int NB = sizeof(B) / sizeof(bool); + +void +test02() +{ + bool test __attribute__((unused)) = true; + + int res = std::accumulate(B, B + NB, 100); + VERIFY( res == 106 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/accumulate/48750.cc b/libstdc++-v3/testsuite/26_numerics/accumulate/48750.cc new file mode 100644 index 000000000..450382c3c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/accumulate/48750.cc @@ -0,0 +1,70 @@ +// 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/>. + +#include <vector> +#include <numeric> + +class NaturalParameters +{ +public: + + NaturalParameters() + : m_data(2) + { } + + std::vector<double>::const_iterator + begin() const + { return m_data.begin(); } + + std::vector<double>::const_iterator + end() const + { return m_data.begin(); } + + NaturalParameters& + operator+=(const NaturalParameters&) + { return *this; } + +private: + std::vector<double> m_data; +}; + +inline +NaturalParameters +operator+(const NaturalParameters& a, const NaturalParameters& b) +{ + NaturalParameters tmp = a; + return tmp += b; +} + +// libstdc++/48750 +void test01() +{ + // Used to fail in parallel-mode with a segfault. + for (std::size_t i = 0; i < 1000; ++i) + { + std::vector<NaturalParameters> ChildrenNP(1000); + NaturalParameters init; + NaturalParameters NP = std::accumulate(ChildrenNP.begin(), + ChildrenNP.end(), init); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/accumulate/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/26_numerics/accumulate/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..01082025a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/accumulate/requirements/explicit_instantiation/2.cc @@ -0,0 +1,32 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_api.h> + +namespace std +{ + typedef __gnu_test::NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template value_type accumulate(iterator_type, iterator_type, value_type); +} diff --git a/libstdc++-v3/testsuite/26_numerics/accumulate/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/26_numerics/accumulate/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..f9403c8b6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/accumulate/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,32 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_character.h> + +namespace std +{ + typedef __gnu_test::pod_int value_type; + typedef value_type* iterator_type; + + template value_type accumulate(iterator_type, iterator_type, value_type); +} diff --git a/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc new file mode 100644 index 000000000..1ab0a98f5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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.4 [lib.adjacent.difference] + +#include <algorithm> +#include <numeric> +#include <testsuite_hooks.h> + +int A[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; +int B[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int D[N]; + + std::adjacent_difference(A, A + N, D); + VERIFY( std::equal(D, D + N, B) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/adjacent_difference/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..0a45aedba --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_api.h> + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* input_iterator; + typedef value_type* output_iterator; + + template + output_iterator adjacent_difference(input_iterator, input_iterator, output_iterator); +} diff --git a/libstdc++-v3/testsuite/26_numerics/adjacent_difference/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..5fed31036 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_character.h> + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* input_iterator; + typedef value_type* output_iterator; + + template + output_iterator adjacent_difference(input_iterator, input_iterator, output_iterator); +} diff --git a/libstdc++-v3/testsuite/26_numerics/cmath/51083.cc b/libstdc++-v3/testsuite/26_numerics/cmath/51083.cc new file mode 100644 index 000000000..8ba9b10e5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/cmath/51083.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } +// +// 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/>. + +#include <cmath> + +namespace a +{ + template<typename> class Mat { }; + + template<typename T> struct Mat2 : Mat<T> { }; + + template<typename T> + int fdim(Mat<T>) { return 1; } + + template<typename T, typename U> + int floor(Mat<T>, U) { return 1; } + template<typename T, typename U> + int floor(T, Mat<U>) { return 1; } + + template<typename T, typename U, typename V> + int fma(Mat<T>, U, V) { return 1; } + template<typename T, typename U, typename V> + int fma(T, Mat<U>, V) { return 1; } + template<typename T, typename U, typename V> + int fma(T, U, Mat<V>) { return 1; } +} + +int main() +{ + int __attribute__((unused)) i; + + using namespace std; + + a::Mat2<double> c; + i = fdim(c); + i = floor(c, 0.); + i = floor(0., c); + i = floor(c, 1); + i = floor(1, c); + i = fma(c, 0., 1.); + i = fma(0., c, 1.); + i = fma(0., 1., c); + i = fma(c, 0., 1); + i = fma(0., c, 1); + i = fma(0., 1, c); +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/13450.cc b/libstdc++-v3/testsuite/26_numerics/complex/13450.cc new file mode 100644 index 000000000..c34648e20 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/13450.cc @@ -0,0 +1,82 @@ +// { dg-do run { xfail broken_cplxf_arg } } + +// Copyright (C) 2004, 2009 Free Software Foundation +// +// 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.2.8 complex transcendentals + +#include <complex> +#include <limits> +#include <testsuite_hooks.h> + +template<typename T> + void test01_do(T a, T b) + { + using namespace std; + bool test __attribute__((unused)) = true; + typedef complex<T> cplx; + + T eps = numeric_limits<T>::epsilon() * 100; + + cplx ref = pow(cplx(a, T()), cplx(b, T())); + cplx res1 = pow(a, cplx(b, T())); + cplx res2 = pow(cplx(a, T()), b); + + VERIFY( abs(ref - res1) < eps ); + VERIFY( abs(ref - res2) < eps ); + VERIFY( abs(res1 - res2) < eps ); + } + +// libstdc++/13450 +void test01() +{ + float f1 = -1.0f; + float f2 = 0.5f; + test01_do(f1, f2); + + f1 = -3.2f; + f2 = 1.4f; + test01_do(f1, f2); + + double d1 = -1.0; + double d2 = 0.5; + test01_do(d1, d2); + + d1 = -3.2; + d2 = 1.4; + test01_do(d1, d2); + +#if __LDBL_MANT_DIG__ != 106 + /* For IBM long double, epsilon is too small (since 1.0 plus any + double is representable) to be able to expect results within + epsilon * 100 (which may be much less than 1ulp for a particular + long double value). */ + long double ld1 = -1.0l; + long double ld2 = 0.5l; + test01_do(ld1, ld2); + + ld1 = -3.2l; + ld2 = 1.4l; + test01_do(ld1, ld2); +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/50880.cc b/libstdc++-v3/testsuite/26_numerics/complex/50880.cc new file mode 100644 index 000000000..2b70a99dd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/50880.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } +// +// 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/>. + +#include <complex> +#include <testsuite_hooks.h> + +template<typename T> + void test01_do() + { + bool test __attribute__((unused)) = true; + + const std::complex<T> ca(T(-2), T(2)); + const std::complex<T> cb(T(-2), T(0)); + const std::complex<T> cc(T(-2), T(-2)); + + std::complex<T> cra = std::acosh(ca); + std::complex<T> crb = std::acosh(cb); + std::complex<T> crc = std::acosh(cc); + + VERIFY( cra.real() > T(0) ); + VERIFY( crb.real() > T(0) ); + VERIFY( crc.real() > T(0) ); + } + +// libstdc++/50880 +void test01() +{ + test01_do<float>(); + test01_do<double>(); + test01_do<long double>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/51083.cc b/libstdc++-v3/testsuite/26_numerics/complex/51083.cc new file mode 100644 index 000000000..54e781ba1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/51083.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// +// 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/>. + +#include <complex> + +namespace a +{ + template<typename> class Mat { }; + + template<typename T> struct Mat2 : Mat<T> { }; + + template<typename T> int arg(Mat<T>) { return 1; } + template<typename T> int conj(Mat<T>) { return 1; } + template<typename T> int imag(Mat<T>) { return 1; } + template<typename T> int norm(Mat<T>) { return 1; } + template<typename T> int proj(Mat<T>) { return 1; } + template<typename T> int real(Mat<T>) { return 1; } + + template<typename T, typename U> int pow(Mat<T>, U) { return 1; } + template<typename T, typename U> int pow(T, Mat<U>) { return 1; } +} + +int main() +{ + int __attribute__((unused)) i; + + using namespace std; + + a::Mat2< std::complex<double> > c; + i = arg(c); + i = conj(c); + i = imag(c); + i = norm(c); + i = proj(c); + i = real(c); + i = pow(std::complex<float>(), c); + i = pow(c, std::complex<float>()); +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc b/libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc new file mode 100644 index 000000000..a6cbc9991 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc @@ -0,0 +1,35 @@ +// 2000-02-09 +// Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr> + +// Copyright (C) 1999, 2009 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/>. + + +// Test buggy builtin GNU __complex__ support. This used to cause +// an ICE on some 64-bits plateforms. +// Origin: petter@matfys.lth.se + +#include <complex> + +int main() +{ + std::complex<double> a(9), b(0, 8), c; + + c = a * b; + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc new file mode 100644 index 000000000..85c3ab7b4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <complex> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_comparison_eq_ne test; + test.operator()<std::complex<float>>(); + test.operator()<std::complex<float>, float>(); + test.operator()<float,std::complex<float>>(); + + test.operator()<std::complex<double>>(); + test.operator()<std::complex<double>, double>(); + test.operator()<double,std::complex<double>>(); + + test.operator()<std::complex<long double>>(); + test.operator()<std::complex<long double>, long double>(); + test.operator()<long double,std::complex<long double>>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc new file mode 100644 index 000000000..0027a34e4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc @@ -0,0 +1,58 @@ +// { dg-require-c-std "" } + +// 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/>. + +#include <complex> +#include <limits> +#include <testsuite_hooks.h> + +template<typename T> + void do_test01() + { + bool test __attribute__((unused)) = true; + + if (std::numeric_limits<T>::has_quiet_NaN) + { + std::complex<T> c1(T(0), std::numeric_limits<T>::quiet_NaN()); + VERIFY( c1.real() == T(0) ); + VERIFY( std::isnan(c1.imag()) ); + + std::complex<T> c2(std::numeric_limits<T>::quiet_NaN(), T(0)); + VERIFY( std::isnan(c2.real()) ); + VERIFY( c2.imag() == T(0) ); + + std::complex<T> c3(std::numeric_limits<T>::quiet_NaN(), + std::numeric_limits<T>::quiet_NaN()); + VERIFY( std::isnan(c3.real()) ); + VERIFY( std::isnan(c3.imag()) ); + } + } + +// libstdc++/48760 +void test01() +{ + do_test01<float>(); + do_test01<double>(); + do_test01<long double>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr.cc new file mode 100644 index 000000000..13d3c8168 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <complex> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()<std::complex<float>>(); + test1.operator()<std::complex<double>>(); + test1.operator()<std::complex<long double>>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<std::complex<float>, float>(); + test2.operator()<std::complex<double>, double>(); + test2.operator()<std::complex<long double>, long double>(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc new file mode 100644 index 000000000..77e01bcff --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc @@ -0,0 +1,67 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <complex> + +// User defined type, so that the primary std::complex template is used. +namespace numext +{ + struct ldld_base + { + long double one; + long double two; + }; + + struct ldld_lit : public ldld_base + { }; + + struct ldld_nonlit : public ldld_base + { + ~ldld_nonlit() { } + }; + + bool + operator<(const ldld_base __a, const ldld_base __b) + { return __a.one < __b.one && __a.two < __b.two; } + + bool + operator==(const ldld_base __a, const ldld_base __b) + { return __a.one == __b.one && __a.two == __b.two; } + + ldld_base + operator+=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one + __b.one, __a.two + __b.two}); } + + ldld_base + operator-=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one - __b.one, __a.two - __b.two}); } + + ldld_base + operator*=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one * __b.one, __a.two * __b.two}); } + + ldld_base + operator/=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one / __b.one, __a.two / __b.two}); } + +} + +constexpr std::complex<numext::ldld_lit> lit; // ok +// constexpr std::complex<numext::ldld_nonlit> nonlit; // error diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr387_2.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr387_2.cc new file mode 100644 index 000000000..06e0380cc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr387_2.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2009 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 <complex> + +// DR 387. std::complex over-encapsulated. +// http://gcc.gnu.org/ml/gcc/2009-03/msg00264.html +typedef std::complex<double> C; + +C f1(C& c) { return c+1.0; } +C f2(C& c) { return c-1.0; } +C f3(C& c) { return 1.0+c; } +C f4(C& c) { return 1.0-c; } diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc new file mode 100644 index 000000000..145a4b044 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008, 2009, 2010 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 <complex> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// DR 781. std::complex should add missing C99 functions. +// DR 1137. Return type of conj and proj. +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + typedef std::complex<float> cmplx_f_type; + typedef std::complex<double> cmplx_d_type; + typedef std::complex<long double> cmplx_ld_type; + + const int i1 = 1; + const float f1 = 1.0f; + const double d1 = 1.0; + const long double ld1 = 1.0l; + + const cmplx_f_type c_f1(f1, f1); + const cmplx_d_type c_d1(d1, d1); + const cmplx_ld_type c_ld1(ld1, ld1); + + check_ret_type<cmplx_f_type>(std::proj(c_f1)); + check_ret_type<cmplx_d_type>(std::proj(c_d1)); + check_ret_type<cmplx_ld_type>(std::proj(c_ld1)); + + check_ret_type<float>(std::proj(f1)); + check_ret_type<double>(std::proj(d1)); + check_ret_type<double>(std::proj(i1)); + VERIFY( std::proj(i1) == std::proj(double(i1)) ); + check_ret_type<long double>(std::proj(ld1)); + + check_ret_type<cmplx_f_type>(std::conj(c_f1)); + check_ret_type<cmplx_d_type>(std::conj(c_d1)); + check_ret_type<cmplx_ld_type>(std::conj(c_ld1)); + + check_ret_type<float>(std::conj(f1)); + check_ret_type<double>(std::conj(d1)); + check_ret_type<double>(std::conj(i1)); + VERIFY( std::conj(i1) == std::conj(double(i1)) ); + check_ret_type<long double>(std::conj(ld1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc new file mode 100644 index 000000000..909ec27a9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-12 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008, 2009 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 <complex> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// DR 844. complex pow return type is ambiguous. +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + typedef std::complex<float> cmplx_f_type; + typedef std::complex<double> cmplx_d_type; + typedef std::complex<long double> cmplx_ld_type; + + const int i1 = 1; + const float f1 = 1.0f; + const double d1 = 1.0; + const long double ld1 = 1.0l; + + check_ret_type<cmplx_d_type>(std::pow(cmplx_f_type(f1, f1), i1)); + VERIFY( std::pow(cmplx_f_type(f1, f1), i1) + == std::pow(cmplx_d_type(f1, f1), double(i1)) ); + check_ret_type<cmplx_d_type>(std::pow(cmplx_d_type(d1, d1), i1)); + check_ret_type<cmplx_ld_type>(std::pow(cmplx_ld_type(ld1, ld1), i1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc new file mode 100644 index 000000000..b7e65594c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc @@ -0,0 +1,138 @@ +// 2000-02-10 +// Petter Urkedal <petter@matfys.lth.se> + +// Copyright (C) 2000, 2003, 2009 Free Software Foundation +// +// 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 <iostream> +#include <string> +#include <sstream> +#include <complex> +#include <testsuite_hooks.h> +#include <cmath> + +template<typename R> +inline bool flteq(R x, R y) +{ + if (x == R(0)) return y == R(0); + else return std::fabs(x-y) < 1e-6*std::fabs(x); +} + +template<typename R> +int +test_good(std::string str, R x, R y) +{ + bool test __attribute__((unused)) = true; + std::complex<R> z; + char ch; + std::istringstream iss(str); + iss >> z >> ch; + VERIFY( iss.good() ); + VERIFY( flteq(z.real(), x) ); + VERIFY( flteq(z.imag(), y) ); + VERIFY( ch == '#' ); + return 0; +} + +template<typename R> +int +test_fail(std::string str) +{ + bool test __attribute__((unused)) = true; + std::complex<R> z; + std::istringstream iss(str); + iss >> z; + VERIFY( iss.fail() && !iss.bad() ); + return 0; +} + +template<typename R> +int +testall() +{ + test_good<R>("(-1.1,3.7)#", -1.1, 3.7); + test_good<R>("( .7e6 , \n-3.1)#", .7e6, -3.1); + test_good<R>("(\t0,-1)#", 0.0, -1.0); + test_good<R>("(-3.14)#", -3.14, 0.0); + test_good<R>("-.1#", -.1, 0.0); + test_good<R>(" ( -2.7e3 )#", -2.7e3, 0.0); + test_good<R>(" -.1#", -.1, 0.0); + test_fail<R>("(a,1)"); + test_fail<R>("(,1)"); + test_fail<R>("(1,a)"); + test_fail<R>("(1, )"); + test_fail<R>("|1,1)"); + test_fail<R>("(1|1)"); + test_fail<R>("(1,1|"); + return 0; +} + +// libstdc++/2970 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + complex<float> cf01(-1.1, -333.2); + stringstream ss; + ss << cf01; + string str = ss.str(); + VERIFY( str == "(-1.1,-333.2)" ); +} + +// libstdc++/2985 +struct gnu_char_traits : public std::char_traits<char> +{ }; + +typedef std::basic_ostringstream<char, gnu_char_traits> gnu_sstream; +template class std::basic_string<char, gnu_char_traits, std::allocator<char> >; + +void test02() +{ + bool test __attribute__((unused)) = true; + + // Construct locale with specialized facets. + typedef gnu_sstream::__num_put_type numput_type; + typedef gnu_sstream::__num_get_type numget_type; + std::locale loc_c = std::locale::classic(); + std::locale loc_1(loc_c, new numput_type); + std::locale loc_2(loc_1, new numget_type); + VERIFY( std::has_facet<numput_type>(loc_2) ); + VERIFY( std::has_facet<numget_type>(loc_2) ); + + gnu_sstream sstr; + sstr.imbue(loc_2); + + + std::complex<double> x(3, 4); + sstr << x; + VERIFY( sstr.str() == "(3,4)" ); +} + +int +main() +{ + testall<float>(); + testall<double>(); + testall<long double>(); + + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc new file mode 100644 index 000000000..8b23aec19 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc @@ -0,0 +1,136 @@ +// Copyright (C) 2007, 2009 Free Software Foundation +// +// 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 <iostream> +#include <string> +#include <sstream> +#include <complex> +#include <testsuite_hooks.h> +#include <cmath> + +template<typename R> +inline bool flteq(R x, R y) +{ + if (x == R(0)) return y == R(0); + else return std::fabs(x-y) < 1e-6*std::fabs(x); +} + +template<typename R> +int +test_good(std::wstring str, R x, R y) +{ + bool test __attribute__((unused)) = true; + std::complex<R> z; + wchar_t ch; + std::wistringstream iss(str); + iss >> z >> ch; + VERIFY( iss.good() ); + VERIFY( flteq(z.real(), x) ); + VERIFY( flteq(z.imag(), y) ); + VERIFY( ch == L'#' ); + return 0; +} + +template<typename R> +int +test_fail(std::wstring str) +{ + bool test __attribute__((unused)) = true; + std::complex<R> z; + std::wistringstream iss(str); + iss >> z; + VERIFY( iss.fail() && !iss.bad() ); + return 0; +} + +template<typename R> +int +testall() +{ + test_good<R>(L"(-1.1,3.7)#", -1.1, 3.7); + test_good<R>(L"( .7e6 , \n-3.1)#", .7e6, -3.1); + test_good<R>(L"(\t0,-1)#", 0.0, -1.0); + test_good<R>(L"(-3.14)#", -3.14, 0.0); + test_good<R>(L"-.1#", -.1, 0.0); + test_good<R>(L" ( -2.7e3 )#", -2.7e3, 0.0); + test_good<R>(L" -.1#", -.1, 0.0); + test_fail<R>(L"(a,1)"); + test_fail<R>(L"(,1)"); + test_fail<R>(L"(1,a)"); + test_fail<R>(L"(1, )"); + test_fail<R>(L"|1,1)"); + test_fail<R>(L"(1|1)"); + test_fail<R>(L"(1,1|"); + return 0; +} + +// libstdc++/2970 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + complex<float> cf01(-1.1, -333.2); + wstringstream ss; + ss << cf01; + wstring str = ss.str(); + VERIFY( str == L"(-1.1,-333.2)" ); +} + +// libstdc++/2985 +struct gnu_char_traits : public std::char_traits<wchar_t> +{ }; + +typedef std::basic_ostringstream<wchar_t, gnu_char_traits> gnu_sstream; +template class std::basic_string<wchar_t, gnu_char_traits, + std::allocator<wchar_t> >; + +void test02() +{ + bool test __attribute__((unused)) = true; + + // Construct locale with specialized facets. + typedef gnu_sstream::__num_put_type numput_type; + typedef gnu_sstream::__num_get_type numget_type; + std::locale loc_c = std::locale::classic(); + std::locale loc_1(loc_c, new numput_type); + std::locale loc_2(loc_1, new numget_type); + VERIFY( std::has_facet<numput_type>(loc_2) ); + VERIFY( std::has_facet<numget_type>(loc_2) ); + + gnu_sstream sstr; + sstr.imbue(loc_2); + + + std::complex<double> x(3, 4); + sstr << x; + VERIFY( sstr.str() == L"(3,4)" ); +} + +int +main() +{ + testall<float>(); + testall<double>(); + testall<long double>(); + + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/pow.cc b/libstdc++-v3/testsuite/26_numerics/complex/pow.cc new file mode 100644 index 000000000..a43e3c674 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/pow.cc @@ -0,0 +1,16 @@ +// { dg-do run { xfail broken_cplxf_arg } } +// PR libstdc++/10689 +// Origin: Daniel.Levine@jhuaph.edu +// { dg-add-options ieee } + +#include <complex> +#include <testsuite_hooks.h> + +int main() +{ + std::complex<double> z; + + VERIFY( pow(z, 1.0/3.0) == 0.0 ); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/complex/requirements/constexpr_functions.cc new file mode 100644 index 000000000..eae5ee7e8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/requirements/constexpr_functions.cc @@ -0,0 +1,57 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <complex> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + typedef typename _Ttesttype::_ComplexT _ComplexT; + const _ComplexT cc = { 1.1 }; + constexpr _Ttesttype a(cc); + constexpr auto v1 __attribute__((unused)) = a.real(); + constexpr auto v2 __attribute__((unused)) = a.imag(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + test.operator()<std::complex<float>>(); + test.operator()<std::complex<double>>(); + test.operator()<std::complex<long double>>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc new file mode 100644 index 000000000..dc05a2b19 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc @@ -0,0 +1,65 @@ +// { dg-do run { xfail broken_cplxf_arg } } +// { dg-options "-O0" } +// 2000-11-20 +// Benjamin Kosnik bkoz@redhat.com + +// Copyright (C) 2000, 2003, 2004, 2009, 2010 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 <complex> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef complex<double> complex_type; + const double cd1 = -11.451; + const double cd2 = -442.1533; + + complex_type a(cd1, cd2); + double d; + d = a.real(); + VERIFY( d == cd1 ); + + d = a.imag(); + VERIFY( d == cd2 ); + + complex_type c(cd1, cd2); + double d6 = abs(c); + VERIFY( d6 >= 0 ); + + double d7 = arg(c); + double d8 = atan2(c.imag(), c.real()); + VERIFY( d7 == d8 ); + + double d9 = norm(c); + double d10 = d6 * d6; + VERIFY( d9 - d10 == 0 ); + + complex_type e __attribute__((unused)) = conj(c); + + complex_type f = polar(c.imag(), 0.0); + VERIFY( f.real() != 0 ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc new file mode 100644 index 000000000..29728a2b3 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc @@ -0,0 +1,57 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <complex> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + typedef typename _Ttesttype::_ComplexT _ComplexT; + const _ComplexT cc = { 1.1 }; + constexpr _Ttesttype a(cc); + constexpr auto v1 __attribute__((unused)) = real(a); + constexpr auto v2 __attribute__((unused)) = imag(a); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_functions test; + test.operator()<std::complex<float>>(); + test.operator()<std::complex<double>>(); + test.operator()<std::complex<long double>>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc new file mode 100644 index 000000000..084a52c31 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc @@ -0,0 +1,51 @@ +// 2008-05-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008, 2009 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 <complex> +#include <testsuite_hooks.h> + +// DR 387. std::complex over-encapsulated. +template<typename T> + void + do_test() + { + bool test __attribute__((unused)) = true; + + const T r = 1.0; + const T i = -1.0; + const T v = 0.0; + + std::complex<T> z1(r, i); + z1.real(v); + VERIFY( z1.real() == v ); + VERIFY( z1.imag() == i ); + + std::complex<T> z2(r, i); + z2.imag(v); + VERIFY( z2.real() == r ); + VERIFY( z2.imag() == v ); + } + +int main() +{ + do_test<float>(); + do_test<double>(); + do_test<long double>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc new file mode 100644 index 000000000..29e8dac5f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007, 2009 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 <ccomplex> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc new file mode 100644 index 000000000..3a1910692 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007, 2009 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 <cfenv> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cfenv/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/types_std_c++0x.cc new file mode 100644 index 000000000..dbe066ac0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/types_std_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cfenv> + +void test01() +{ +#if _GLIBCXX_USE_C99_FENV_TR1 + + typedef std::fenv_t my_fenv_t; + typedef std::fexcept_t my_fexcept_t; + +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/19322.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/19322.cc new file mode 100644 index 000000000..25494c357 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/19322.cc @@ -0,0 +1,35 @@ +// { dg-require-c-std "" } + +// Copyright (C) 2005, 2009, 2010, 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/>. + +#include <cmath> +#include <testsuite_hooks.h> + +// libstdc++/19322 +void test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( !std::isnan(3.0) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc new file mode 100644 index 000000000..025db2c2c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2007, 2009 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/>. + + +// { dg-do compile } + +#include <cmath> +#include <string> + +struct employee +: private std::string { }; + +struct manager +: public employee { }; + +bool isnormal(const employee&) +{ return false; } + +// libstdc++/25913 +void test01() +{ + manager m; + isnormal(m); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc new file mode 100644 index 000000000..0cec658d8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2008, 2009 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/>. + + +// { dg-do compile } + +#include <cmath> + +struct foo +{ + foo (double); +}; + +bool operator &&(int, const foo &); + +// libstdc++/37582 +double +test01(double x) +{ + return std::pow (x, 2.0); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++.cc new file mode 100644 index 000000000..3f4b8ba26 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++.cc @@ -0,0 +1,84 @@ +// 2001-04-06 gdr + +// Copyright (C) 2001, 2005, 2009 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/>. + + +// { dg-do compile { xfail uclibc } } +// { dg-excess-errors "" { target uclibc } } + +#include <cmath> + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + +#if _GLIBCXX_USE_C99_MATH +template <typename _Tp> + void test_c99_classify() + { + bool test __attribute__((unused)) = true; + + typedef _Tp fp_type; + fp_type f1 = 1.0; + fp_type f2 = 3.0; + int res = 0; + + res = std::fpclassify(f1); + res = std::isfinite(f2); + res = std::isinf(f1); + res = std::isnan(f2); + res = std::isnormal(f1); + res = std::signbit(f2); + res = std::isgreater(f1, f2); + res = std::isgreaterequal(f1, f2); + res = std::isless(f1, f2); + res = std::islessequal(f1,f2); + res = std::islessgreater(f1, f2); + res = std::isunordered(f1, f2); + res = res; // Suppress unused warning. + } +#endif + +int main() +{ +#if _GLIBCXX_USE_C99_MATH + test_c99_classify<float>(); + test_c99_classify<double>(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++0x.cc new file mode 100644 index 000000000..413fe6925 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++0x.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2010 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/>. + +// { dg-options "-std=gnu++0x" } +// { dg-do compile { xfail uclibc } } +// { dg-excess-errors "" { target uclibc } } + +#include <cmath> + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + +#if _GLIBCXX_USE_C99_MATH +template <typename _Tp, typename _Up = _Tp> + void test_c99_classify() + { + bool test __attribute__((unused)) = true; + + typedef _Tp fp_type_one; + typedef _Up fp_type_two; + fp_type_one f1 = 1.0; + fp_type_two f2 = 3.0; + int resi; + bool res; + + resi = std::fpclassify(f1); + res = std::isfinite(f2); + res = std::isinf(f1); + res = std::isnan(f2); + res = std::isnormal(f1); + res = std::signbit(f2); + res = std::isgreater(f1, f2); + res = std::isgreaterequal(f1, f2); + res = std::isless(f1, f2); + res = std::islessequal(f1,f2); + res = std::islessgreater(f1, f2); + res = std::isunordered(f1, f2); + resi = resi; // Suppress unused warning. + res = res; + } +#endif + +int main() +{ +#if _GLIBCXX_USE_C99_MATH + test_c99_classify<float>(); + test_c99_classify<double>(); + test_c99_classify<long double>(); + test_c99_classify<float, double>(); + test_c99_classify<float, long double>(); + test_c99_classify<double, float>(); + test_c99_classify<double, long double>(); + test_c99_classify<long double, float>(); + test_c99_classify<long double, double>(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc new file mode 100644 index 000000000..716dda51b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc @@ -0,0 +1,51 @@ +// 2001-04-06 gdr + +// Copyright (C) 2001, 2005, 2009, 2010 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/>. + +// { dg-do compile } +// { dg-add-options no_pch } + +// { dg-xfail-if "" { { *-*-linux* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* } || { uclibc || newlib } } { "*" } { "" } } +// { dg-excess-errors "" { target { { *-*-linux* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* } || { uclibc || newlib } } } } + +#include <math.h> + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math.cc new file mode 100644 index 000000000..b8cf6e5e1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math.cc @@ -0,0 +1,70 @@ +// 1999-06-05 +// Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr> + +// Copyright (C) 1999, 2000, 2009 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 <cmath> +#include <testsuite_hooks.h> + +// test compilation. +int +test01() +{ + float a = 1.f; + float b; + std::modf(a, &b); + return 0; +} + +// need more extravagant checks than this, of course, but this used to core... +int +test02() +{ + std::sin(static_cast<float>(0)); + return 0; +} + +// as did this. +int +test03() +{ + double powtest __attribute__((unused)) = std::pow(2., 0); + return 0; +} + +// this used to abort. +int +test04() +{ + bool test __attribute__((unused)) = true; + float x[2] = {1, 2}; + float y = 3.4; + std::modf(y, &x[0]); + VERIFY(x[1] == 2); + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math_dynamic.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math_dynamic.cc new file mode 100644 index 000000000..de4dbe39c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math_dynamic.cc @@ -0,0 +1,49 @@ +// Inspired by libstdc++/7680 & 26_numerics/c_math.cc, 2003-04-12 ljr + +// Copyright (C) 2003, 2009 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/>. + + +// { dg-do link } +// { dg-options "-D_XOPEN_SOURCE" { target *-*-freebsd* } } + +#include <cmath> + +int +test01() +{ + float a = 1.f; + float b; + std::modf(a, &b); + return 0; +} + +int +test02 () +{ + float a = 0.0f; + float b __attribute__((unused)) = std::acos(a); + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc new file mode 100644 index 000000000..c8f7c5cc5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-26 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008, 2009 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 <cmath> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// DR 550. What should the return type of pow(float,int) be? +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + const int i1 = 1; + const float f1 = 1.0f; + const double d1 = 1.0; + const long double ld1 = 1.0l; + + check_ret_type<double>(std::pow(f1, i1)); + VERIFY( std::pow(f1, i1) == std::pow(double(f1), double(i1)) ); + check_ret_type<double>(std::pow(d1, i1)); + check_ret_type<long double>(std::pow(ld1, i1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/fabs_inline.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/fabs_inline.cc new file mode 100644 index 000000000..17057773e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/fabs_inline.cc @@ -0,0 +1,36 @@ +// Copyright (C) 1999, 2002, 2009 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/>. + +// Test to see whether the host provides its own (inline) view of fabs. +// Origin: Kurt Garloff <kurt@garloff.de>, 2001-05-24 +// dg-do link + +#include <cmath> +#include <cstdio> + +typedef double (*realfn) (double); + +using std::fabs; + +int main () +{ + double a = fabs (-2.4); + realfn myfn = fabs; + double b = myfn (-2.5); + std::printf ("%f, %f, %p\n", a, b, myfn); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std.cc new file mode 100644 index 000000000..5226ee4eb --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std.cc @@ -0,0 +1,46 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cmath> + +namespace gnu +{ + using std::acos; + using std::asin; + using std::atan; + using std::atan2; + using std::ceil; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::floor; + using std::fmod; + using std::frexp; + using std::ldexp; + using std::log; + using std::log10; + using std::modf; + using std::pow; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/macros.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/macros.cc new file mode 100644 index 000000000..754f94402 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cmath> + +namespace gnu +{ +#ifndef HUGE_VAL + #error "HUGE_VAL_must_be_a_macro" +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc new file mode 100644 index 000000000..5819e1a18 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// 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/>. + +// PR 3181 +// Origin: pete@toyon.com + +#include <cmath> + +int main() +{ + int i = -1; + int j = 9; + double ans; + ans = std::abs(i); + ans = std::acos(i); + ans = std::asin(i); + ans = std::atan(i); + ans = std::atan2(i, j); + ans = std::cos(i); + ans = std::cosh(i); + ans = std::exp(i); + ans = std::fabs(i); + ans = std::floor(i); + ans = std::log(i); + ans = std::log10(i); + ans = std::sqrt(i); + ans = std::sin(i); + ans = std::sinh(j); + ans = std::tan(i); + ans = std::tanh(i); + ans = ans; // Suppress unused warnings. +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/powi.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/powi.cc new file mode 100644 index 000000000..2af912357 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/powi.cc @@ -0,0 +1,63 @@ +// 2005-02-13 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005, 2009 Free Software Foundation +// +// 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 C Library + +#include <cmath> +#include <testsuite_hooks.h> + +template<typename T> + void test01_do() + { + using namespace std; + bool test __attribute__((unused)) = true; + + VERIFY( pow(T(1.0), 0) == T(1.0) ); + VERIFY( pow(T(2.0), 0) == T(1.0) ); + VERIFY( pow(T(-1.0), 0) == T(1.0) ); + VERIFY( pow(T(-4.0), 0) == T(1.0) ); + + VERIFY( pow(T(1.0), 1) == T(1.0) ); + VERIFY( pow(T(2.0), 1) == T(2.0) ); + VERIFY( pow(T(-1.0), 1) == T(-1.0) ); + VERIFY( pow(T(-4.0), 1) == T(-4.0) ); + + VERIFY( pow(T(1.0), -1) == T(1.0) / T(1.0) ); + VERIFY( pow(T(2.0), -1) == T(1.0) / T(2.0) ); + VERIFY( pow(T(-1.0), -1) == T(1.0) / T(-1.0) ); + VERIFY( pow(T(-4.0), -1) == T(1.0) / T(-4.0) ); + + VERIFY( pow(T(1.0), 2) == T(1.0) * T(1.0) ); + VERIFY( pow(T(2.0), 2) == T(2.0) * T(2.0) ); + VERIFY( pow(T(-1.0), 2) == T(-1.0) * T(-1.0) ); + VERIFY( pow(T(-4.0), 2) == T(-4.0) * T(-4.0) ); + } + +void test01() +{ + test01_do<float>(); + test01_do<double>(); + test01_do<long double>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x.cc new file mode 100644 index 000000000..7e4abe90e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cmath> + +void test01() +{ +#if _GLIBCXX_USE_C99_MATH_TR1 + + typedef std::double_t my_double_t; + typedef std::float_t my_float_t; + +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc new file mode 100644 index 000000000..27fd15cde --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cmath> + +namespace gnu +{ + // C++0x changes from TR1. + using std::assoc_laguerre; + using std::assoc_legendre; + using std::beta; + using std::comp_ellint_1; + using std::comp_ellint_2; + using std::comp_ellint_3; + using std::conf_hyperg; + using std::cyl_bessel_i; + using std::cyl_bessel_j; + using std::cyl_bessel_k; + using std::cyl_neumann; + using std::ellint_1; + using std::ellint_2; + using std::ellint_3; + using std::expint; + using std::hermite; + using std::hyperg; + using std::laguerre; + using std::legendre; + using std::riemann_zeta; + using std::sph_bessel; + using std::sph_legendre; + using std::sph_neumann; +} + +// { dg-error "has not been declared" "" { target *-*-* } 26 } +// { dg-error "has not been declared" "" { target *-*-* } 27 } +// { dg-error "has not been declared" "" { target *-*-* } 28 } +// { dg-error "has not been declared" "" { target *-*-* } 29 } +// { dg-error "has not been declared" "" { target *-*-* } 30 } +// { dg-error "has not been declared" "" { target *-*-* } 31 } +// { dg-error "has not been declared" "" { target *-*-* } 32 } +// { dg-error "has not been declared" "" { target *-*-* } 33 } +// { dg-error "has not been declared" "" { target *-*-* } 34 } +// { dg-error "has not been declared" "" { target *-*-* } 35 } +// { dg-error "has not been declared" "" { target *-*-* } 36 } +// { dg-error "has not been declared" "" { target *-*-* } 37 } +// { dg-error "has not been declared" "" { target *-*-* } 38 } +// { dg-error "has not been declared" "" { target *-*-* } 39 } +// { dg-error "has not been declared" "" { target *-*-* } 40 } +// { dg-error "has not been declared" "" { target *-*-* } 41 } +// { dg-error "has not been declared" "" { target *-*-* } 42 } +// { dg-error "has not been declared" "" { target *-*-* } 43 } +// { dg-error "has not been declared" "" { target *-*-* } 44 } +// { dg-error "has not been declared" "" { target *-*-* } 45 } +// { dg-error "has not been declared" "" { target *-*-* } 46 } +// { dg-error "has not been declared" "" { target *-*-* } 47 } +// { dg-error "has not been declared" "" { target *-*-* } 48 } diff --git a/libstdc++-v3/testsuite/26_numerics/headers/complex/synopsis.cc b/libstdc++-v3/testsuite/26_numerics/headers/complex/synopsis.cc new file mode 100644 index 000000000..4d885930b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/complex/synopsis.cc @@ -0,0 +1,87 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <complex> + +namespace std { + template<class T> class complex; + template<> class complex<float>; + template<> class complex<double>; + template<> class complex<long double>; + + // 26.2.6 operators: + template<class T> + complex<T> operator+(const complex<T>&, const complex<T>&); + template<class T> complex<T> operator+(const complex<T>&, const T&); + template<class T> complex<T> operator+(const T&, const complex<T>&); + template<class T> complex<T> operator- + (const complex<T>&, const complex<T>&); + template<class T> complex<T> operator-(const complex<T>&, const T&); + template<class T> complex<T> operator-(const T&, const complex<T>&); + template<class T> complex<T> operator* + (const complex<T>&, const complex<T>&); + template<class T> complex<T> operator*(const complex<T>&, const T&); + template<class T> complex<T> operator*(const T&, const complex<T>&); + template<class T> complex<T> operator/ + (const complex<T>&, const complex<T>&); + template<class T> complex<T> operator/(const complex<T>&, const T&); + template<class T> complex<T> operator/(const T&, const complex<T>&); + template<class T> complex<T> operator+(const complex<T>&); + template<class T> complex<T> operator-(const complex<T>&); + template<class T> bool operator== + (const complex<T>&, const complex<T>&); + template<class T> bool operator==(const complex<T>&, const T&); + template<class T> bool operator==(const T&, const complex<T>&); + + + template<class T> bool operator!=(const complex<T>&, const complex<T>&); + template<class T> bool operator!=(const complex<T>&, const T&); + template<class T> bool operator!=(const T&, const complex<T>&); + template<class T, class charT, class traits> + basic_istream<charT, traits>& + operator>>(basic_istream<charT, traits>&, complex<T>&); + template<class T, class charT, class traits> + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>&, const complex<T>&); + + // 26.2.7 values: + template<class T> T real(const complex<T>&); + template<class T> T imag(const complex<T>&); + template<class T> T abs(const complex<T>&); + template<class T> T arg(const complex<T>&); + template<class T> T norm(const complex<T>&); + template<class T> complex<T> conj(const complex<T>&); + template<class T> complex<T> polar(const T& rho, const T& theta = 0); + + // 26.2.8 transcendentals: + template<class T> complex<T> cos(const complex<T>&); + template<class T> complex<T> cosh(const complex<T>&); + template<class T> complex<T> exp(const complex<T>&); + template<class T> complex<T> log(const complex<T>&); + template<class T> complex<T> log10(const complex<T>&); + template<class T> complex<T> pow(const complex<T>&, int); + template<class T> complex<T> pow(const complex<T>&, const T&); + template<class T> complex<T> pow(const complex<T>&, const complex<T>&); + template<class T> complex<T> pow(const T&, const complex<T>&); + template<class T> complex<T> sin (const complex<T>&); + template<class T> complex<T> sinh(const complex<T>&); + template<class T> complex<T> sqrt(const complex<T>&); + template<class T> complex<T> tan(const complex<T>&); + template<class T> complex<T> tanh(const complex<T>&); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc new file mode 100644 index 000000000..ff40cd67c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 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 <cstdlib> +#include <testsuite_hooks.h> + +#if _GLIBCXX_USE_C99 +// libstdc++/13943 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + VERIFY( llabs(-3) == 3 ); + + lldiv_t q = lldiv(6, 4); + VERIFY( q.quot == 1 ); + VERIFY( q.rem == 2 ); +} +#endif + +int main() +{ +#if _GLIBCXX_USE_C99 + test01(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/2190.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/2190.cc new file mode 100644 index 000000000..b3a5075ed --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/2190.cc @@ -0,0 +1,36 @@ +// 2000-01-01 bkoz + +// Copyright (C) 2001, 2002, 2003, 2009 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/>. + +// 17.4.1.2 Headers, cstdlib + +#include <cstdlib> + +// libstdc++/2190 +void test01() +{ + long a __attribute__((unused)) = std::abs(1L); + std::div(2L, 1L); + std::ldiv_t b __attribute__((unused)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/functions_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/functions_std.cc new file mode 100644 index 000000000..b37b588aa --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/functions_std.cc @@ -0,0 +1,30 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cstdlib> + +namespace gnu +{ + using std::abs; + using std::div; + using std::labs; + using std::ldiv; + using std::srand; + using std::rand; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/macros.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/macros.cc new file mode 100644 index 000000000..5aa0889df --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cstdlib> + +namespace gnu +{ +#ifndef RAND_MAX + #error "RAND_MAX_must_be_a_macro" +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std.cc new file mode 100644 index 000000000..503caf1dd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std.cc @@ -0,0 +1,26 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cstdlib> + +namespace gnu +{ + std::div_t d; + std::ldiv_t ld; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc new file mode 100644 index 000000000..0eb8b651a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <cstdlib> + +#if _GLIBCXX_HOSTED + +void test01() +{ +#if _GLIBCXX_USE_C99 + + typedef std::lldiv_t my_lldiv_t; + +#endif +} + +#endif diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc new file mode 100644 index 000000000..23b266e85 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007, 2009 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 <ctgmath> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/numeric_parallel_mode.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/numeric_parallel_mode.cc new file mode 100644 index 000000000..3db5fc22a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/numeric_parallel_mode.cc @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-D_GLIBCXX_PARALLEL -fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 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 <numeric> diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric.cc new file mode 100644 index 000000000..452f8fe35 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric.cc @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 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 <parallel/numeric> diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed1.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed1.cc new file mode 100644 index 000000000..a1ce8f052 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed1.cc @@ -0,0 +1,48 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 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 <parallel/numeric> +#include <numeric> +#include <vector> +#include <numeric> + +void test() +{ + typedef unsigned short value_type; + typedef std::vector<value_type> vector_type; + + const value_type c(0); + + vector_type v(10); + + std::accumulate(v.begin(), v.end(), value_type(1)); + std::accumulate(v.begin(), v.end(), value_type(1), std::plus<value_type>()); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1)); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1), + std::plus<value_type>()); + + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed2.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed2.cc new file mode 100644 index 000000000..a38d92561 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed2.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 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/>. + +// Make sure to test without _GLIBCXX_PARALLEL +#ifdef _GLIBCXX_PARALLEL +# undef _GLIBCXX_PARALLEL +#endif + +#include <parallel/numeric> +#include <numeric> +#include <vector> +#include <numeric> + +void test() +{ + typedef unsigned short value_type; + typedef std::vector<value_type> vector_type; + + const value_type c(0); + + vector_type v(10); + + std::accumulate(v.begin(), v.end(), value_type(1)); + std::accumulate(v.begin(), v.end(), value_type(1), std::plus<value_type>()); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1)); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1), + std::plus<value_type>()); + + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc new file mode 100644 index 000000000..21a21c9ff --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc @@ -0,0 +1,64 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <numeric> + +namespace std { + template <class InputIterator, class T> + T accumulate(InputIterator first, InputIterator last, T init); + + template <class InputIterator, class T, class BinaryOperation> + T accumulate(InputIterator first, InputIterator last, T init, + BinaryOperation binary_op); + + template <class InputIterator1, class InputIterator2, class T> + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init); + + template <class InputIterator1, class InputIterator2, class T, + class BinaryOperation1, class BinaryOperation2> + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, + BinaryOperation1 binary_op1, + BinaryOperation2 binary_op2); + + template <class InputIterator, class OutputIterator> + OutputIterator partial_sum(InputIterator first, + InputIterator last, + OutputIterator result); + + template <class InputIterator, class OutputIterator, + class BinaryOperation> + OutputIterator partial_sum(InputIterator first, + InputIterator last, + OutputIterator result, + BinaryOperation binary_op); + + template <class InputIterator, class OutputIterator> + OutputIterator adjacent_difference(InputIterator first, + InputIterator last, + OutputIterator result); + + template <class InputIterator, class OutputIterator, + class BinaryOperation> + OutputIterator adjacent_difference(InputIterator first, + InputIterator last, + OutputIterator result, + BinaryOperation binary_op); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc new file mode 100644 index 000000000..1f83cdac6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007, 2009 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 <random> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/random/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/random/types_std_c++0x.cc new file mode 100644 index 000000000..9f8ae967e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/random/types_std_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <random> + +namespace gnu +{ + using std::random_device; + using std::bernoulli_distribution; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/valarray/synopsis.cc b/libstdc++-v3/testsuite/26_numerics/headers/valarray/synopsis.cc new file mode 100644 index 000000000..2f7b08468 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/valarray/synopsis.cc @@ -0,0 +1,127 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <valarray> + +namespace std { + template<class T> class valarray; + + class slice; + template<class T> class slice_array; + + class gslice; + template<class T> class gslice_array; + template<class T> class mask_array; + template<class T> class indirect_array; + template<class T> valarray<T> operator* + (const valarray<T>&, const valarray<T>&); + template<class T> valarray<T> operator* (const valarray<T>&, const T&); + template<class T> valarray<T> operator* (const T&, const valarray<T>&); + +template<class T> valarray<T> operator/ + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator/ (const valarray<T>&, const T&); +template<class T> valarray<T> operator/ (const T&, const valarray<T>&); +template<class T> valarray<T> operator% + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator% (const valarray<T>&, const T&); +template<class T> valarray<T> operator% (const T&, const valarray<T>&); +template<class T> valarray<T> operator+ + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator+ (const valarray<T>&, const T&); +template<class T> valarray<T> operator+ (const T&, const valarray<T>&); +template<class T> valarray<T> operator- + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator- (const valarray<T>&, const T&); +template<class T> valarray<T> operator- (const T&, const valarray<T>&); +template<class T> valarray<T> operator^ + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator^ (const valarray<T>&, const T&); +template<class T> valarray<T> operator^ (const T&, const valarray<T>&); +template<class T> valarray<T> operator& + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator& (const valarray<T>&, const T&); +template<class T> valarray<T> operator& (const T&, const valarray<T>&); +template<class T> valarray<T> operator| + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator| (const valarray<T>&, const T&); +template<class T> valarray<T> operator| (const T&, const valarray<T>&); +template<class T> valarray<T> operator<< + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator<<(const valarray<T>&, const T&); +template<class T> valarray<T> operator<<(const T&, const valarray<T>&); +template<class T> valarray<T> operator>> + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator>>(const valarray<T>&, const T&); +template<class T> valarray<T> operator>>(const T&, const valarray<T>&); +template<class T> valarray<bool> operator&& + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<bool> operator&&(const valarray<T>&, const T&); +template<class T> valarray<bool> operator&&(const T&, const valarray<T>&); +template<class T> valarray<bool> operator|| + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<bool> operator||(const valarray<T>&, const T&); +template<class T> valarray<bool> operator||(const T&, const valarray<T>&); + + template<class T> + valarray<bool> operator==(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator==(const valarray<T>&, const T&); + template<class T> valarray<bool> operator==(const T&, const valarray<T>&); + template<class T> + valarray<bool> operator!=(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator!=(const valarray<T>&, const T&); + template<class T> valarray<bool> operator!=(const T&, const valarray<T>&); + template<class T> + valarray<bool> operator< (const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator< (const valarray<T>&, const T&); + template<class T> valarray<bool> operator< (const T&, const valarray<T>&); + template<class T> + valarray<bool> operator> (const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator> (const valarray<T>&, const T&); + template<class T> valarray<bool> operator> (const T&, const valarray<T>&); + template<class T> + valarray<bool> operator<=(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator<=(const valarray<T>&, const T&); + template<class T> valarray<bool> operator<=(const T&, const valarray<T>&); + template<class T> + valarray<bool> operator>=(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator>=(const valarray<T>&, const T&); + template<class T> valarray<bool> operator>=(const T&, const valarray<T>&); + template<class T> valarray<T> abs (const valarray<T>&); + template<class T> valarray<T> acos (const valarray<T>&); + template<class T> valarray<T> asin (const valarray<T>&); + template<class T> valarray<T> atan (const valarray<T>&); + template<class T> valarray<T> atan2 + (const valarray<T>&, const valarray<T>&); + template<class T> valarray<T> atan2(const valarray<T>&, const T&); + template<class T> valarray<T> atan2(const T&, const valarray<T>&); + template<class T> valarray<T> cos (const valarray<T>&); + template<class T> valarray<T> cosh (const valarray<T>&); + template<class T> valarray<T> exp (const valarray<T>&); + template<class T> valarray<T> log (const valarray<T>&); + template<class T> valarray<T> log10(const valarray<T>&); + template<class T> valarray<T> pow(const valarray<T>&, const valarray<T>&); + template<class T> valarray<T> pow(const valarray<T>&, const T&); + template<class T> valarray<T> pow(const T&, const valarray<T>&); + template<class T> valarray<T> sin (const valarray<T>&); + template<class T> valarray<T> sinh (const valarray<T>&); + template<class T> valarray<T> sqrt (const valarray<T>&); + template<class T> valarray<T> tan (const valarray<T>&); + template<class T> valarray<T> tanh (const valarray<T>&); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/valarray/types_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/valarray/types_std.cc new file mode 100644 index 000000000..7c47f27f6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/valarray/types_std.cc @@ -0,0 +1,26 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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 <valarray> + +namespace gnu +{ + typedef std::slice t1; + typedef std::gslice t2; +} diff --git a/libstdc++-v3/testsuite/26_numerics/inner_product/1.cc b/libstdc++-v3/testsuite/26_numerics/inner_product/1.cc new file mode 100644 index 000000000..c3d17b924 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/inner_product/1.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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.2 [lib.inner_product] + +#include <numeric> +#include <testsuite_hooks.h> + +int A1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +int A2[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; +const int NA = sizeof(A1) / sizeof(int); + +bool B1[] = {false, true, true, false, true, false, true, true, false, true}; +bool B2[] = {true, false, true, true, false, true, false, true, true, false}; +const int NB = sizeof(B1) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int res = std::inner_product(A1, A1 + NA, A2, 31); + VERIFY( res == 983 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + int res = std::inner_product(B1, B1 + NB, B2, 100); + VERIFY( res == 102 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/inner_product/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/26_numerics/inner_product/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..e00171fbe --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/inner_product/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_api.h> + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template value_type inner_product(iterator_type, iterator_type, iterator_type, value_type); +} diff --git a/libstdc++-v3/testsuite/26_numerics/inner_product/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/26_numerics/inner_product/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..303c56abf --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/inner_product/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_character.h> + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template value_type inner_product(iterator_type, iterator_type, iterator_type, value_type); +} diff --git a/libstdc++-v3/testsuite/26_numerics/iota/1.cc b/libstdc++-v3/testsuite/26_numerics/iota/1.cc new file mode 100644 index 000000000..3293b13e8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/iota/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 <numeric> +#include <algorithm> +#include <testsuite_hooks.h> + +int A[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; +int B[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; +int C[] = {-9, -8, -7, -6, -5, -4, -3, -2, -1}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::iota(A, A + N, 1); + VERIFY( std::equal(A, A + N, B) ); + + std::iota(A, A + N, -9); + VERIFY( std::equal(A, A + N, C) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..ff4530e06 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/2.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 <numeric> +#include <testsuite_api.h> + +namespace std +{ + typedef __gnu_test::NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template void iota(iterator_type, iterator_type, value_type); +} diff --git a/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..ee14829a6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 <numeric> +#include <testsuite_character.h> + +namespace std +{ + typedef __gnu_test::pod_int value_type; + typedef value_type* iterator_type; + + template void iota(iterator_type, iterator_type, value_type); +} diff --git a/libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc b/libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc new file mode 100644 index 000000000..8c49ddaaf --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// 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.3 [lib.partial.sum] + +#include <algorithm> +#include <numeric> +#include <testsuite_hooks.h> + +int A[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; +int B[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int D[N]; + + std::partial_sum(B, B + N, D); + VERIFY( std::equal(D, D + N, A) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/partial_sum/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/26_numerics/partial_sum/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..edd6b6e82 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/partial_sum/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_api.h> + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* input_iterator; + typedef value_type* output_iterator; + + template output_iterator partial_sum(input_iterator, input_iterator, output_iterator); +} diff --git a/libstdc++-v3/testsuite/26_numerics/partial_sum/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/26_numerics/partial_sum/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..6871a7416 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/partial_sum/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007, 2009 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 <numeric> +#include <testsuite_character.h> + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* input_iterator; + typedef value_type* output_iterator; + + template output_iterator partial_sum(input_iterator, input_iterator, output_iterator); +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/cons/default.cc new file mode 100644 index 000000000..16e56f805 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/cons/default.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.1 Class template bernoulli_distribution [rand.dist.bern.bernoulli] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::bernoulli_distribution u; + VERIFY( u.p() == 0.5 ); + VERIFY( u.min() == std::numeric_limits<bool>::min() ); + VERIFY( u.max() == std::numeric_limits<bool>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/cons/parms.cc new file mode 100644 index 000000000..9742e273a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/cons/parms.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.1 Class template bernoulli_distribution [rand.dist.bern.bernoulli] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::bernoulli_distribution u(0.75); + VERIFY( u.p() == 0.75 ); + VERIFY( u.min() == std::numeric_limits<bool>::min() ); + VERIFY( u.max() == std::numeric_limits<bool>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/equal.cc new file mode 100644 index 000000000..b3e8b9702 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::bernoulli_distribution u(0.75), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/inequal.cc new file mode 100644 index 000000000..6ed72faa1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::bernoulli_distribution u(0.75), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/serialize.cc new file mode 100644 index 000000000..3677ba7dd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.2.1 Class template bernoulli_distribution [rand.dist.bern.bernoulli] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::bernoulli_distribution u(0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..adea635e9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.1 Class template bernoulli_distribution [rand.dist.bern.bernoulli] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::bernoulli_distribution test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/cons/default.cc new file mode 100644 index 000000000..25fe4fbc5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.2 Class template binomial_distribution [rand.dist.bern.bin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::binomial_distribution<> u; + VERIFY( u.t() == 1 ); + VERIFY( u.p() == 0.5 ); + VERIFY( u.min() == 0 ); + VERIFY( u.max() == u.t() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/cons/parms.cc new file mode 100644 index 000000000..4381c6ea4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.2 Class template binomial_distribution [rand.dist.bern.bin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::binomial_distribution<> u(3, 0.75); + VERIFY( u.t() == 3 ); + VERIFY( u.p() == 0.75 ); + VERIFY( u.min() == 0 ); + VERIFY( u.max() == u.t() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/equal.cc new file mode 100644 index 000000000..9002614d4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::binomial_distribution<int> u(3, 0.75), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/inequal.cc new file mode 100644 index 000000000..fb05a0daa --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::binomial_distribution<int> u(3, 0.75), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/serialize.cc new file mode 100644 index 000000000..fb65018b9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/serialize.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.2.2 Class template binomial_distribution [rand.dist.bern.bin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + std::stringstream str; + std::binomial_distribution<int> u(3, 0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..e60fac13c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.2 Class template binomial_distribution [rand.dist.bern.bin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::binomial_distribution<int> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/cons/default.cc new file mode 100644 index 000000000..85a5c278c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.4 Class template cauchy_distribution [rand.dist.norm.cauchy] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::cauchy_distribution<> u; + VERIFY( u.a() == 0.0 ); + VERIFY( u.b() == 1.0 ); + typedef std::cauchy_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/cons/parms.cc new file mode 100644 index 000000000..54f6f81b3 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.4 Class template cauchy_distribution [rand.dist.norm.cauchy] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::cauchy_distribution<> u(5.0, 2.0); + VERIFY( u.a() == 5.0 ); + VERIFY( u.b() == 2.0 ); + typedef std::cauchy_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/equal.cc new file mode 100644 index 000000000..068c8ca04 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.4 class template cauchy_distribution [rand.dist.norm.cauchy] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::cauchy_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/inequal.cc new file mode 100644 index 000000000..de1e6f63c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.4 class template cauchy_distribution [rand.dist.norm.cauchy] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::cauchy_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/serialize.cc new file mode 100644 index 000000000..fd0d5f9db --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::cauchy_distribution<double> u(5.0, 2.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..3d80d2ddf --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.4 Class template cauchy_distribution [rand.dist.norm.cauchy] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::cauchy_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/cons/default.cc new file mode 100644 index 000000000..88e5ebb4c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.3 Class template chi_squared_distribution [rand.dist.norm.chisq] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::chi_squared_distribution<> u; + VERIFY( u.n() == 1 ); + typedef std::chi_squared_distribution<>::result_type result_type; + VERIFY( u.min() == 0.0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/cons/parms.cc new file mode 100644 index 000000000..a720aab5f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.3 Class template chi_squared_distribution [rand.dist.norm.chisq] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::chi_squared_distribution<> u(1.5); + VERIFY( u.n() == 1.5 ); + typedef std::chi_squared_distribution<>::result_type result_type; + VERIFY( u.min() == 0.0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/equal.cc new file mode 100644 index 000000000..e84e1046f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3 Class template chi_squared_distribution [rand.dist.norm.chisq] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::chi_squared_distribution<double> u(1.5), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/inequal.cc new file mode 100644 index 000000000..eb95739ef --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3 Class template chi_squared_distribution [rand.dist.norm.chisq] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::chi_squared_distribution<double> u(1.5), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/serialize.cc new file mode 100644 index 000000000..146eeae51 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.4.3 Class template chi_squared_distribution [rand.dist.norm.chisq] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::chi_squared_distribution<double> u(1.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..271e0fe45 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.3 Class template chi_squared_distribution [rand.dist.norm.chisq] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::chi_squared_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/default_random_engine.cc b/libstdc++-v3/testsuite/26_numerics/random/default_random_engine.cc new file mode 100644 index 000000000..3fef87d0c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/default_random_engine.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2006, 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [10] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::default_random_engine a; + a.discard(9999); + + // This is our choice for now. + std::minstd_rand0 b; + b.discard(9999); + + assert( a() == b() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc new file mode 100644 index 000000000..ded2205b1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + typedef std::subtract_with_carry_engine<unsigned long, 24, 10, 24> + base_engine; + + base_engine b; + + std::discard_block_engine<base_engine, 389, 24> e(b); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc new file mode 100644 index 000000000..4f903e530 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + typedef std::subtract_with_carry_engine<unsigned long, 24, 10, 24> + base_engine; + + std::discard_block_engine<base_engine, 389, 24> + e(std::move(base_engine())); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/copy.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/copy.cc new file mode 100644 index 000000000..6010c536c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/copy.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > e(1); + + const auto f(e); + auto g(f); + g = g; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc new file mode 100644 index 000000000..0868f8f4a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > e; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc new file mode 100644 index 000000000..ae9f2b4ce --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + unsigned long seed = 2; + + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > e(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc new file mode 100644 index 000000000..edf40b08c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + double seed = 2.0; + + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > e(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc new file mode 100644 index 000000000..c1f841a46 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + std::seed_seq seq; + + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > e(seq); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc new file mode 100644 index 000000000..5d63114fe --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > u, v; + + VERIFY( u == v ); + + u.discard(100); + v.discard(100); + + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/inequal.cc new file mode 100644 index 000000000..fff369b1b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/inequal.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.4.1 class template discard_block_engine [rand.adapt.disc] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > u, v; + + VERIFY( !(u != v) ); + + u.discard(100); + v.discard(100); + + VERIFY( !(u != v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc new file mode 100644 index 000000000..7aec649c0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::stringstream str; + std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > u, v; + + u(); // advance + str << u; + + VERIFY( !(u == v) ); + + str >> v; + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/constexpr_data.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/constexpr_data.cc new file mode 100644 index 000000000..1c70881fc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/constexpr_data.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::block_size; + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::used_block; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + typedef std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/constexpr_functions.cc new file mode 100644 index 000000000..77f4fb578 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/constexpr_functions.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + typedef std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc new file mode 100644 index 000000000..6e23316ca --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 Class template discard_blockl_engine [rand.adapt.disc] +// 26.4.2.3 Concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> + +void +test01() +{ + typedef std::discard_block_engine + < + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, + 389, 24 + > test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/default.cc new file mode 100644 index 000000000..9d05b1982 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/default.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::discrete_distribution<> u; + std::vector<double> probablility = u.probabilities(); + VERIFY( probablility.size() == 1 ); + VERIFY( probablility[0] == 1.0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/initlist.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/initlist.cc new file mode 100644 index 000000000..3bcb7448e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/initlist.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::discrete_distribution<> u({0.0, 2.0, 4.0, 3.0, 4.0, 0.0}); + std::vector<double> probablility = u.probabilities(); + VERIFY( probablility.size() == 6 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/num_xbound_fun.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/num_xbound_fun.cc new file mode 100644 index 000000000..12282f0f4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/num_xbound_fun.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <cmath> +#include <testsuite_hooks.h> + +struct cosine_distribution +{ + cosine_distribution(double x0, double lambda) + : _M_x0(x0), _M_lambda(lambda) + { } + + double + operator()(double x) + { + if (x - _M_x0 < -_M_lambda / 4) + return 0.0; + else if (x - _M_x0 > _M_lambda / 4) + return 0.0; + else + { + const double pi = 3.14159265358979323846; + return std::cos(2 * pi * (x - _M_x0) / _M_lambda); + } + } + +private: + double _M_x0; + double _M_lambda; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + cosine_distribution cd(1.5, 3.0); + std::discrete_distribution<> u(21, -10.0, 10.0, cd); + std::vector<double> probablility = u.probabilities(); + VERIFY( probablility.size() == 21 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/range.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/range.cc new file mode 100644 index 000000000..aa8d9567f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/cons/range.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> wt = {0.5, 1.0, 2.5, 1.5, 0.5}; + std::discrete_distribution<> u(wt.begin(), wt.end()); + std::vector<double> probablility = u.probabilities(); + VERIFY( probablility.size() == 5 ); + VERIFY( probablility[0] == 0.5 / 6.0 ); + VERIFY( probablility[2] == 2.5 / 6.0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/call-default.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/call-default.cc new file mode 100644 index 000000000..11e0d6879 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/call-default.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-10-13 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.1 Class template discrete_distribution +// [rand.dist.samp.discrete] + +#include <random> + +void +test01() +{ + std::discrete_distribution<> u; + std::minstd_rand0 rng; + + u(rng); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/equal.cc new file mode 100644 index 000000000..6ef26c9c6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/equal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> wt = { 0.5, 1.0, 2.5, 1.5, 0.5 }; + std::discrete_distribution<int> u(wt.begin(), wt.end()), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/inequal.cc new file mode 100644 index 000000000..2215a7008 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/inequal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> wt = { 0.5, 1.0, 2.5, 1.5, 0.5 }; + std::discrete_distribution<int> u(wt.begin(), wt.end()), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/serialize.cc new file mode 100644 index 000000000..c2ba51a12 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/serialize.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::vector<double> wt = {0.5, 1.0, 2.5, 1.5, 0.5}; + std::discrete_distribution<int> u(wt.begin(), wt.end()), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..7c5977b38 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.1 Class template discrete_distribution [rand.dist.samp.discrete] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::discrete_distribution<> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/cons/default.cc new file mode 100644 index 000000000..97168ff02 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2 Class template exponential_distribution [rand.dist.pois.exp] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::exponential_distribution<> u; + VERIFY( u.lambda() == 1.0 ); + typedef std::exponential_distribution<>::result_type result_type; + VERIFY( u.min() == 0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/cons/parms.cc new file mode 100644 index 000000000..6c2535fa0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2 Class template exponential_distribution [rand.dist.pois.exp] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::exponential_distribution<> u(0.5); + VERIFY( u.lambda() == 0.5 ); + typedef std::exponential_distribution<>::result_type result_type; + VERIFY( u.min() == 0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/equal.cc new file mode 100644 index 000000000..e4a30bba6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.2 Class template exponential_distribution [rand.dist.pois.exp] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::exponential_distribution<double> u(0.5), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/inequal.cc new file mode 100644 index 000000000..a3fbc2fbc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.2 Class template exponential_distribution [rand.dist.pois.exp] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::exponential_distribution<double> u(0.5), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/serialize.cc new file mode 100644 index 000000000..d1dca74c6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.2 Class template exponential_distribution [rand.dist.pois.exp] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::exponential_distribution<double> u(0.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..7c696e252 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2 Class template exponential_distribution [rand.dist.pois.exp] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::exponential_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/cons/default.cc new file mode 100644 index 000000000..542909588 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Class template extreme_value_distribution [rand.dist.pois.extreme] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::extreme_value_distribution<> u; + VERIFY( u.a() == 0.0 ); + VERIFY( u.b() == 1.0 ); + typedef std::extreme_value_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/cons/parms.cc new file mode 100644 index 000000000..d0374cd5c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Class template extreme_value_distribution [rand.dist.pois.extreme] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::extreme_value_distribution<> u(5.0, 2.0); + VERIFY( u.a() == 5.0 ); + VERIFY( u.b() == 2.0 ); + typedef std::extreme_value_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/equal.cc new file mode 100644 index 000000000..85e78a60c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.5 Class template extreme_value_distribution [rand.dist.pois.extreme] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::extreme_value_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/inequal.cc new file mode 100644 index 000000000..dbc65f837 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.5 Class template extreme_value_distribution [rand.dist.pois.extreme] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::extreme_value_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/serialize.cc new file mode 100644 index 000000000..2f68409b9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.5 Class template extreme_value_distribution [rand.dist.pois.extreme] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::extreme_value_distribution<double> u, v(5.0, 2.0); + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..8f5d99da4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Class template extreme_value_distribution [rand.dist.pois.extreme] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::extreme_value_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/cons/default.cc new file mode 100644 index 000000000..d3e8ae968 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.5 Class template fisher_f_distribution [rand.dist.norm.f] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::fisher_f_distribution<> u; + VERIFY( u.m() == 1.0 ); + VERIFY( u.n() == 1.0 ); + typedef std::fisher_f_distribution<>::result_type result_type; + VERIFY( u.min() == 0.0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/cons/parms.cc new file mode 100644 index 000000000..15133aba1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.5 Class template fisher_f_distribution [rand.dist.norm.f] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::fisher_f_distribution<> u(2.0, 3.0); + VERIFY( u.m() == 2.0 ); + VERIFY( u.n() == 3.0 ); + typedef std::fisher_f_distribution<>::result_type result_type; + VERIFY( u.min() == 0.0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/equal.cc new file mode 100644 index 000000000..bedb79e71 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 fisher_f_distribution [rand.dist.norm.f] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::fisher_f_distribution<double> u(2.0, 3.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/inequal.cc new file mode 100644 index 000000000..ae19853a0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 fisher_f_distribution [rand.dist.norm.f] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::fisher_f_distribution<double> u(2.0, 3.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/serialize.cc new file mode 100644 index 000000000..52640f3fc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.4.5 Class template fisher_f_distribution [rand.dist.norm.f] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::fisher_f_distribution<double> u(2.0, 3.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..a92727d70 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.5 Class template fisher_f_distribution [rand.dist.norm.f] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::fisher_f_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/cons/default.cc new file mode 100644 index 000000000..378eca23b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3 Class template gamma_distribution [rand.dist.pois.gamma] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::gamma_distribution<> u; + VERIFY( u.alpha() == 1.0 ); + VERIFY( u.beta() == 1.0 ); + VERIFY( u.min() == 0.0 ); + typedef std::gamma_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/26_numerics/random/gamma_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/cons/parms.cc new file mode 100644 index 000000000..c400c98df --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3 Class template gamma_distribution [rand.dist.pois.gamma] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::gamma_distribution<> u(1.5, 3.0); + VERIFY( u.alpha() == 1.5 ); + VERIFY( u.beta() == 3.0 ); + VERIFY( u.min() == 0.0 ); + typedef std::gamma_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/26_numerics/random/gamma_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/equal.cc new file mode 100644 index 000000000..131132f04 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.3 Class template gamma_distribution [rand.dist.pois.gamma] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::gamma_distribution<double> u(1.5, 3.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/inequal.cc new file mode 100644 index 000000000..1fe8057da --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.3 Class template gamma_distribution [rand.dist.pois.gamma] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::gamma_distribution<double> u(1.5, 3.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/serialize.cc new file mode 100644 index 000000000..0c24b7a5b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.3 Class template gamma_distribution [rand.dist.pois.gamma] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::gamma_distribution<double> u(1.5, 3.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..a1d15575e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3 Class template gamma_distribution [rand.dist.pois.gamma] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::gamma_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/cons/default.cc new file mode 100644 index 000000000..353193bbd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.3 Class template geometric_distribution [rand.dist.bern.geo] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::geometric_distribution<> u; + VERIFY( u.p() == 0.5 ); + VERIFY( u.min() == 0 ); + typedef std::geometric_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/26_numerics/random/geometric_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/cons/parms.cc new file mode 100644 index 000000000..ddc667675 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.3 Class template geometric_distribution [rand.dist.bern.geo] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::geometric_distribution<> u(0.75); + VERIFY( u.p() == 0.75 ); + VERIFY( u.min() == 0 ); + typedef std::geometric_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/26_numerics/random/geometric_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/equal.cc new file mode 100644 index 000000000..bd20f9262 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::geometric_distribution<int> u(0.75), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/inequal.cc new file mode 100644 index 000000000..19031ccf3 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::geometric_distribution<int> u(0.75), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/serialize.cc new file mode 100644 index 000000000..75de1b88c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.2.3 Class template geometric_distribution [rand.dist.bern.geom] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::geometric_distribution<int> u(0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..cc03ebf0d --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.3 Class template geometric_distribution [rand.dist.bern.geom] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::geometric_distribution<int> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/base_copy.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/base_copy.cc new file mode 100644 index 000000000..81d5d8f18 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/base_copy.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + typedef std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> + base_engine; + + base_engine b; + + std::independent_bits_engine<base_engine, 48, uint_fast64_t> e(b); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/base_move.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/base_move.cc new file mode 100644 index 000000000..c5747b306 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/base_move.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + typedef std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> + base_engine; + + std::independent_bits_engine<base_engine, 48, uint_fast64_t> + e(std::move(base_engine())); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/copy.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/copy.cc new file mode 100644 index 000000000..111af1964 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/copy.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::independent_bits_engine + < + std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, + uint_fast64_t + > e(1); + + const auto f(e); + auto g(f); + g = g; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/default.cc new file mode 100644 index 000000000..781e7a9e2 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/default.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + std::independent_bits_engine + < + std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, + uint_fast64_t + > e; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed1.cc new file mode 100644 index 000000000..890045d86 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed1.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + unsigned long seed = 2; + + std::independent_bits_engine + < + std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, + uint_fast64_t + > e(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed2.cc new file mode 100644 index 000000000..973ddd4dc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed2.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + double seed = 2.0; + + std::independent_bits_engine + < + std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, + uint_fast64_t + > e(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq.cc new file mode 100644 index 000000000..dcaed2d75 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + std::seed_seq seq; + + std::independent_bits_engine + < + std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, + uint_fast64_t + > e(seq); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/equal.cc new file mode 100644 index 000000000..18d05140d --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/equal.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::independent_bits_engine + <std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, uint_fast64_t> u, v; + + VERIFY( u == v ); + + u.discard(100); + v.discard(100); + + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/inequal.cc new file mode 100644 index 000000000..a1e05a715 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/inequal.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.4.2 class template independent_bits_engine [rand.adapt.bits] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::independent_bits_engine + <std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, uint_fast64_t> u, v; + + VERIFY( !(u != v) ); + + u.discard(100); + v.discard(100); + + VERIFY( !(u != v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/serialize.cc new file mode 100644 index 000000000..332931add --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/operators/serialize.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::stringstream str; + std::independent_bits_engine + <std::subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>, + 48, uint_fast64_t> u, v; + + u(); // advance + str << u; + + VERIFY( !(u == v) ); + + str >> v; + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/requirements/constexpr_functions.cc new file mode 100644 index 000000000..b10d36fb7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/requirements/constexpr_functions.cc @@ -0,0 +1,62 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + typedef std::independent_bits_engine + < + std::subtract_with_carry_engine + < + uint_fast64_t, 48, 5, 12 + >, + 48, uint_fast64_t + > type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/requirements/typedefs.cc new file mode 100644 index 000000000..0402a0966 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/requirements/typedefs.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.2 class template independent_bits_engine [rand.adapt.ibits] +// 26.4.2.3 Concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> + +void +test01() +{ + typedef std::independent_bits_engine + < + std::subtract_with_carry_engine + < + uint_fast64_t, 48, 5, 12 + >, + 48, uint_fast64_t + > test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/knuth_b.cc b/libstdc++-v3/testsuite/26_numerics/random/knuth_b.cc new file mode 100644 index 000000000..ba4016eab --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/knuth_b.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2006, 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [9] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::knuth_b a; + a.discard(9999); + + VERIFY( a() == 1112339016 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/copy.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/copy.cc new file mode 100644 index 000000000..6f5b8d297 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/copy.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::linear_congruential_engine<unsigned long, 48271, 0, 2147483647> e(1); + + const auto f(e); + auto g(f); + g = g; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/default.cc new file mode 100644 index 000000000..42ca73c73 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/default.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.1 class template linear_congruential_engine [rand.eng.lcong] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::linear_congruential_engine<unsigned long, 48271, 0, 2147483647> x; + VERIFY( x.min() == 1 ); + VERIFY( x.max() == 2147483647-1 ); + VERIFY( x() == 48271 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed1.cc new file mode 100644 index 000000000..06d04775b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed1.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + unsigned long seed = 2; + std::linear_congruential_engine<unsigned long, 48271, 0, 2147483647> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed2.cc new file mode 100644 index 000000000..1fa23dff2 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed2.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + double seed = 2.0; + std::linear_congruential_engine<unsigned long, 48271, 0, 2147483647> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq.cc new file mode 100644 index 000000000..d09d83824 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::seed_seq seed; + std::linear_congruential_engine<unsigned long, 48271, 0, 2147483647> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/equal.cc new file mode 100644 index 000000000..5f555db48 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/equal.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.1 class template linear_congruential_engine [rand.eng.lcong] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::minstd_rand0 a; + std::minstd_rand0 b; + std::minstd_rand0 c(120); + + VERIFY( a == b ); + VERIFY( !(a == c) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/inequal.cc new file mode 100644 index 000000000..768837a30 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/inequal.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.1 class template linear_congruential_engine [rand.eng.lcong] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::minstd_rand0 a; + std::minstd_rand0 b; + std::minstd_rand0 c(120); + + VERIFY( a != c ); + VERIFY( !(a != b) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/serialize.cc new file mode 100644 index 000000000..8b67e5f3a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/serialize.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.1 class template linear_congruential_engine [rand.eng.lcong] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::stringstream str; + std::minstd_rand0 a; + std::minstd_rand0 b; + + a(); // advance + str << a; + VERIFY( !(a == b) ); + + str >> b; + VERIFY( a == b ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constants.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constants.cc new file mode 100644 index 000000000..2b48164fb --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constants.cc @@ -0,0 +1,41 @@ +// { dg-do link } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-09-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009, 2010 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 <random> + +void test01() +{ + std::minstd_rand0 lc; + + const void* p = &lc.multiplier; + p = &lc.increment; + p = &lc.modulus; + p = &lc.default_seed; + p = p; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_data.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_data.cc new file mode 100644 index 000000000..1e8171b5c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_data.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::multiplier; + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::increment; + constexpr auto v3 __attribute__((unused)) + = _Ttesttype::modulus; + constexpr auto v4 __attribute__((unused)) + = _Ttesttype::default_seed; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + typedef std::linear_congruential_engine<unsigned int, 41, 0, 2147483647> type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_functions.cc new file mode 100644 index 000000000..7917a9906 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_functions.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + typedef std::linear_congruential_engine<unsigned int, 41, 0, 2147483647> type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc new file mode 100644 index 000000000..18fb44fda --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc @@ -0,0 +1,33 @@ +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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/>. + +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// { dg-error "not a valid type" "" { target *-*-* } 32 } +// { dg-error "invalid type" "" { target *-*-* } 32 } + +// 26.4.3.1 class template linear_congruential_engine [rand.eng.lcong] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> + +std::linear_congruential_engine<double, 48271, 0, 2147483647> x; + diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/typedefs.cc new file mode 100644 index 000000000..993f79354 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.1 class template linear_congruential_engine [rand.eng.lcong] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> + +void +test01() +{ + typedef std::linear_congruential_engine<unsigned long, 2, 0, 4> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/cons/default.cc new file mode 100644 index 000000000..9607fd3e8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.2 Class template lognormal_distribution [rand.dist.norm.lognormal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::lognormal_distribution<> u; + VERIFY( u.m() == 0.0 ); + VERIFY( u.s() == 1.0 ); + typedef std::lognormal_distribution<>::result_type result_type; + VERIFY( u.min() == 0.0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/cons/parms.cc new file mode 100644 index 000000000..a18f93508 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.2 Class template lognormal_distribution [rand.dist.norm.lognormal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::lognormal_distribution<> u(5.0, 2.0); + VERIFY( u.m() == 5.0 ); + VERIFY( u.s() == 2.0 ); + typedef std::lognormal_distribution<>::result_type result_type; + VERIFY( u.min() == 0.0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/equal.cc new file mode 100644 index 000000000..684c0ca93 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.2 Class template lognormal_distribution [rand.dist.norm.lognormal] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::lognormal_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/inequal.cc new file mode 100644 index 000000000..ce427e573 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.2 Class template lognormal_distribution [rand.dist.norm.lognormal] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::lognormal_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/serialize.cc new file mode 100644 index 000000000..877b6aab5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.4.2 Class template lognormal_distribution [rand.dist.norm.lognormal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::lognormal_distribution<double> u(5.0, 2.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..2e3ade699 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.2 Class template lognormal_distribution [rand.dist.norm.lognormal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::lognormal_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/copy.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/copy.cc new file mode 100644 index 000000000..98ea4fe03 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/copy.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + typedef unsigned long value_type; + + std::mersenne_twister_engine< + value_type, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> e(1); + + const auto f(e); + auto g(f); + g = g; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/default.cc new file mode 100644 index 000000000..be5716080 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/default.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + typedef unsigned long value_type; + + std::mersenne_twister_engine< + value_type, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> x; + + VERIFY( x.min() == 0 ); + VERIFY( x.max() == 4294967295ul ); + VERIFY( x() == 3499211612ul ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed1.cc new file mode 100644 index 000000000..cf24ffe13 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed1.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + unsigned long seed = 2; + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed2.cc new file mode 100644 index 000000000..425e5be7d --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed2.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + double seed = 2.0; + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq.cc new file mode 100644 index 000000000..aa98c9b93 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::seed_seq seed; + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/equal.cc new file mode 100644 index 000000000..7e482a8cd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/equal.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.2 Class template mersenne_twister_engine [rand.eng.mers] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> u, v; + + VERIFY( u == v ); + + u.discard(100); + v.discard(100); + + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/inequal.cc new file mode 100644 index 000000000..94ccb76f7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/inequal.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.2 Class template mersenne_twister_engine [rand.eng.mers] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> u, v; + + VERIFY( !(u != v) ); + + u.discard(100); + v.discard(100); + + VERIFY( !(u != v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/serialize.cc new file mode 100644 index 000000000..03fb8b04f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/operators/serialize.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.2 Class template mersenne_twister_engine [rand.eng.mers] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <sstream> +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::stringstream str; + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> u, v; + + u(); // advance + str << u; + + VERIFY( !(u == v) ); + + str >> v; + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constants.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constants.cc new file mode 100644 index 000000000..ad38bec01 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constants.cc @@ -0,0 +1,51 @@ +// { dg-do link } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-09-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009, 2010 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 <random> + +void test01() +{ + std::mt19937 mt; + + const void* p = &mt.word_size; + p = &mt.state_size; + p = &mt.shift_size; + p = &mt.mask_bits; + p = &mt.xor_mask; + p = &mt.tempering_u; + p = &mt.tempering_d; + p = &mt.tempering_s; + p = &mt.tempering_b; + p = &mt.tempering_t; + p = &mt.tempering_c; + p = &mt.tempering_l; + p = &mt.initialization_multiplier; + p = &mt.default_seed; + p = p; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constexpr_data.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constexpr_data.cc new file mode 100644 index 000000000..4a27982b4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constexpr_data.cc @@ -0,0 +1,79 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::word_size; + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::state_size; + constexpr auto v3 __attribute__((unused)) + = _Ttesttype::shift_size; + constexpr auto v4 __attribute__((unused)) + = _Ttesttype::mask_bits; + constexpr auto v5 __attribute__((unused)) + = _Ttesttype::xor_mask; + constexpr auto v6 __attribute__((unused)) + = _Ttesttype::tempering_u; + constexpr auto v7 __attribute__((unused)) + = _Ttesttype::tempering_d; + constexpr auto v8 __attribute__((unused)) + = _Ttesttype::tempering_s; + constexpr auto v9 __attribute__((unused)) + = _Ttesttype::tempering_b; + constexpr auto v10 __attribute__((unused)) + = _Ttesttype::tempering_t; + constexpr auto v11 __attribute__((unused)) + = _Ttesttype::tempering_c; + constexpr auto v12 __attribute__((unused)) + = _Ttesttype::tempering_l; + constexpr auto v13 __attribute__((unused)) + = _Ttesttype::initialization_multiplier; + constexpr auto v14 __attribute__((unused)) + = _Ttesttype::default_seed; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + typedef std::mt19937 type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constexpr_functions.cc new file mode 100644 index 000000000..03513acf8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/constexpr_functions.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + typedef std::mt19937 type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/typedefs.cc new file mode 100644 index 000000000..7ea898a1e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/requirements/typedefs.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.2 Class template mersenne_twister_engine [rand.eng.mers] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> + +void +test01() +{ + typedef std::mersenne_twister_engine<unsigned long, + 32, 624, 397, 31, + 0x9908b0df, 11, + 0xfffffffful, 7, + 0x9d2c5680, 15, + 0xefc60000, 18, 1812433253ul> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/minstd_rand.cc b/libstdc++-v3/testsuite/26_numerics/random/minstd_rand.cc new file mode 100644 index 000000000..33f5c0355 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/minstd_rand.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2006, 2008, 2009 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.5 Engines with predefined parameters +// 26.4.5 [2] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::minstd_rand a; + a.discard(9999); + + VERIFY( a() == 399268537 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/minstd_rand0.cc b/libstdc++-v3/testsuite/26_numerics/random/minstd_rand0.cc new file mode 100644 index 000000000..51716b3c9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/minstd_rand0.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [1] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::minstd_rand0 a; + a.discard(9999); + + VERIFY( a() == 1043618065 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mt19937.cc b/libstdc++-v3/testsuite/26_numerics/random/mt19937.cc new file mode 100644 index 000000000..2703ae3e8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mt19937.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2006, 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [3] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::mt19937 a; + a.discard(9999); + + VERIFY( a() == 4123659995ul ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/mt19937_64.cc b/libstdc++-v3/testsuite/26_numerics/random/mt19937_64.cc new file mode 100644 index 000000000..47ef8cfcf --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/mt19937_64.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [4] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::mt19937_64 a; + a.discard(9999); + + VERIFY( a() == 9981545732273789042ull ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/cons/default.cc new file mode 100644 index 000000000..02a7836ef --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.4 Class template negative_binomial_distribution [rand.dist.bern.negbin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::negative_binomial_distribution<> u; + VERIFY( u.k() == 1 ); + VERIFY( u.p() == 0.5 ); + typedef std::negative_binomial_distribution<>::result_type result_type; + VERIFY( u.min() == 0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/cons/parms.cc new file mode 100644 index 000000000..3db9c0bd1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.4 Class template negative_binomial_distribution [rand.dist.bern.negbin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::negative_binomial_distribution<> u(3, 0.75); + VERIFY( u.k() == 3 ); + VERIFY( u.p() == 0.75 ); + typedef std::negative_binomial_distribution<>::result_type result_type; + VERIFY( u.min() == 0 ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/equal.cc new file mode 100644 index 000000000..08ec8938f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/equal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.4 Class template negative_binomial_distribution +// [rand.dist.bern.negbin] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::negative_binomial_distribution<int> u(3, 0.75), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/inequal.cc new file mode 100644 index 000000000..86d23e770 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/inequal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.4 Class template negative_binomial_distribution +// [rand.dist.bern.negbin] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::negative_binomial_distribution<int> u(3, 0.75), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/serialize.cc new file mode 100644 index 000000000..7320f5224 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/serialize.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.2.4 Class template negative_binomial_distribution +// [rand.dist.bern.negbin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::negative_binomial_distribution<int> u(3, 0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..5b30fda67 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.2.4 Class template negative_binomial_distribution [rand.dist.bern.negbin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::negative_binomial_distribution<int> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/cons/default.cc new file mode 100644 index 000000000..fca0cc188 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 Class template normal_distribution [rand.dist.norm.normal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::normal_distribution<> u; + VERIFY( u.mean() == 0.0 ); + VERIFY( u.stddev() == 1.0 ); + typedef std::normal_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/cons/parms.cc new file mode 100644 index 000000000..ea3113dd0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 Class template normal_distribution [rand.dist.norm.normal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::normal_distribution<> u(5.0, 2.0); + VERIFY( u.mean() == 5.0 ); + VERIFY( u.stddev() == 2.0 ); + typedef std::normal_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/equal.cc new file mode 100644 index 000000000..6dac4b386 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.1 Class template normal_distribution [rand.dist.norm.normal] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::normal_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/inequal.cc new file mode 100644 index 000000000..e3a31f68e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.1 Class template normal_distribution [rand.dist.norm.normal] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::normal_distribution<double> u(5.0, 2.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/serialize.cc new file mode 100644 index 000000000..c88e0a19b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.4.1 Class template normal_distribution [rand.dist.norm.normal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::normal_distribution<double> u(5.0, 2.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..471379d55 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 Class template normal_distribution [rand.dist.norm.normal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::normal_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/default.cc new file mode 100644 index 000000000..cdfa3d061 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/default.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.2 Class template piecewise_constant_distribution [rand.dist.samp.pconst] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::piecewise_constant_distribution<> u; + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 2 ); + VERIFY( interval[0] == 0.0 ); + VERIFY( interval[1] == 1.0 ); + VERIFY( density.size() == 1 ); + VERIFY( density[0] == 1.0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/initlist_fun.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/initlist_fun.cc new file mode 100644 index 000000000..7ae5d89be --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/initlist_fun.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.2 Class template piecewise_constant_distribution +// [rand.dist.samp.pconst] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <cmath> +#include <testsuite_hooks.h> + +struct cosine_distribution +{ + cosine_distribution(double x0, double lambda) + : _M_x0(x0), _M_lambda(lambda) + { } + + double + operator()(double x) + { + if (x - _M_x0 < -_M_lambda / 4) + return 0.0; + else if (x - _M_x0 > _M_lambda / 4) + return 0.0; + else + { + const double pi = 3.14159265358979323846; + return std::cos(2 * pi * (x - _M_x0) / _M_lambda); + } + } + +private: + double _M_x0; + double _M_lambda; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + cosine_distribution cd(1.5, 3.0); + std::piecewise_constant_distribution<> u({-10.0, -8.0, -6.0, -4.0, -2.0, + 0.0, 2.0, 4.0, 6.0, 8.0, 10.0}, + cd); + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 11 ); + VERIFY( density.size() == 10 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/num_xbound_fun.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/num_xbound_fun.cc new file mode 100644 index 000000000..a7c7589fe --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/num_xbound_fun.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.2 Class template piecewise_constant_distribution +// [rand.dist.samp.pconst] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <cmath> +#include <testsuite_hooks.h> + +struct cosine_distribution +{ + cosine_distribution(double x0, double lambda) + : _M_x0(x0), _M_lambda(lambda) + { } + + double + operator()(double x) + { + if (x - _M_x0 < -_M_lambda / 4) + return 0.0; + else if (x - _M_x0 > _M_lambda / 4) + return 0.0; + else + { + const double pi = 3.14159265358979323846; + return std::cos(2 * pi * (x - _M_x0) / _M_lambda); + } + } + +private: + double _M_x0; + double _M_lambda; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + cosine_distribution cd(1.5, 3.0); + std::piecewise_constant_distribution<> u(21, -10.0, 10.0, cd); + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 22 ); + VERIFY( density.size() == 21 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/range.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/range.cc new file mode 100644 index 000000000..d0f7dbf53 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/range.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.2 Class template piecewise_constant_distribution [rand.dist.samp.pconst] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + std::vector<double> wt = {0.5, 1.0, 2.5, 1.5, 0.5}; + std::piecewise_constant_distribution<> u(x.begin(), x.end(), wt.begin()); + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 6 ); + VERIFY( interval[0] == 0.0 ); + VERIFY( interval[5] == 5.0 ); + VERIFY( density.size() == 5 ); + VERIFY( density[0] == 0.5 / 6.0 ); + VERIFY( density[2] == 2.5 / 6.0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/call-default.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/call-default.cc new file mode 100644 index 000000000..fe2b9620a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/call-default.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-10-13 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.2 Class template piecewise_constant_distribution +// [rand.dist.samp.pconst] + +#include <random> + +void +test01() +{ + std::piecewise_constant_distribution<> u; + std::minstd_rand0 rng; + + u(rng); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/equal.cc new file mode 100644 index 000000000..fc74cf11a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/equal.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.2 Class template piecewise_constant_distribution +// [rand.dist.samp.pconst] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> x = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector<double> wt = { 0.5, 1.0, 2.5, 1.5, 0.5 }; + std::piecewise_constant_distribution<double> + u(x.begin(), x.end(), wt.begin()), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/inequal.cc new file mode 100644 index 000000000..dec264d1c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/inequal.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.2 Class template piecewise_constant_distribution +// [rand.dist.samp.pconst] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> x = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector<double> wt = { 0.5, 1.0, 2.5, 1.5, 0.5 }; + std::piecewise_constant_distribution<double> + u(x.begin(), x.end(), wt.begin()), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize.cc new file mode 100644 index 000000000..e1136796d --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.5.2 Class template piecewise_constant_distribution +// [rand.dist.samp.pconst] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + std::vector<double> wt = {0.5, 1.0, 2.5, 1.5, 0.5}; + std::piecewise_constant_distribution<double> + u(x.begin(), x.end(), wt.begin()), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..c0d458ef6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.2 Class template piecewise_constant_distribution [rand.dist.samp.pconst] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::piecewise_constant_distribution<> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/default.cc new file mode 100644 index 000000000..d2db1765a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/default.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.3 Class template piecewise_linear_distribution [rand.dist.samp.plinear] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::piecewise_linear_distribution<> u; + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 2 ); + VERIFY( interval[0] == 0.0 ); + VERIFY( interval[1] == 1.0 ); + VERIFY( density.size() == 2 ); + VERIFY( density[0] == 1.0 ); + VERIFY( density[1] == 1.0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/initlist_fun.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/initlist_fun.cc new file mode 100644 index 000000000..564aeeea2 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/initlist_fun.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.3 Class template piecewise_linear_distribution +// [rand.dist.samp.plinear] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <cmath> +#include <testsuite_hooks.h> + +struct cosine_distribution +{ + cosine_distribution(double x0, double lambda) + : _M_x0(x0), _M_lambda(lambda) + { } + + double + operator()(double x) + { + if (x - _M_x0 < -_M_lambda / 4) + return 0.0; + else if (x - _M_x0 > _M_lambda / 4) + return 0.0; + else + { + const double pi = 3.14159265358979323846; + return std::cos(2 * pi * (x - _M_x0) / _M_lambda); + } + } + +private: + double _M_x0; + double _M_lambda; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + cosine_distribution cd(1.5, 3.0); + std::piecewise_linear_distribution<> u({-10.0, -8.0, -6.0, -4.0, -2.0, + 0.0, 2.0, 4.0, 6.0, 8.0, 10.0}, + cd); + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 11 ); + VERIFY( density.size() == 11 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/num_xbound_fun.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/num_xbound_fun.cc new file mode 100644 index 000000000..e4eb0e8fe --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/num_xbound_fun.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.3 Class template piecewise_linear_distribution +// [rand.dist.samp.plinear] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <cmath> +#include <testsuite_hooks.h> + +struct cosine_distribution +{ + cosine_distribution(double x0, double lambda) + : _M_x0(x0), _M_lambda(lambda) + { } + + double + operator()(double x) + { + if (x - _M_x0 < -_M_lambda / 4) + return 0.0; + else if (x - _M_x0 > _M_lambda / 4) + return 0.0; + else + { + const double pi = 3.14159265358979323846; + return std::cos(2 * pi * (x - _M_x0) / _M_lambda); + } + } + +private: + double _M_x0; + double _M_lambda; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + cosine_distribution cd(1.5, 3.0); + std::piecewise_linear_distribution<> u(21, -10.0, 10.0, cd); + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 22 ); + VERIFY( density.size() == 22 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/range.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/range.cc new file mode 100644 index 000000000..56be0ad9b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/range.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.3 Class template piecewise_linear_distribution [rand.dist.samp.plinear] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + std::vector<double> wt = {0.0, 1.0, 2.5, 1.5, 3.5, 0.0}; + std::piecewise_linear_distribution<> u(x.begin(), x.end(), wt.begin()); + std::vector<double> interval = u.intervals(); + std::vector<double> density = u.densities(); + VERIFY( interval.size() == 6 ); + VERIFY( interval[0] == 0.0 ); + VERIFY( interval[5] == 5.0 ); + VERIFY( density.size() == 6 ); + VERIFY( density[0] == 0.0 ); + VERIFY( density[4] == 3.5 / 8.5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/call-default.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/call-default.cc new file mode 100644 index 000000000..426c4d837 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/call-default.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-10-12 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.3 Class template piecewise_linear_distribution +// [rand.dist.samp.plinear] + +#include <random> + +void +test01() +{ + std::piecewise_linear_distribution<> u; + std::minstd_rand0 rng; + + u(rng); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/equal.cc new file mode 100644 index 000000000..c3510b9cc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/equal.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.3 Class template piecewise_linear_distribution +// [rand.dist.samp.plinear] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> x = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector<double> wt = { 0.0, 1.0, 2.5, 1.5, 0.5, 0.0 }; + std::piecewise_linear_distribution<double> + u(x.begin(), x.end(), wt.begin()), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/inequal.cc new file mode 100644 index 000000000..bbb96dc0e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/inequal.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.5.3 Class template piecewise_linear_distribution +// [rand.dist.samp.plinear] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<double> x = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; + std::vector<double> wt = { 0.0, 1.0, 2.5, 1.5, 0.5, 0.0 }; + std::piecewise_linear_distribution<double> + u(x.begin(), x.end(), wt.begin()), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize.cc new file mode 100644 index 000000000..75ea5a700 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.5.3 Class template piecewise_linear_distribution +// [rand.dist.samp.plinear] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + std::vector<double> wt = {0.0, 1.0, 2.5, 1.5, 0.5, 0.0}; + std::piecewise_linear_distribution<double> + u(x.begin(), x.end(), wt.begin()), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..cb1d016dc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-03 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5.3 Class template piecewise_linear_distribution [rand.dist.samp.plinear] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::piecewise_linear_distribution<> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/cons/default.cc new file mode 100644 index 000000000..df396c4c0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1 Class template poisson_distribution [rand.dist.pois.poisson] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::poisson_distribution<> u; + VERIFY( u.mean() == 1.0 ); + VERIFY( u.min() == 0 ); + typedef std::poisson_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/26_numerics/random/poisson_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/cons/parms.cc new file mode 100644 index 000000000..728587bd2 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1 Class template poisson_distribution [rand.dist.pois.poisson] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::poisson_distribution<> u(5.0); + VERIFY( u.mean() == 5.0 ); + VERIFY( u.min() == 0 ); + typedef std::poisson_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/26_numerics/random/poisson_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/equal.cc new file mode 100644 index 000000000..3ded153fe --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.1 Class template poisson_distribution [rand.dist.pois.poisson] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::poisson_distribution<int> u(5.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/inequal.cc new file mode 100644 index 000000000..a996dc154 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.1 Class template poisson_distribution [rand.dist.pois.poisson] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::poisson_distribution<int> u(5.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/serialize.cc new file mode 100644 index 000000000..315e309db --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.1 Class template poisson_distribution [rand.dist.pois.poisson] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::poisson_distribution<int> u(5.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..d6a600293 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1 Class template poisson_distribution [rand.dist.pois.poisson] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::poisson_distribution<int> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/default.cc new file mode 100644 index 000000000..2e21ab6a9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/default.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.6 class random_device [rand.device] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::random_device x; + + VERIFY( x.min() == std::numeric_limits<std::random_device::result_type>::min() ); + VERIFY( x.max() == std::numeric_limits<std::random_device::result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc new file mode 100644 index 000000000..638134cf4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.6 class random_device [rand.device] +// 26.4.6 [3] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + +#ifdef _GLIBCXX_USE_RANDOM_TR1 + std::random_device x("/dev/random"); +#else + std::random_device x("0"); +#endif + + VERIFY( x.min() == std::numeric_limits<std::random_device::result_type>::min() ); + VERIFY( x.max() == std::numeric_limits<std::random_device::result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/requirements/typedefs.cc new file mode 100644 index 000000000..47a76b613 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.6 class random_device [rand.device] + +#include <random> + +void +test01() +{ + typedef std::random_device test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/ranlux24.cc b/libstdc++-v3/testsuite/26_numerics/random/ranlux24.cc new file mode 100644 index 000000000..f7352146d --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/ranlux24.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [7] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ranlux24 a; + a.discard(9999); + + VERIFY( a() == 9901578ul ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/ranlux24_base.cc b/libstdc++-v3/testsuite/26_numerics/random/ranlux24_base.cc new file mode 100644 index 000000000..65cf97560 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/ranlux24_base.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [5] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ranlux24_base a; + a.discard(9999); + + VERIFY( a() == 7937952ul ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/ranlux48.cc b/libstdc++-v3/testsuite/26_numerics/random/ranlux48.cc new file mode 100644 index 000000000..095242c1c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/ranlux48.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [8] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ranlux48 a; + a.discard(9999); + + VERIFY( a() == 249142670248501ull ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/ranlux48_base.cc b/libstdc++-v3/testsuite/26_numerics/random/ranlux48_base.cc new file mode 100644 index 000000000..42c423c73 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/ranlux48_base.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-18 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.5 Engines and egine adaptors with predefined parameters [rand.predef] +// 26.4.5 [6] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ranlux48_base a; + a.discard(9999); + + VERIFY( a() == 61839128582725ull ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc new file mode 100644 index 000000000..c68c1b446 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-05 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.7.1 Class seed_seq [rand.util.seedseq] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + std::seed_seq seq; + + std::vector<unsigned> foo(10000); + seq.generate(foo.begin(), foo.end()); + + VERIFY( seq.size() == 0 ); + //VERIFY(); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc new file mode 100644 index 000000000..d98b6b2c4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-02-13 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.7.1 Class seed_seq [rand.util.seedseq] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::seed_seq seq({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::vector<unsigned> foo(10000); + seq.generate(foo.begin(), foo.end()); + + VERIFY( seq.size() == 10 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/range.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/range.cc new file mode 100644 index 000000000..69740c888 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/range.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-05 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.7.1 Class seed_seq [rand.util.seedseq] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + unsigned in[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + std::seed_seq seq(in, in + 10); + + std::vector<unsigned> foo(10000); + seq.generate(foo.begin(), foo.end()); + + VERIFY( seq.size() == 10 ); + //VERIFY(); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/requirements/typedefs.cc new file mode 100644 index 000000000..6c92fa809 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-05 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.7.1 Class seed_seq [rand.util.seedseq] + +#include <random> + +void +test01() +{ + typedef std::seed_seq test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/base_copy.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/base_copy.cc new file mode 100644 index 000000000..197f5f0de --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/base_copy.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + typedef std::linear_congruential_engine + <uint_fast32_t, 16807UL, 0UL, 2147483647UL> base_engine; + + base_engine b; + + std::shuffle_order_engine<base_engine, 256> e(b); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/base_move.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/base_move.cc new file mode 100644 index 000000000..c05bc1965 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/base_move.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + typedef std::linear_congruential_engine + <uint_fast32_t, 16807UL, 0UL, 2147483647UL> base_engine; + + std::shuffle_order_engine<base_engine, 256> + e(std::move(base_engine())); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/copy.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/copy.cc new file mode 100644 index 000000000..55e38e22f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/copy.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > e(1); + + const auto f(e); + auto g(f); + g = g; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/default.cc new file mode 100644 index 000000000..15a5c2d8f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/default.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > e; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed1.cc new file mode 100644 index 000000000..b39d45a39 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed1.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + unsigned long seed = 2; + + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > e(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed2.cc new file mode 100644 index 000000000..c979e32b8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed2.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + double seed = 2.0; + + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > e(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq.cc new file mode 100644 index 000000000..01ea91f1e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-12-07 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> + +void +test01() +{ + std::seed_seq seq; + + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > e(seq); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/equal.cc new file mode 100644 index 000000000..57763e851 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/equal.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > u, v; + + VERIFY( u == v ); + + u.discard(100); + v.discard(100); + + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/inequal.cc new file mode 100644 index 000000000..43fc99fbb --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/inequal.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.4.1 class template discard_block_engine [rand.adapt.disc] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > u, v; + + VERIFY( !(u != v) ); + + u.discard(100); + v.discard(100); + + VERIFY( !(u != v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/serialize.cc new file mode 100644 index 000000000..578e49593 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/operators/serialize.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::stringstream str; + std::shuffle_order_engine + < + std::linear_congruential_engine<uint_fast32_t,16807UL, 0UL, 2147483647UL>, + 256 + > u, v; + + u(); // advance + str << u; + + VERIFY( !(u == v) ); + + str >> v; + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constants.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constants.cc new file mode 100644 index 000000000..2a96488cd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constants.cc @@ -0,0 +1,39 @@ +// { dg-do link } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-09-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009, 2010 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 <random> + +void test01() +{ + std::knuth_b so; + + const void* p = &so.table_size; + p = &so.table_size; + p = p; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constexpr_data.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constexpr_data.cc new file mode 100644 index 000000000..dde00063e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constexpr_data.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::table_size; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + typedef std::shuffle_order_engine + < + std::linear_congruential_engine + < + uint_fast32_t,16807UL, 0UL, 2147483647UL + >, + 256 + > type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constexpr_functions.cc new file mode 100644 index 000000000..8829898ff --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/constexpr_functions.cc @@ -0,0 +1,62 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + typedef std::shuffle_order_engine + < + std::linear_congruential_engine + < + uint_fast32_t,16807UL, 0UL, 2147483647UL + >, + 256 + > type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/typedefs.cc new file mode 100644 index 000000000..e2ec4ce14 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/requirements/typedefs.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.3 class template shuffle_order_engine [rand.adapt.shuf] +// 26.4.2.3 Concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include <random> + +void +test01() +{ + typedef std::shuffle_order_engine + < + std::linear_congruential_engine + < + uint_fast32_t,16807UL, 0UL, 2147483647UL + >, + 256 + > test_type; + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/cons/default.cc new file mode 100644 index 000000000..a875523d9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.6 Class template student_t_distribution [rand.dist.norm.t] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::student_t_distribution<> u; + VERIFY( u.n() == 1.0 ); + typedef std::student_t_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/cons/parms.cc new file mode 100644 index 000000000..19ea7bacd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.6 Class template student_t_distribution [rand.dist.norm.t] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::student_t_distribution<> u(1.5); + VERIFY( u.n() == 1.5 ); + typedef std::student_t_distribution<>::result_type result_type; + VERIFY( u.min() == std::numeric_limits<result_type>::min() ); + VERIFY( u.max() == std::numeric_limits<result_type>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/equal.cc new file mode 100644 index 000000000..5117729b1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.6 Class template student_t_distribution [rand.dist.norm.t] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::student_t_distribution<double> u(1.5), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/inequal.cc new file mode 100644 index 000000000..edead19d6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.6 Class template student_t_distribution [rand.dist.norm.t] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::student_t_distribution<double> u(1.5), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/serialize.cc new file mode 100644 index 000000000..d4144702a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.4.6 Class template student_t_distribution [rand.dist.norm.t] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::student_t_distribution<double> u(1.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..e090b3542 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4.6 Class template student_t_distribution [rand.dist.norm.t] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::student_t_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/copy.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/copy.cc new file mode 100644 index 000000000..2639e87dd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/copy.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> e(1); + + const auto f(e); + auto g(f); + g = g; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/default.cc new file mode 100644 index 000000000..1297747a5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/default.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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 <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> x; + VERIFY( x.min() == 0 ); + VERIFY( x.max() == ((1UL << 24) - 1) ); + VERIFY( x() == 15039276 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed1.cc new file mode 100644 index 000000000..95db25f4d --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed1.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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.3.3 Class template subtract_with_carry_engine [rand.eng.sub] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> + +void +test01() +{ + unsigned long seed = 2; + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed2.cc new file mode 100644 index 000000000..73f9cbe0f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed2.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009, 2010 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.3.3 Class template subtract_with_carry_engine [rand.eng.sub] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> + +void +test01() +{ + double seed = 2.0; + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq.cc new file mode 100644 index 000000000..3fc9991d7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-02-01 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 <random> + +void +test01() +{ + std::seed_seq seed; + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> x(seed); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/equal.cc new file mode 100644 index 000000000..53fdbbefd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/equal.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.3 Class template subtract_with_carry_engine [rand.eng.sub] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> u; + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> v; + + VERIFY( u == v ); + + u.discard(100); + v.discard(100); + + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/inequal.cc new file mode 100644 index 000000000..aa7ec2420 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/inequal.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.3 Class template subtract_with_carry_engine [rand.eng.sub] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> u; + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> v; + + VERIFY( !(u != v) ); + + u.discard(100); + v.discard(100); + + VERIFY( !(u != v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/serialize.cc new file mode 100644 index 000000000..e4129fc8d --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/operators/serialize.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.3 Class template subtract_with_carry_engine [rand.eng.sub] +// 26.4.2.2 Concept RandomNumberEngine [rand.concept.eng] + +#include <sstream> +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::stringstream str; + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> u; + std::subtract_with_carry_engine<unsigned long, 24, 10, 24> v; + + u(); // advance + str << u; + + VERIFY( !(u == v) ); + + str >> v; + VERIFY( u == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constants.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constants.cc new file mode 100644 index 000000000..8c033cd26 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constants.cc @@ -0,0 +1,41 @@ +// { dg-do link } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-09-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009, 2010 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 <random> + +void test01() +{ + std::ranlux24_base swc; + + const void* p = &swc.word_size; + p = &swc.short_lag; + p = &swc.long_lag; + p = &swc.default_seed; + p = p; // Suppress unused warning. +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constexpr_data.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constexpr_data.cc new file mode 100644 index 000000000..c22dae0bb --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constexpr_data.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::word_size; + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::short_lag; + constexpr auto v3 __attribute__((unused)) + = _Ttesttype::long_lag; + constexpr auto v4 __attribute__((unused)) + = _Ttesttype::default_seed; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + typedef std::ranlux24_base type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constexpr_functions.cc new file mode 100644 index 000000000..39a3177ab --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/constexpr_functions.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 <random> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + typedef std::ranlux24_base type; + test.operator()<type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/typedefs.cc new file mode 100644 index 000000000..5e56a6e25 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.3.3 Class template subtract_with_carry_engine [rand.eng.sub] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::subtract_with_carry_engine<unsigned long, 24, 10, 24> + test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc new file mode 100644 index 000000000..dae94ccea --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1.1 Class template uniform_int_distribution [rand.dist.uni.int] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <limits> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_int_distribution<int> u; + VERIFY( u.a() == 0 ); + VERIFY( u.b() == std::numeric_limits<int>::max() ); + VERIFY( u.min() == 0 ); + VERIFY( u.max() == std::numeric_limits<int>::max() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/parms.cc new file mode 100644 index 000000000..70b40b0ad --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1.1 Class template uniform_int_distribution [rand.dist_uni] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_int_distribution<int> u(1, 20); + VERIFY( u.a() == 1 ); + VERIFY( u.b() == 20 ); + VERIFY( u.min() == 1 ); + VERIFY( u.max() == 20 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/equal.cc new file mode 100644 index 000000000..288cc0d66 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.1.1 Class template uniform_int_distribution [rand.dist_uni] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_int_distribution<int> u(1, 20), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/inequal.cc new file mode 100644 index 000000000..48875c36a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.1.1 Class template uniform_int_distribution [rand.dist_uni] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_int_distribution<int> u(1, 20), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/serialize.cc new file mode 100644 index 000000000..6ae080957 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.1.1 Class template uniform_int_distribution [rand.dist_uni] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::uniform_int_distribution<int> u(1, 20), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..3d584b525 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1.1 Class template uniform_int_distribution [rand.dist_uni] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::uniform_int_distribution<int> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/cons/default.cc new file mode 100644 index 000000000..8240736c7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/cons/default.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1.1 Class template uniform_real_distribution [rand.dist.uni.real] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_real_distribution<double> u; + VERIFY( u.a() == 0.0 ); + VERIFY( u.b() == 1.0 ); + VERIFY( u.min() == 0.0 ); + VERIFY( u.max() == 1.0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/cons/parms.cc new file mode 100644 index 000000000..ff1494b73 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/cons/parms.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1.1 Class template uniform_real_distribution [rand.dist_uni] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_real_distribution<double> u(-5.0, 5.0); + VERIFY( u.a() == -5.0 ); + VERIFY( u.b() == 5.0 ); + VERIFY( u.min() == -5.0 ); + VERIFY( u.max() == 5.0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/equal.cc new file mode 100644 index 000000000..df27f6cf4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.1.2 Class template uniform_real_distribution [rand.dist.uni.real] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_real_distribution<double> u(-5.0, 5.0), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/inequal.cc new file mode 100644 index 000000000..a93a4fde5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.1.2 Class template uniform_real_distribution [rand.dist.uni.real] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::uniform_real_distribution<double> u(-5.0, 5.0), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/serialize.cc new file mode 100644 index 000000000..a6ef0f490 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.1.2 Class template uniform_real_distribution [rand.dist.uni.real] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::uniform_real_distribution<double> u(-5.0, 5.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..c14182f72 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.1.2 Class template uniform_real_distribution [rand.dist.uni.real] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::uniform_real_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/cons/default.cc new file mode 100644 index 000000000..1377c20e3 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4 Class template weibull_distribution [rand.dist.pois.weibull] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::weibull_distribution<> u; + VERIFY( u.a() == 1.0 ); + VERIFY( u.b() == 1.0 ); + VERIFY( u.min() == 0.0 ); + typedef std::weibull_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/26_numerics/random/weibull_distribution/cons/parms.cc b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/cons/parms.cc new file mode 100644 index 000000000..91eca51e5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/cons/parms.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4 Class template weibull_distribution [rand.dist.pois.weibull] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::weibull_distribution<> u(2.0, 3.5); + VERIFY( u.a() == 2.0 ); + VERIFY( u.b() == 3.5 ); + VERIFY( u.min() == 0.0 ); + typedef std::weibull_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/26_numerics/random/weibull_distribution/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/equal.cc new file mode 100644 index 000000000..be4201a4f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/equal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.4 Class template weibull_distribution [rand.dist.pois.weibull] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::weibull_distribution<double> u(2.0, 3.5), v, w; + + VERIFY( v == w ); + VERIFY( !(u == v) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/inequal.cc b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/inequal.cc new file mode 100644 index 000000000..44dc1d3d1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/inequal.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2010-03-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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.3.4 Class template weibull_distribution [rand.dist.pois.weibull] + +#include <random> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::weibull_distribution<double> u(2.0, 3.5), v, w; + + VERIFY( u != v ); + VERIFY( !(v != w) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/serialize.cc new file mode 100644 index 000000000..786702364 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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.4 Class template weibull_distribution [rand.dist.pois.weibull] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> +#include <sstream> + +void +test01() +{ + std::stringstream str; + std::weibull_distribution<double> u(2.0, 3.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/requirements/typedefs.cc new file mode 100644 index 000000000..5c8d8e076 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2008, 2009 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.4 Class template weibull_distribution [rand.dist.pois.weibull] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include <random> + +void +test01() +{ + typedef std::weibull_distribution<double> test_type; + + typedef test_type::result_type result_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/slice/1.cc b/libstdc++-v3/testsuite/26_numerics/slice/1.cc new file mode 100644 index 000000000..1a911909c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/slice/1.cc @@ -0,0 +1,63 @@ +// 20020717 gdr + +// Copyright (C) 2002, 2003, 2009 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/>. + +// Test slice class invariants + +#include <valarray> +#include <cstdlib> +#include <testsuite_hooks.h> + +bool +construction(std::size_t start, std::size_t size, std::size_t stride) +{ + std::slice s(start, size, stride); + return s.start() == start && s.size() == size && s.stride() == stride; +} + +bool +copy(std::size_t start, std::size_t size, std::size_t stride) +{ + std::slice s(start, size, stride); + std::slice t = s; + return t.start() == start && t.size() == size && t.stride() == stride; +} + +bool +assignment(std::size_t start, std::size_t size, std::size_t stride) +{ + std::slice s(start, size, stride); + std::slice t; + t = s; + return t.start() == start && t.size() == size && t.stride() == stride; +} + + +int main() +{ + bool test __attribute__((unused)) = true; + std::srand(20020717); + using std::rand; + VERIFY(construction(rand(), rand(), rand())); + + VERIFY(copy(rand(), rand(), rand())); + + VERIFY(assignment(rand(), rand(), rand())); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/slice_array/array_assignment.cc b/libstdc++-v3/testsuite/26_numerics/slice_array/array_assignment.cc new file mode 100644 index 000000000..0357e5de7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/slice_array/array_assignment.cc @@ -0,0 +1,40 @@ +// 20010613 gdr + +// Copyright (C) 2001, 2002, 2003, 2009, 2010 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/>. + +// This is DR-253. Test for accessible assignment-operators. +#include <valarray> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + using std::valarray; + using std::slice; + valarray<int> v(1, 10), w(2, 10); + + w[slice(0, 3, 3)] = v[slice(2, 3, 3)]; + + VERIFY(v[0] == 1 && w[0] == 1); + VERIFY(v[3] == 1 && w[3] == 1); + VERIFY(v[6] == 1 && w[6] == 1); + + std::slice_array<int> t __attribute__((unused)) = v[slice(0, 10, 1)]; + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/slice_array/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/26_numerics/slice_array/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..2e85f2ab1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/slice_array/requirements/explicit_instantiation.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <valarray> + +template class std::slice_array<short>; diff --git a/libstdc++-v3/testsuite/26_numerics/slice_array/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/slice_array/requirements/typedefs.cc new file mode 100644 index 000000000..154fa01e6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/slice_array/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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/>. + + +// 6.2.2 Class template array + +#include <valarray> + +void test01() +{ + // Check for required typedefs + typedef std::slice_array<int> test_type; + typedef test_type::value_type value_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/27867.cc b/libstdc++-v3/testsuite/26_numerics/valarray/27867.cc new file mode 100644 index 000000000..4100aa7c4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/27867.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2006, 2009 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 <valarray> +#include <testsuite_hooks.h> + +// libstdc++/27867 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::valarray<int> v1(100, 1); + std::valarray<int> v2(100, 1); + std::valarray<bool> v3(true, 1); + + std::valarray<bool> resl(1); + resl = ((v1 == v2) == v3); + VERIFY( resl[0] == true ); + + std::valarray<bool> resr(1); + resr = (v3 == (v1 == v2)); + VERIFY( resr[0] == true ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/28277.cc b/libstdc++-v3/testsuite/26_numerics/valarray/28277.cc new file mode 100644 index 000000000..7e619c020 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/28277.cc @@ -0,0 +1,43 @@ +// 2006-07-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006, 2009 Free Software Foundation +// +// 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 <valarray> +#include <testsuite_hooks.h> + +// libstdc++/28277 +void test01() +{ + bool test __attribute__((unused)) = true; + + const std::valarray<int> v1(1, 5000000); + + const std::valarray<int> v2 = v1.shift(1); + VERIFY( v2.size() == v1.size() ); + VERIFY( v2[v1.size() - 1] == 0 ); + + const std::valarray<int> v3 = v2.cshift(-1); + VERIFY( v3.size() == v2.size() ); + VERIFY( v3[0] == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/30416.cc b/libstdc++-v3/testsuite/26_numerics/valarray/30416.cc new file mode 100644 index 000000000..4ce8f75ed --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/30416.cc @@ -0,0 +1,181 @@ +// 2007-01-11 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007, 2009 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 <valarray> +#include <testsuite_hooks.h> + +bool +comp_vala(const std::valarray<int>& v1, const std::valarray<int>& v2) +{ + if (v1.size() == v2.size()) + { + for (size_t i = 0; i < v1.size(); ++i) + if (v1[i] != v2[i]) + return false; + return true; + } + return false; +} + +void +init_vala(std::valarray<int>& v, size_t first, size_t last, int val) +{ + for (size_t i = first; i <= last; ++i) + v[i] = val++; +} + +// libstdc++/30416 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // shift + valarray<int> v1; + valarray<int> v1_ris(v1.shift(0)); + VERIFY( comp_vala(v1, v1_ris) ); + + valarray<int> v2; + valarray<int> v2_ris(v2.shift(10)); + VERIFY( comp_vala(v2, v2_ris) ); + + valarray<int> v3; + valarray<int> v3_ris(v3.shift(-10)); + VERIFY( comp_vala(v3, v3_ris) ); + + valarray<int> v4(10); + valarray<int> v4_ris(v4.shift(0)); + VERIFY( comp_vala(v4, v4_ris) ); + + valarray<int> v5(10); + init_vala(v5, 0, 9, 1); + valarray<int> v5_ref(10); + + valarray<int> v5_ris(v5.shift(16)); + VERIFY( comp_vala(v5_ris, v5_ref) ); + + valarray<int> v6(10); + init_vala(v6, 0, 9, 1); + valarray<int> v6_ref(10); + + valarray<int> v6_ris(v6.shift(-16)); + VERIFY( comp_vala(v6_ris, v6_ref) ); + + valarray<int> v7(10); + init_vala(v7, 0, 9, 1); + valarray<int> v7_ref(10); + + valarray<int> v7_ris(v7.shift(10)); + VERIFY( comp_vala(v7_ris, v7_ref) ); + + valarray<int> v8(10); + init_vala(v8, 0, 9, 1); + valarray<int> v8_ref(10); + + valarray<int> v8_ris(v8.shift(-10)); + VERIFY( comp_vala(v8_ris, v8_ref) ); + + valarray<int> v9(10); + init_vala(v9, 0, 9, 1); + valarray<int> v9_ref(10); + init_vala(v9_ref, 0, 3, 7); + + valarray<int> v9_ris(v9.shift(6)); + VERIFY( comp_vala(v9_ris, v9_ref) ); + + valarray<int> v10(10); + init_vala(v10, 0, 9, 1); + valarray<int> v10_ref(10); + init_vala(v10_ref, 6, 9, 1); + + valarray<int> v10_ris(v10.shift(-6)); + VERIFY( comp_vala(v10_ris, v10_ref) ); + + // cshift + valarray<int> v11; + valarray<int> v11_ris(v11.cshift(0)); + VERIFY( comp_vala(v11, v11_ris) ); + + valarray<int> v12; + valarray<int> v12_ris(v12.cshift(10)); + VERIFY( comp_vala(v12, v12_ris) ); + + valarray<int> v13; + valarray<int> v13_ris(v13.cshift(-10)); + VERIFY( comp_vala(v13, v13_ris) ); + + valarray<int> v14(10); + valarray<int> v14_ris(v14.cshift(0)); + VERIFY( comp_vala(v14, v14_ris) ); + + valarray<int> v15(10); + init_vala(v15, 0, 9, 1); + valarray<int> v15_ref(10); + init_vala(v15_ref, 0, 3, 7); + init_vala(v15_ref, 4, 9, 1); + + valarray<int> v15_ris(v15.cshift(16)); + VERIFY( comp_vala(v15_ris, v15_ref) ); + + valarray<int> v16(10); + init_vala(v16, 0, 9, 1); + valarray<int> v16_ref(10); + init_vala(v16_ref, 0, 5, 5); + init_vala(v16_ref, 6, 9, 1); + + valarray<int> v16_ris(v16.cshift(-16)); + VERIFY( comp_vala(v16_ris, v16_ref) ); + + valarray<int> v17(10); + init_vala(v17, 0, 9, 1); + + valarray<int> v17_ris(v15.cshift(10)); + VERIFY( comp_vala(v17, v17_ris) ); + + valarray<int> v18(10); + init_vala(v18, 0, 9, 1); + + valarray<int> v18_ris(v18.cshift(-10)); + VERIFY( comp_vala(v18, v18_ris) ); + + valarray<int> v19(10); + init_vala(v19, 0, 9, 1); + valarray<int> v19_ref(10); + init_vala(v19_ref, 0, 3, 7); + init_vala(v19_ref, 4, 9, 1); + + valarray<int> v19_ris(v15.cshift(6)); + VERIFY( comp_vala(v19_ris, v19_ref) ); + + valarray<int> v20(10); + init_vala(v20, 0, 9, 1); + valarray<int> v20_ref(10); + init_vala(v20_ref, 0, 5, 5); + init_vala(v20_ref, 6, 9, 1); + + valarray<int> v20_ris(v20.cshift(-6)); + VERIFY( comp_vala(v20_ris, v20_ref) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/33084.cc b/libstdc++-v3/testsuite/26_numerics/valarray/33084.cc new file mode 100644 index 000000000..918414197 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/33084.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2007, 2009 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/>. + + +// { dg-do compile } + +#include <valarray> + +// libstdc++/33084 +void test01() +{ + std::valarray<char> vc(char(0), 10); + std::valarray<bool> res(10); + char c(0); + + res = vc == vc; + res = vc == c; + res = c == vc; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/40691.cc b/libstdc++-v3/testsuite/26_numerics/valarray/40691.cc new file mode 100644 index 000000000..5524835a6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/40691.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2009 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/>. + +// { dg-do compile } + +#include <valarray> + +// PR libstdc++/40691 +void test01() +{ + const std::valarray<int> vi(12); + std::valarray<bool> vb1(12); + std::valarray<bool> vb2(3); + std::slice s(0,3,4); + + vb1 = !vi; + vb2 = !(std::valarray<int>)vi[s]; + vb2 = !vi[s]; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/algo.cc b/libstdc++-v3/testsuite/26_numerics/valarray/algo.cc new file mode 100644 index 000000000..c12497611 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/algo.cc @@ -0,0 +1,31 @@ +// 19990404 gdr + +// Copyright (C) 1999, 2000, 2009 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 <valarray> + +int main() +{ + // 02: algo + using std::valarray; + valarray<double> b, c; + double m __attribute__((unused)) = std::abs(b - c).max(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc b/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc new file mode 100644 index 000000000..7dbcfbd52 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc @@ -0,0 +1,37 @@ +// 19990805 gdr +// +// XXX: to impove later. +// Origin: Andreas Amann <amann@physik.tu-berlin.de> +// CXXFLAGS: -g + +#include <iostream> +#include <valarray> + + +int main() +{ + std::valarray<double> a(10), b(10), c(10), d(10); + + a = 1.2; + b = 3.1; + + c = 4.0; + + d = ( 2.0 * b + a ); // works + std::cout << "d[4] = " << d[4] << std::endl; + + d = (a * 2.0 + b ); // works + std::cout << "d[4] = " << d[4] << std::endl; + + d = (a + b * 2.0 ); // segfaults! + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + + std::cout << "d[4] = " << d[4] << std::endl; + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/const_bracket.cc b/libstdc++-v3/testsuite/26_numerics/valarray/const_bracket.cc new file mode 100644 index 000000000..abd9cd873 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/const_bracket.cc @@ -0,0 +1,39 @@ +// 20010518 gdr + +// Copyright (C) 2001, 2009 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 <valarray> + +// dg-do compile + +template<typename P> + void copy(P, std::size_t) { } + +template<typename T> + void test(const std::valarray<T>& v) + { + copy(&v[0], v.size()); + } + +int main() +{ + std::valarray<double> v(190); + test(v); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc b/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc new file mode 100644 index 000000000..e474ef998 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2006, 2009 Free Software Foundation +// +// 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 <valarray> +#include <testsuite_hooks.h> + +// DR 543. valarray slice default constructor +void test01() +{ + bool test __attribute__((unused)) = true; + + std::valarray<int> v1(10); + std::valarray<int> v2 = v1[std::slice()]; + VERIFY( v2.size() == 0 ); + + std::valarray<int> v3(10); + std::valarray<int> v4 = v3[std::gslice()]; + VERIFY( v4.size() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/dr630-1.cc b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-1.cc new file mode 100644 index 000000000..9e5d14a28 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-1.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2009 Free Software Foundation +// +// 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 <valarray> +#include <testsuite_hooks.h> + +// DR 630. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + valarray<int> v1; + const valarray<int> v2(-1, 10000); + + v1 = v2; + VERIFY( v1.size() == v2.size() ); + VERIFY( (v1 == v2).min() == true ); + + valarray<int> v3(0, 10000); + const valarray<int> v4; + + v3 = v4; + VERIFY( v3.size() == v4.size() ); + VERIFY( v3.size() == 0 ); + + valarray<int> v5(0, 100); + const valarray<int> v6(-1, 10000); + + v5 = v6; + VERIFY( v5.size() == v6.size() ); + VERIFY( (v5 == v6).min() == true ); + + valarray<int> v7(0, 10000); + const valarray<int> v8(-1, 100); + + v7 = v8; + VERIFY( v7.size() == v8.size() ); + VERIFY( (v7 == v8).min() == true ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/dr630-2.cc b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-2.cc new file mode 100644 index 000000000..ddb6bcaff --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-2.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation +// +// 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 <valarray> +#include <testsuite_hooks.h> + +// DR 630. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + valarray<int> v1; + + v1 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + VERIFY( v1.size() == 10 ); + VERIFY( v1.min() == -1 ); + VERIFY( v1.max() == -1 ); + + valarray<int> v2(0, 10); + + v2 = { }; + VERIFY( v2.size() == 0 ); + + valarray<int> v3(0, 10); + + v3 = { -1, -1, -1, -1, -1 }; + VERIFY( v3.size() == 5 ); + VERIFY( v3.min() == -1 ); + VERIFY( v3.max() == -1 ); + + valarray<int> v4(0, 5); + + v4 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + VERIFY( v4.size() == 10 ); + VERIFY( v4.min() == -1 ); + VERIFY( v4.max() == -1 ); + + valarray<int> v5(0, 10); + + v5 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + VERIFY( v5.size() == 10 ); + VERIFY( v5.min() == -1 ); + VERIFY( v5.max() == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc b/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc new file mode 100644 index 000000000..1c0665901 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2008, 2009 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/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <valarray> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + valarray<int> m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m[0] == 1); + VERIFY(m[1] == 5); + VERIFY(m[2] == 37); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m[0] == 28); + VERIFY(m[1] == 37); + VERIFY(m[2] == 102); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/name_lookup.cc b/libstdc++-v3/testsuite/26_numerics/valarray/name_lookup.cc new file mode 100644 index 000000000..65d679a21 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/name_lookup.cc @@ -0,0 +1,133 @@ +// 2002-08-02 gdr + +// Copyright (C) 2002, 2003, 2009 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/>. + + +// Test name lookup resolutions for standard functions applied to an +// array expression. +// { dg-do compile } + +#include <valarray> + +namespace My +{ + struct Number + { + operator bool() const; + }; + + Number operator+(Number); + Number operator-(Number); + Number operator~(Number); + + bool operator!(Number); + + Number operator+(Number, Number); + Number operator-(Number, Number); + Number operator*(Number, Number); + Number operator/(Number, Number); + Number operator%(Number, Number); + + Number operator^(Number, Number); + Number operator&(Number, Number); + Number operator|(Number, Number); + + Number operator<<(Number, Number); + Number operator>>(Number, Number); + + bool operator==(Number, Number); + bool operator!=(Number, Number); + bool operator<(Number, Number); + bool operator<=(Number, Number); + bool operator>(Number, Number); + bool operator>=(Number, Number); + + Number abs(Number); + + Number cos(Number); + Number cosh(Number); + Number acos(Number); + + Number sin(Number); + Number sinh(Number); + Number asin(Number); + + Number tan(Number); + Number tanh(Number); + Number atan(Number); + + Number exp(Number); + Number log(Number); + Number log10(Number); + Number sqrt(Number); + + Number atan2(Number, Number); + Number pow(Number, Number); +} + +int main() +{ + typedef std::valarray<My::Number> Array; + Array u(10), v(10); + v = +u; + v = -u; + v = ~u; + std::valarray<bool> z = !u; + + v = abs(u); + + v = cos(u); + v = cosh(u); + v = acos(u); + + v = sin(u); + v = sinh(u); + v = asin(u); + + v = tan(u); + v = tanh(u); + v = atan(u); + + v = exp(u); + v = log(u); + v = log10(u); + v = sqrt(u); + + Array w = u + v; + w = u - v; + w = u * v; + w = u / v; + w = u % v; + + w = u ^ v; + w = u & v; + w = u | v; + + w = u << v; + w = u >> v; + + z = u == v; + z = u != v; + z = u < v; + z = u <= v; + z = u > v; + z = u >= v; + + w = atan2(u, v); + w = pow(u, v); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/operators.cc b/libstdc++-v3/testsuite/26_numerics/valarray/operators.cc new file mode 100644 index 000000000..82904334a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/operators.cc @@ -0,0 +1,68 @@ +// { dg-do run } +// 2003-02-03 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + +// Copyright (C) 2003, 2009 Free Software Foundation +// +// 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 <valarray> +#include <testsuite_hooks.h> + +void test01() // check unary operators +{ + bool test __attribute__((unused)) = true; + std::valarray<int> u(1); + u[0]=1; + + VERIFY( (+u)[0] == +1 ); + VERIFY( (-u)[0] == -1 ); + VERIFY( (!u)[0] == !1 ); + VERIFY( (~u)[0] == ~1 ); +} + +void test02() // check binary operators +{ + bool test __attribute__((unused)) = true; + std::valarray<int> u(1), v(1); + u[0]=1; + v[0]=3; + + VERIFY( (u+ v)[0] == (1+ 3) ); + VERIFY( (u- v)[0] == (1- 3) ); + VERIFY( (u* v)[0] == (1* 3) ); + VERIFY( (u/ v)[0] == (1/ 3) ); + VERIFY( (u% v)[0] == (1% 3) ); + VERIFY( (u^ v)[0] == (1^ 3) ); + VERIFY( (u& v)[0] == (1& 3) ); + VERIFY( (u| v)[0] == (1| 3) ); + VERIFY( (u<<v)[0] == (1<<3) ); + VERIFY( (u>>v)[0] == (1>>3) ); + VERIFY( (u&&v)[0] == (1&&3) ); + VERIFY( (u||v)[0] == (1||3) ); + VERIFY( (u==v)[0] == (1==3) ); + VERIFY( (u!=v)[0] == (1!=3) ); + VERIFY( (u< v)[0] == (1< 3) ); + VERIFY( (u> v)[0] == (1> 3) ); + VERIFY( (u<=v)[0] == (1<=3) ); + VERIFY( (u>=v)[0] == (1>=3) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc new file mode 100644 index 000000000..10f67dac8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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.6.10 valarray range access: [valarray.range] + +#include <valarray> + +void +test01() +{ + std::valarray<double> va{1.0, 2.0, 3.0}; + std::begin(va); + std::end(va); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d63ea7c75 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/explicit_instantiation.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <valarray> + +template class std::valarray<short>; diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/typedefs.cc new file mode 100644 index 000000000..6501d0738 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 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/>. + + +// 6.2.2 Class template array + +#include <valarray> + +void test01() +{ + // Check for required typedefs + typedef std::valarray<int> test_type; + typedef test_type::value_type value_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/subset_assignment.cc b/libstdc++-v3/testsuite/26_numerics/valarray/subset_assignment.cc new file mode 100644 index 000000000..00ec70b60 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/subset_assignment.cc @@ -0,0 +1,78 @@ +// 2004-01-03 Jerry Quinn <jlquinn@optonline.net> + +// Copyright (C) 2004, 2009 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/>. + + +// PR 3247 + +// This is DR-253. Test for accessible assignment-operators. +#include <valarray> +#include <testsuite_hooks.h> + +bool check_array(std::valarray<double>& a, double b[]) +{ + for (unsigned int i=0; i < a.size(); i++) + if (a[i] != b[i]) return false; + return true; +} + +int main() +{ + std::valarray<double> val_d(10); // 0 1 2 3 4 5 6 7 8 9 + std::valarray<double> val_d1(10); // 10 9 8 7 6 5 4 3 2 1 + + for (int i=0; i< 10; i++) { val_d[i] = 10; val_d1[i] = i; } + std::valarray<double> val_c(val_d); + std::valarray<double> val_f(val_d); + std::valarray<double> val_g(val_d); + + std::slice slc(1, 3, 3); // 1 4 7 + val_d[slc] = val_d1[slc]; + + double ans1[10] = {10, 1, 10, 10, 4, 10, 10, 7, 10, 10}; + VERIFY(check_array(val_d, ans1)); + + std::valarray<std::size_t> val_size(2); + std::valarray<std::size_t> val_stride(2); + val_size[0] = 2; val_size[1] = 3; + val_stride[0] = 4; val_stride[1] = 1; + + std::gslice gslc(1, val_size, val_stride); + val_c[gslc] = val_d1[gslc]; + + double ans2[10] = {10, 1, 2, 3, 10, 5, 6, 7, 10, 10}; + VERIFY(check_array(val_c, ans2)); + + std::valarray<bool> val_b(false, 10); + val_b[2] = val_b[6] = val_b[9] = true; + val_f[val_b] = val_d1[val_b]; + + double ans3[10] = {10, 10, 2, 10, 10, 10, 6, 10, 10, 9}; + VERIFY(check_array(val_f, ans3)); + + size_t addr[] = {1, 2, 3, 4, 5}; + size_t addr1[] = {2, 7, 1, 9, 4}; + std::valarray<std::size_t> val_indirect(addr, 5); + std::valarray<std::size_t> val_indirect1(addr1, 5); + val_g[val_indirect] = val_d1[val_indirect1]; + + double ans4[10] = {10, 2, 7, 1, 9, 4, 10, 10, 10, 10}; + VERIFY(check_array(val_g, ans4)); + + return 0; +}; |