diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-22 05:32:16 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-22 05:32:16 +0000 |
commit | fd8431c84811e14566423cbc55645074300ec2fa (patch) | |
tree | 1c19eaec8b161244a85ea6ebe24ea14c66a07346 /libstdc++-v3/testsuite | |
parent | dfaec4a91ea4562335a383795530f62a31b9d629 (diff) | |
download | gcc-fd8431c84811e14566423cbc55645074300ec2fa.tar.gz |
2004-10-21 Benjamin Kosnik <bkoz@redhat.com>
* include/tr1/array (array): Make safe for zero-sized arrays.
(array::end): Return one past the end.
(array::at): Use __throw_out_of_range, include functexcept.h.
(operator==): Implement.
(operator!=): Same.
(operator<): Same.
(operator>): Same.
(operator>=): Same.
(operator<=): Same.
* testsuite/tr1/6_containers/array/capacity/(empty.cc,
max_size.cc, size.cc): New.
* testsuite/tr1/6_containers/array/comparison_operators/(equal.cc,
greater.cc, greater_or_equal.cc, less.cc, less_or_equal.cc,
not_equal): New.
* testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc:
New.
* testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc:
New.
* testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc: New.
* testsuite/tr1/6_containers/array/requirements/(contiguous.cc,
instantiate, typedefs, zero_size_arrays): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89429 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
16 files changed, 762 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 00000000000..844ca5a7f54 --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..d081b3daa87 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/max_size.cc @@ -0,0 +1,53 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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/capacity/size.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/capacity/size.cc new file mode 100644 index 00000000000..d081b3daa87 --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..0ace9aec0df --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..3badc2033e6 --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..aaf0cb06fbe --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..c0debec764f --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..11ae4e8514c --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..f166ae74873 --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 00000000000..f885424b6aa --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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 }; +} + +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 00000000000..1b178565296 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc @@ -0,0 +1,54 @@ +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 6.2.2 Class template array + +#include <tr1/array> +#include <stdexcept> + +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); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } +} + +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 00000000000..890704fb8ed --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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/contiguous.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/contiguous.cc new file mode 100644 index 00000000000..2643600f431 --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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/instantiate.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/instantiate.cc new file mode 100644 index 00000000000..f4d7b68b422 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/instantiate.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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/typedefs.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/typedefs.cc new file mode 100644 index 00000000000..225426d54b3 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/typedefs.cc @@ -0,0 +1,49 @@ +// { dg-do compile } + +// 2004-10-20 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 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 00000000000..95d927514c1 --- /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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 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( 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; +} + |