summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/23_containers/vector/cons
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/23_containers/vector/cons
downloadcbb-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/23_containers/vector/cons')
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/1.cc47
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/2.cc48
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/3.cc53
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/4.cc584
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc39
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc87
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc40
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/moveable.cc62
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/moveable2.cc55
9 files changed, 1015 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc
new file mode 100644
index 000000000..f17de5c57
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/1.cc
@@ -0,0 +1,47 @@
+// 1999-06-29 bkoz
+
+// Copyright (C) 1999-2001, 2002, 2003, 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/>.
+
+// 23.2.4.1 vector constructors, copy, and assignment
+
+#include <vector>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ struct A { };
+
+struct B { };
+
+void test01()
+{
+ // 1
+ std::vector< A<B> > vec01;
+ std::vector< A<B> > vec02(5);
+ typedef std::vector< A<B> >::size_type size_type;
+
+ vec01 = vec02;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc
new file mode 100644
index 000000000..24add08ab
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/2.cc
@@ -0,0 +1,48 @@
+// 1999-06-29 bkoz
+
+// Copyright (C) 1999-2001, 2002, 2003, 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/>.
+
+// 23.2.4.1 vector constructors, copy, and assignment
+
+#include <vector>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ struct A { };
+
+struct B { };
+
+// 2
+template class std::vector<double>;
+template class std::vector< A<B> >;
+
+// libstdc++/102
+void test02()
+{
+ std::vector<int> v1;
+ std::vector<int> v2(v1);
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc
new file mode 100644
index 000000000..03859ece7
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/3.cc
@@ -0,0 +1,53 @@
+// 1999-06-29 bkoz
+
+// Copyright (C) 1999-2001, 2002, 2003, 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/>.
+
+// 23.2.4.1 vector constructors, copy, and assignment
+
+#include <vector>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+// test range constructors and range-fill constructor
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+ const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
+ const int B[] = {7, 7, 7, 7, 7};
+ const int N = sizeof(A) / sizeof(int);
+ const int M = sizeof(B) / sizeof(int);
+
+ std::vector<int> v3(A, A + N);
+ VERIFY(std::equal(v3.begin(), v3.end(), A));
+
+ std::vector<int> v4(v3.begin(), v3.end());
+ VERIFY(std::equal(v4.begin(), v4.end(), A));
+
+ std::vector<int> v5(M, 7);
+ VERIFY(std::equal(v5.begin(), v5.end(), B));
+ VERIFY(std::equal(B, B + M, v5.begin()));
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc
new file mode 100644
index 000000000..27d496ac9
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc
@@ -0,0 +1,584 @@
+// 1999-06-29 bkoz
+
+// Copyright (C) 1999-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/>.
+
+// 23.2.4.1 vector constructors, copy, and assignment
+
+#include <vector>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+using __gnu_test::copy_tracker;
+using __gnu_test::tracker_allocator_counter;
+using __gnu_test::tracker_allocator;
+using __gnu_test::copy_constructor;
+using __gnu_test::assignment_operator;
+
+// @fn test_default_ctor_exception_gurantee This test verifies that if
+// one of the vector's contained objects throws an exception from its
+// constructor while the vector is being constructed and filled with
+// default values, all memory is returned to the allocator whence it
+// came.
+void
+test_default_ctor_exception_gurantee()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ copy_tracker::reset();
+ copy_constructor::throw_on(3);
+ tracker_allocator_counter::reset();
+
+ // run test
+ try
+ {
+ T ref;
+ X a(7, ref);
+ VERIFY(false);
+ }
+ catch (...)
+ {
+ }
+
+ // assert postconditions
+ VERIFY( tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count() );
+
+ // teardown
+}
+
+// @fn test_copy_ctor_exception_gurantee This test verifies that if
+// one of the vector's contained objects throws an exception from its
+// constructor while the vector is being copy constructed, all memory
+// is returned to the allocator whence it came.
+void
+test_copy_ctor_exception_gurantee()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ tracker_allocator_counter::reset();
+ {
+ X a(7);
+ copy_tracker::reset();
+ copy_constructor::throw_on(3);
+
+ // run test
+ try
+ {
+ X u(a);
+ VERIFY(false);
+ }
+ catch (...)
+ {
+ }
+ }
+
+ // assert postconditions
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+// operator=()
+//
+// case 1: lhs.size() > rhs.size()
+// case 2: lhs.size() < rhs.size() < lhs.capacity()
+// case 3: lhs.capacity() < rhs.size()
+//
+void
+test_assignment_operator_1()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ X r(9);
+ X a(r.size() - 2);
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+
+ // preconditions
+ VERIFY(r.size() > a.size());
+
+ // run test
+ r = a;
+
+ // assert postconditions
+ VERIFY(r == a);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == 0);
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_assignment_operator_2()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ X r(1);
+ r.reserve(17);
+ X a(r.size() + 7);
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+
+ // preconditions
+ VERIFY(r.size() < a.size());
+ VERIFY(a.size() < r.capacity());
+
+ // run test
+ r = a;
+
+ // assert postconditions
+ VERIFY(r == a);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == 0);
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_assignment_operator_3()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ tracker_allocator_counter::reset();
+ {
+ X r(1);
+ X a(r.capacity() + 7);
+ copy_tracker::reset();
+
+ // preconditions
+ VERIFY(r.capacity() < a.size());
+
+ // run test
+ r = a;
+
+ // assert postconditions
+ VERIFY(r == a);
+ }
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_assignment_operator_3_exception_guarantee()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ tracker_allocator_counter::reset();
+ {
+ X r(1);
+ X a(r.capacity() + 7);
+ copy_tracker::reset();
+ copy_constructor::throw_on(3);
+
+ // preconditions
+ VERIFY(r.capacity() < a.size());
+
+ // run test
+ try
+ {
+ r = a;
+ VERIFY(false);
+ }
+ catch (...)
+ {
+ }
+ }
+
+ // assert postconditions
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+// fill assign()
+//
+// case 1: [23.2.4.1 (3)] n <= size()
+// case 2: [23.2.4.1 (3)] size() < n <= capacity()
+// case 3: [23.2.4.1 (3)] n > capacity()
+// case 4: [23.2.4.1 (3)] n > capacity(), exception guarantees
+// case 5: [23.1.1 (9)] fill assign disguised as a range assign
+//
+void
+test_fill_assign_1()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ X a(7);
+ X::size_type old_size = a.size();
+ X::size_type new_size = old_size - 2;
+ const T t;
+
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+
+ // run test
+ a.assign(new_size, t);
+
+ // assert postconditions
+ VERIFY(a.size() == new_size);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == 0);
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_fill_assign_2()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ X a(7);
+ a.reserve(11);
+ X::size_type old_size = a.size();
+ X::size_type old_capacity = a.capacity();
+ X::size_type new_size = old_size + 2;
+ const T t;
+
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+
+ // assert preconditions
+ VERIFY(old_size < new_size);
+ VERIFY(new_size <= old_capacity);
+
+ // run test
+ a.assign(new_size, t);
+
+ // assert postconditions
+ VERIFY(a.size() == new_size);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == 0);
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_fill_assign_3()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ tracker_allocator_counter::reset();
+ {
+ X a(7);
+ X::size_type old_capacity = a.capacity();
+ X::size_type new_size = old_capacity + 4;
+ const T t;
+
+ copy_tracker::reset();
+
+ // assert preconditions
+ VERIFY(new_size > old_capacity);
+
+ // run test
+ a.assign(new_size, t);
+
+ // assert postconditions
+ VERIFY(a.size() == new_size);
+ }
+
+ VERIFY(tracker_allocator_counter::get_allocation_count() > 0);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_fill_assign_3_exception_guarantee()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ tracker_allocator_counter::reset();
+ {
+ X a(7);
+ X::size_type old_size = a.size();
+ X::size_type old_capacity = a.capacity();
+ X::size_type new_size = old_capacity + 4;
+ const T t;
+
+ copy_tracker::reset();
+ copy_constructor::throw_on(3);
+
+ // assert preconditions
+ VERIFY(new_size > old_capacity);
+
+ // run test
+ try
+ {
+ a.assign(new_size, t);
+ VERIFY(false);
+ }
+ catch (...)
+ {
+ }
+
+ // assert postconditions
+ VERIFY(a.size() == old_size);
+ VERIFY(a.capacity() == old_capacity);
+ }
+
+ VERIFY(tracker_allocator_counter::get_allocation_count() > 0);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_fill_assign_4()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ X a(7);
+ X::size_type old_size = a.size();
+ X::size_type new_size = old_size - 2;
+ X::size_type new_value = 117;
+
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+
+ // run test
+ a.assign(new_size, new_value);
+
+ // assert postconditions
+ VERIFY(a.size() == new_size);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == 0);
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+// range assign()
+//
+// case 1: [23.2.4.1 (2)] input iterator
+// case 2: [23.2.4.1 (2)] forward iterator, distance(first, last) <= size()
+// case 3: [23.2.4.1 (2)]
+// forward iterator, size() < distance(first, last) <= capacity()
+// case 4: [23.2.4.1 (2)] forward iterator, distance(first, last) > capacity()
+// case 5: [23.2.4.1 (2)]
+// forward iterator, distance(first, last) > capacity(),
+// exception guarantees
+void
+test_range_assign_1()
+{
+ // @TODO
+}
+
+void
+test_range_assign_2()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ X a(7);
+ X b(3);
+
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+
+ // assert preconditions
+ VERIFY(b.size() < a.capacity());
+
+ // run test
+ a.assign(b.begin(), b.end());
+
+ // assert postconditions
+ VERIFY(a.size() == b.size());
+ VERIFY(a == b);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == 0);
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_range_assign_3()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ X a(7);
+ a.reserve(a.size() + 7);
+ X b(a.size() + 3);
+
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+
+ // assert preconditions
+ VERIFY(a.size() < b.size());
+ VERIFY(b.size() < a.capacity());
+
+ // run test
+ a.assign(b.begin(), b.end());
+
+ // assert postconditions
+ VERIFY(a.size() == b.size());
+ VERIFY(a == b);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == 0);
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_range_assign_4()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ tracker_allocator_counter::reset();
+ {
+ X a(7);
+ X b(a.capacity() + 7);
+
+ copy_tracker::reset();
+
+ // assert preconditions
+ VERIFY(b.size() > a.capacity());
+
+ // run test
+ a.assign(b.begin(), b.end());
+
+ // assert postconditions
+ VERIFY(a.size() == b.size());
+ VERIFY(a == b);
+ }
+ VERIFY(tracker_allocator_counter::get_allocation_count() > 0);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+void
+test_range_assign_4_exception_guarantee()
+{
+ // setup
+ bool test __attribute__((unused)) = true;
+ typedef copy_tracker T;
+ typedef std::vector<T, tracker_allocator<T> > X;
+
+ tracker_allocator_counter::reset();
+ {
+ X a(7);
+ X b(a.capacity() + 7);
+
+ copy_tracker::reset();
+ copy_constructor::throw_on(3);
+
+ // assert preconditions
+ VERIFY(b.size() > a.capacity());
+
+ // run test
+ try
+ {
+ a.assign(b.begin(), b.end());
+ VERIFY(false);
+ }
+ catch (...)
+ {
+ }
+ }
+
+ // assert postconditions
+ VERIFY(tracker_allocator_counter::get_allocation_count() > 0);
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
+
+ // teardown
+ copy_tracker::reset();
+ tracker_allocator_counter::reset();
+}
+
+
+int main()
+{
+ test_default_ctor_exception_gurantee();
+ test_copy_ctor_exception_gurantee();
+ test_assignment_operator_1();
+ test_assignment_operator_2();
+ test_assignment_operator_3();
+ test_assignment_operator_3_exception_guarantee();
+ test_fill_assign_1();
+ test_fill_assign_2();
+ test_fill_assign_3();
+ test_fill_assign_3_exception_guarantee();
+ test_fill_assign_4();
+ test_range_assign_1();
+ test_range_assign_2();
+ test_range_assign_3();
+ test_range_assign_4();
+ test_range_assign_4_exception_guarantee();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc
new file mode 100644
index 000000000..b469fdcab
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/6513.cc
@@ -0,0 +1,39 @@
+// 1999-06-29 bkoz
+
+// Copyright (C) 1999-2001, 2002, 2003, 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/>.
+
+// 23.2.4.1 vector constructors, copy, and assignment
+
+#include <vector>
+#include <string>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/6513
+void test04()
+{
+ const char* c_strings[5] = { "1", "2", "3", "4", "5" };
+ std::vector<std::string> strings(c_strings, c_strings + 5);
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc
new file mode 100644
index 000000000..18a2f1a02
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc
@@ -0,0 +1,87 @@
+// 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/>.
+
+#include <vector>
+#include <ext/new_allocator.h>
+
+using namespace std;
+using __gnu_cxx::new_allocator;
+
+template<typename T>
+ class clear_alloc : public new_allocator<T>
+ {
+ public:
+
+ template <typename T1>
+ struct rebind
+ { typedef clear_alloc<T1> other; };
+
+ virtual void clear() throw()
+ { }
+
+ clear_alloc() throw()
+ { }
+
+ clear_alloc(clear_alloc const&) throw() : new_allocator<T>()
+ { }
+
+ template<typename T1>
+ clear_alloc(clear_alloc<T1> const&) throw()
+ { }
+
+ virtual ~clear_alloc() throw()
+ { this->clear(); }
+
+ T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0)
+ {
+ this->clear();
+ return new_allocator<T>::allocate(n, hint);
+ }
+
+ void deallocate(T *ptr, typename new_allocator<T>::size_type n)
+ {
+ this->clear();
+ new_allocator<T>::deallocate(ptr, n);
+ }
+ };
+
+template<typename Container>
+ void Check_Container()
+ {
+ Container* pic = new Container;
+ int x = 230;
+
+ while (x--)
+ {
+ pic->push_back(x);
+ }
+
+ pic->get_allocator();
+
+ // The following has led to infinite recursions or cores.
+ pic->clear();
+
+ delete pic;
+ }
+
+
+int main()
+{
+ Check_Container<std::vector<int, clear_alloc<int> > >();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc
new file mode 100644
index 000000000..a33ba1ad6
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-18 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 <vector>
+#include <testsuite_hooks.h>
+#include <testsuite_api.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::vector<__gnu_test::NonCopyConstructible> v(1000);
+ VERIFY( std::distance(v.begin(), v.end()) == 1000 );
+ for(auto it = v.begin(); it != v.end(); ++it)
+ VERIFY( *it == -1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/moveable.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/moveable.cc
new file mode 100644
index 000000000..8807ad9b4
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/moveable.cc
@@ -0,0 +1,62 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 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/>.
+
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on vector (via swap). If the implementation changed
+// this test may begin to fail.
+
+#include <vector>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::vector<int> a,b;
+ a.push_back(1);
+ b = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 );
+
+ std::vector<int> c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == 1 );
+ VERIFY( b.size() == 0 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::vector<bool> a,b;
+ a.push_back(1);
+ b = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == 1 && a.size() == 0 );
+
+ std::vector<bool> c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == 1 );
+ VERIFY( b.size() == 0 );
+}
+
+int main(void)
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/moveable2.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/moveable2.cc
new file mode 100644
index 000000000..ab04ccf0c
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/moveable2.cc
@@ -0,0 +1,55 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 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 <vector>
+#include <iterator>
+#include <testsuite_iterators.h>
+#include <testsuite_rvalref.h>
+
+using namespace __gnu_test;
+typedef std::vector<rvalstruct> test_type;
+
+// Empty constructor doesn't require a copy constructor
+void
+test01()
+{ test_type d; }
+
+// Constructing from a range that returns rvalue references doesn't
+// require a copy constructor.
+void
+test02(rvalstruct* begin, rvalstruct* end)
+{
+ test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
+}
+
+// Constructing from a input iterator range that returns rvalue
+// references doesn't require a copy constructor either.
+void
+test03(input_iterator_wrapper<rvalstruct> begin,
+ input_iterator_wrapper<rvalstruct> end)
+{
+ test_type d(std::make_move_iterator(begin), std::make_move_iterator(end));
+}
+
+// Neither does destroying one.
+void
+test04(test_type* d)
+{ delete d; }