diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/tr1/6_containers/array | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'libstdc++-v3/testsuite/tr1/6_containers/array')
25 files changed, 1189 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/empty.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/empty.cc new file mode 100644 index 000000000..24a561916 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/empty.cc @@ -0,0 +1,53 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + { + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + + VERIFY( a.empty() == false ); + } + + { + const size_t len = 0; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a; + + VERIFY( a.empty() == true ); + } +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/max_size.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/max_size.cc new file mode 100644 index 000000000..d5321192c --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/max_size.cc @@ -0,0 +1,52 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + { + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + + VERIFY( a.max_size() == len ); + } + + { + const size_t len = 0; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a; + + VERIFY( a.max_size() == len ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/size.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/size.cc new file mode 100644 index 000000000..3c7d29278 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/size.cc @@ -0,0 +1,53 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + { + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + + VERIFY( a.size() == len ); + } + + { + const size_t len = 0; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a; + + VERIFY( a.size() == len ); + } +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/equal.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/equal.cc new file mode 100644 index 000000000..7e9ac4acd --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/equal.cc @@ -0,0 +1,45 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3 } }; + + VERIFY( a == b ); + VERIFY( !(a == c) ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater.cc new file mode 100644 index 000000000..bbe02d6ad --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater.cc @@ -0,0 +1,45 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( !(a > b) ); + VERIFY( c > a ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc new file mode 100644 index 000000000..0f5fb250a --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc @@ -0,0 +1,45 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( a >= b ); + VERIFY( c >= a ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less.cc new file mode 100644 index 000000000..8db6ec6ad --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less.cc @@ -0,0 +1,45 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( !(a < b) ); + VERIFY( a < c ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc new file mode 100644 index 000000000..8ff18b300 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc @@ -0,0 +1,45 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3, 7 } }; + + VERIFY( a <= b ); + VERIFY( a <= c ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc new file mode 100644 index 000000000..957c05ebc --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc @@ -0,0 +1,45 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3, 4 } }; + array_type c = { { 0, 1, 2, 3 } }; + + VERIFY( !(a != b) ); + VERIFY( a != c ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc new file mode 100644 index 000000000..78085f940 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc @@ -0,0 +1,43 @@ +// { dg-do compile } + +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> + +void +test01() +{ + typedef std::tr1::array<int, 5> array_type; + + array_type a = { { 0, 1, 2, 3, 4 } }; + array_type b = { { 0, 1, 2, 3 } }; + + a = b; +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc new file mode 100644 index 000000000..4a53a6d99 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc @@ -0,0 +1,56 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + + try + { + a.at(len); + VERIFY( false ); + } + catch(std::out_of_range& obj) + { + // Expected. + VERIFY( true ); + } + catch(...) + { + // Failed. + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/back.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/back.cc new file mode 100644 index 000000000..3c0ea2490 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/back.cc @@ -0,0 +1,50 @@ +// 2005-08-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + + { + array_type a = { { 0, 1, 2, 3, 4 } }; + int& ri = a.back(); + VERIFY( ri == 4 ); + } + + { + const array_type ca = { { 4, 3, 2, 1, 0 } }; + const int& cri = ca.back(); + VERIFY( cri == 0 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/data.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/data.cc new file mode 100644 index 000000000..80f27e7fc --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/data.cc @@ -0,0 +1,50 @@ +// 2005-08-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + + { + array_type a = { { 0, 1, 2, 3, 4 } }; + int* pi = a.data(); + VERIFY( *pi == 0 ); + } + + { + const array_type ca = { { 4, 3, 2, 1, 0 } }; + const int* pci = ca.data(); + VERIFY( *pci == 4 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/front.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/front.cc new file mode 100644 index 000000000..e7eb139ed --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/front.cc @@ -0,0 +1,50 @@ +// 2005-08-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + + { + array_type a = { { 0, 1, 2, 3, 4 } }; + int& ri = a.front(); + VERIFY( ri == 0 ); + } + + { + const array_type ca = { { 4, 3, 2, 1, 0 } }; + const int& cri = ca.front(); + VERIFY( cri == 4 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc new file mode 100644 index 000000000..92ff761db --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc @@ -0,0 +1,46 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + + array_type::iterator b = a.begin(); + array_type::iterator e = a.end(); + + VERIFY( e != (b + a.size() - 1)); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc new file mode 100644 index 000000000..5925cc796 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc @@ -0,0 +1,46 @@ +// 2006-02-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 3; + typedef std::tr1::array<int, len> array_type; + + array_type a = { { 0, 1, 2 } }; + const int value = 5; + + a.assign(value); + VERIFY( a[0] == value ); + VERIFY( a[1] == value ); + VERIFY( a[2] == value ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/contiguous.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/contiguous.cc new file mode 100644 index 000000000..e22b96cbe --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/contiguous.cc @@ -0,0 +1,46 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + array_type a = { { 0, 1, 2, 3, 4 } }; + + // &a[n] == &a[0] + n for all 0 <= n < N. + for (size_t i = 0; i < len; ++i) + { + VERIFY( &a[i] == &a[0] + i ); + } +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..0074de7cb --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/explicit_instantiation.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// 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/>. + + +// 6.2.2 Class template array + +#include <tr1/array> + +template class std::tr1::array<int, 5>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc new file mode 100644 index 000000000..ea663bf71 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc @@ -0,0 +1,48 @@ +// 2006-02-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + + array_type a = { { 0, 1, 2, 3, 4 } }; + const array_type a_ref = a; + + array_type b = { { 4, 3, 2, 1, 0 } }; + const array_type b_ref = b; + + a.swap(b); + VERIFY( a == b_ref ); + VERIFY( b == a_ref ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/typedefs.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/typedefs.cc new file mode 100644 index 000000000..9f616ee75 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/typedefs.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// 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/>. + + +// 6.2.2 Class template array + +#include <tr1/array> + +void test01() +{ + // Check for required typedefs + typedef std::tr1::array<int, 5> test_type; + typedef test_type::reference reference; + typedef test_type::const_reference const_reference; + typedef test_type::iterator iterator; + typedef test_type::const_iterator const_iterator; + typedef test_type::size_type size_type; + typedef test_type::difference_type difference_type; + typedef test_type::value_type value_type; + typedef test_type::reverse_iterator reverse_iterator; + typedef test_type::const_reverse_iterator const_reverse_iterator; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc new file mode 100644 index 000000000..1ea4f8aee --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc @@ -0,0 +1,61 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2004, 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/>. + +// 6.2.2.4 Zero sized arrays + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + const size_t len = 0; + typedef std::tr1::array<int, len> array_type; + bool test __attribute__((unused)) = true; + + // 1: ? + array_type a = { }; + + // 2 + array_type b; + + // 3 + // begin() == end() + VERIFY( a.begin() == a.end() ); + VERIFY( b.begin() == b.end() ); + + // 4: ? + // begin() == end() == unique value. + { + typedef std::tr1::array<long, len> array_type1; + typedef std::tr1::array<char, len> array_type2; + array_type1 one; + array_type2 two; + void* v1 = one.begin(); + void* v2 = two.begin(); + VERIFY( v1 != v2 ); + } +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc new file mode 100644 index 000000000..1f0ae9d7f --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc @@ -0,0 +1,48 @@ +// 2006-02-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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/>. + +// 6.2.2.2 array specialized algorithms + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 5; + typedef std::tr1::array<int, len> array_type; + + array_type a = { { 0, 1, 2, 3, 4 } }; + const array_type a_ref = a; + + array_type b = { { 4, 3, 2, 1, 0 } }; + const array_type b_ref = b; + + std::tr1::swap(a, b); + VERIFY( a == b_ref ); + VERIFY( b == a_ref ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/get.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/get.cc new file mode 100644 index 000000000..de0531da2 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/get.cc @@ -0,0 +1,51 @@ +// 2005-08-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::tr1; + + const size_t len = 5; + typedef array<int, len> array_type; + + { + array_type a = { { 0, 1, 2, 3, 4 } }; + int& ri = get<0>(a); + VERIFY( ri == 0 ); + } + + { + const array_type a = { { 4, 3, 2, 1, 0 } }; + const int& cri = get<1>(a); + VERIFY( cri == 3 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/tuple_element.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/tuple_element.cc new file mode 100644 index 000000000..09de57dc5 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/tuple_element.cc @@ -0,0 +1,51 @@ +// 2005-08-26 Paolo Carlini <pcarlini@suse.de> +// +// 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <tr1/type_traits> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::tr1; + + { + const size_t len = 3; + typedef array<int, len> array_type; + VERIFY( (is_same<tuple_element<0, array_type>::type, int>::value == true) ); + VERIFY( (is_same<tuple_element<1, array_type>::type, int>::value == true) ); + VERIFY( (is_same<tuple_element<2, array_type>::type, int>::value == true) ); + } + + { + const size_t len = 0; + typedef array<int, len> array_type; + VERIFY( (is_same<tuple_element<0, array_type>::type, int>::value == true) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/tuple_size.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/tuple_size.cc new file mode 100644 index 000000000..99fcc7de0 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/tuple_interface/tuple_size.cc @@ -0,0 +1,48 @@ +// 2005-08-26 Paolo Carlini <pcarlini@suse.de> +// +// 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/>. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::tr1; + + { + const size_t len = 5; + typedef array<int, len> array_type; + VERIFY( tuple_size<array_type>::value == 5 ); + } + + { + const size_t len = 0; + typedef array<float, len> array_type; + VERIFY( tuple_size<array_type>::value == 0 ); + } +} + +int main() +{ + test01(); + return 0; +} |