From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/26_numerics/valarray/30416.cc | 181 +++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/30416.cc (limited to 'libstdc++-v3/testsuite/26_numerics/valarray/30416.cc') 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 + +// 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 +// . + + +#include +#include + +bool +comp_vala(const std::valarray& v1, const std::valarray& 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& 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 v1; + valarray v1_ris(v1.shift(0)); + VERIFY( comp_vala(v1, v1_ris) ); + + valarray v2; + valarray v2_ris(v2.shift(10)); + VERIFY( comp_vala(v2, v2_ris) ); + + valarray v3; + valarray v3_ris(v3.shift(-10)); + VERIFY( comp_vala(v3, v3_ris) ); + + valarray v4(10); + valarray v4_ris(v4.shift(0)); + VERIFY( comp_vala(v4, v4_ris) ); + + valarray v5(10); + init_vala(v5, 0, 9, 1); + valarray v5_ref(10); + + valarray v5_ris(v5.shift(16)); + VERIFY( comp_vala(v5_ris, v5_ref) ); + + valarray v6(10); + init_vala(v6, 0, 9, 1); + valarray v6_ref(10); + + valarray v6_ris(v6.shift(-16)); + VERIFY( comp_vala(v6_ris, v6_ref) ); + + valarray v7(10); + init_vala(v7, 0, 9, 1); + valarray v7_ref(10); + + valarray v7_ris(v7.shift(10)); + VERIFY( comp_vala(v7_ris, v7_ref) ); + + valarray v8(10); + init_vala(v8, 0, 9, 1); + valarray v8_ref(10); + + valarray v8_ris(v8.shift(-10)); + VERIFY( comp_vala(v8_ris, v8_ref) ); + + valarray v9(10); + init_vala(v9, 0, 9, 1); + valarray v9_ref(10); + init_vala(v9_ref, 0, 3, 7); + + valarray v9_ris(v9.shift(6)); + VERIFY( comp_vala(v9_ris, v9_ref) ); + + valarray v10(10); + init_vala(v10, 0, 9, 1); + valarray v10_ref(10); + init_vala(v10_ref, 6, 9, 1); + + valarray v10_ris(v10.shift(-6)); + VERIFY( comp_vala(v10_ris, v10_ref) ); + + // cshift + valarray v11; + valarray v11_ris(v11.cshift(0)); + VERIFY( comp_vala(v11, v11_ris) ); + + valarray v12; + valarray v12_ris(v12.cshift(10)); + VERIFY( comp_vala(v12, v12_ris) ); + + valarray v13; + valarray v13_ris(v13.cshift(-10)); + VERIFY( comp_vala(v13, v13_ris) ); + + valarray v14(10); + valarray v14_ris(v14.cshift(0)); + VERIFY( comp_vala(v14, v14_ris) ); + + valarray v15(10); + init_vala(v15, 0, 9, 1); + valarray v15_ref(10); + init_vala(v15_ref, 0, 3, 7); + init_vala(v15_ref, 4, 9, 1); + + valarray v15_ris(v15.cshift(16)); + VERIFY( comp_vala(v15_ris, v15_ref) ); + + valarray v16(10); + init_vala(v16, 0, 9, 1); + valarray v16_ref(10); + init_vala(v16_ref, 0, 5, 5); + init_vala(v16_ref, 6, 9, 1); + + valarray v16_ris(v16.cshift(-16)); + VERIFY( comp_vala(v16_ris, v16_ref) ); + + valarray v17(10); + init_vala(v17, 0, 9, 1); + + valarray v17_ris(v15.cshift(10)); + VERIFY( comp_vala(v17, v17_ris) ); + + valarray v18(10); + init_vala(v18, 0, 9, 1); + + valarray v18_ris(v18.cshift(-10)); + VERIFY( comp_vala(v18, v18_ris) ); + + valarray v19(10); + init_vala(v19, 0, 9, 1); + valarray v19_ref(10); + init_vala(v19_ref, 0, 3, 7); + init_vala(v19_ref, 4, 9, 1); + + valarray v19_ris(v15.cshift(6)); + VERIFY( comp_vala(v19_ris, v19_ref) ); + + valarray v20(10); + init_vala(v20, 0, 9, 1); + valarray v20_ref(10); + init_vala(v20_ref, 0, 5, 5); + init_vala(v20_ref, 6, 9, 1); + + valarray v20_ris(v20.cshift(-6)); + VERIFY( comp_vala(v20_ris, v20_ref) ); +} + +int main() +{ + test01(); + return 0; +} -- cgit v1.2.3